Skip to content

Commit

Permalink
Temporary calls to the V2 API
Browse files Browse the repository at this point in the history
  • Loading branch information
lukasz-puslecki committed Nov 25, 2014
1 parent eaf259d commit 27003a1
Show file tree
Hide file tree
Showing 6 changed files with 148 additions and 0 deletions.
24 changes: 24 additions & 0 deletions MangoPaySDK/entities/temporaryImmediatePayIn.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
<?php
namespace MangoPay;

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
* Temporary immediate pay-in entity.
*/
class TemporaryImmediatePayIn extends Transaction {

/**
* Payment card Id
* @var string
*/
public $PaymentCardId;

/**
* Credited wallet Id
* @var string
*/
public $CreditedWalletId;
}
48 changes: 48 additions & 0 deletions MangoPaySDK/entities/temporaryPaymentCard.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
<?php
namespace MangoPay;

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
* Temporary Payment Card entity.
*/
class TemporaryPaymentCard extends EntityBase {

/**
* User Id
* @var string
*/
public $UserId;

/**
* Culture
* @var string
*/
public $Culture;

/**
* Return URL
* @var string
*/
public $ReturnURL;

/**
* Template URL
* @var string
*/
public $TemplateURL;

/**
* Redirect URL
* @var string
*/
public $RedirectURL;

/**
* Alias
* @var string
*/
public $Alias;
}
6 changes: 6 additions & 0 deletions MangoPaySDK/tools/apiBase.inc
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,12 @@ abstract class ApiBase {
'kyc_documents_save' => array( '/users/%s/KYC/documents/%s', RequestType::PUT ),
'kyc_page_create' => array( '/users/%s/KYC/documents/%s/pages', RequestType::POST ),
'kyc_documents_all' => array( '/KYC/documents', RequestType::GET ),

// These are temporary functions and WILL be removed in the future.
// Please, contact with support before using these features or if you have any questions.
'temp_paymentcards_create' => array( '/temp/paymentcards', RequestType::POST ),
'temp_paymentcards_get' => array( '/temp/paymentcards/%s', RequestType::GET ),
'temp_immediatepayins_create' => array( '/temp/immediate-payins', RequestType::POST )
);

/**
Expand Down
26 changes: 26 additions & 0 deletions MangoPaySDK/tools/apiCards.inc
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,30 @@ class ApiCards extends ApiBase {
public function Update($card) {
return $this->SaveObject('card_save', $card, '\MangoPay\Card');
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
* Create new temporary payment card
* @param \MangoPay\TemporaryPaymentCard $paymentCard Payment card object to create
* @return \MangoPay\TemporaryPaymentCard Card registration object returned from API
*/
public function CreateTemporaryPaymentCard($paymentCard) {
return $this->CreateObject('temp_paymentcards_create', $paymentCard, '\MangoPay\TemporaryPaymentCard');
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
* Get temporary payment card
* @param string $paymentCardId Card identifier
* @return \MangoPay\TemporaryPaymentCard object returned from API
*/
public function GetTemporaryPaymentCard($paymentCardId) {
return $this->GetObject('temp_paymentcards_get', $paymentCardId, '\MangoPay\TemporaryPaymentCard');
}
}
13 changes: 13 additions & 0 deletions MangoPaySDK/tools/apiPayIns.inc
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ class ApiPayIns extends ApiBase {
return $this->GetObject('payins_getrefunds', $payInId, '\MangoPay\Refund');
}

/**
* WARNING!!
* It's temporary entity and it will be removed in the future.
* Please, contact with support before using these features or if you have any questions.
*
* Create new temporary immediate pay-in
* @param \MangoPay\TemporaryImmediatePayIn $immediatePayIn Immediate pay-in object to create
* @return \MangoPay\TemporaryImmediatePayIn Immediate pay-in object returned from API
*/
public function CreateTemporaryImmediatePayIn($immediatePayIn) {
return $this->CreateObject('temp_immediatepayins_create', $immediatePayIn, '\MangoPay\TemporaryImmediatePayIn');
}

private function GetPaymentKey($payIn) {

if (!isset($payIn->PaymentDetails) || !is_object($payIn->PaymentDetails))
Expand Down
31 changes: 31 additions & 0 deletions tests/cases/cardRegistrations.php
Original file line number Diff line number Diff line change
Expand Up @@ -80,4 +80,35 @@ function test_Cards_Update(){
$this->assertEqual($updatedCard->Validity, \MangoPay\CardValidity::Valid);
$this->assertFalse($updatedCard->Active);
}

function test_TemporaryPaymentCard_Create(){
$user = $this->getJohn();
$paymentCard = new \MangoPay\TemporaryPaymentCard();
$paymentCard->UserId = $user->Id;
$paymentCard->Tag = "Test tag";
$paymentCard->Culture = "FR";
$paymentCard->ReturnURL = "http://test.com/test";
$paymentCard->TemplateURL = "https://test.com/test";

$paymentCardCreated = $this->_api->Cards->CreateTemporaryPaymentCard($paymentCard);

$this->assertTrue($paymentCardCreated->Id > 0);
$this->assertEqual($paymentCardCreated->UserId, $user->Id);
}

function test_TemporaryPaymentCard_Get(){
$user = $this->getJohn();
$paymentCard = new \MangoPay\TemporaryPaymentCard();
$paymentCard->UserId = $user->Id;
$paymentCard->Tag = "Test tag";
$paymentCard->Culture = "FR";
$paymentCard->ReturnURL = "http://test.com/test";
$paymentCard->TemplateURL = "https://test.com/test";
$paymentCardCreated = $this->_api->Cards->CreateTemporaryPaymentCard($paymentCard);

$paymentCardGet = $this->_api->Cards->GetTemporaryPaymentCard($paymentCardCreated->Id);

$this->assertTrue($paymentCardGet->Id > 0);
$this->assertEqual($paymentCardGet->Id, $paymentCardCreated->Id);
}
}

0 comments on commit 27003a1

Please sign in to comment.