From 27003a1bc5365011470313ef6e0c6c10ff723e05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Pu=C5=9Blecki?= Date: Tue, 25 Nov 2014 10:12:50 +0100 Subject: [PATCH] Temporary calls to the V2 API --- .../entities/temporaryImmediatePayIn.inc | 24 ++++++++++ MangoPaySDK/entities/temporaryPaymentCard.inc | 48 +++++++++++++++++++ MangoPaySDK/tools/apiBase.inc | 6 +++ MangoPaySDK/tools/apiCards.inc | 26 ++++++++++ MangoPaySDK/tools/apiPayIns.inc | 13 +++++ tests/cases/cardRegistrations.php | 31 ++++++++++++ 6 files changed, 148 insertions(+) create mode 100644 MangoPaySDK/entities/temporaryImmediatePayIn.inc create mode 100644 MangoPaySDK/entities/temporaryPaymentCard.inc diff --git a/MangoPaySDK/entities/temporaryImmediatePayIn.inc b/MangoPaySDK/entities/temporaryImmediatePayIn.inc new file mode 100644 index 00000000..77582994 --- /dev/null +++ b/MangoPaySDK/entities/temporaryImmediatePayIn.inc @@ -0,0 +1,24 @@ + 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 ) ); /** diff --git a/MangoPaySDK/tools/apiCards.inc b/MangoPaySDK/tools/apiCards.inc index 46e6610a..6e2a346e 100644 --- a/MangoPaySDK/tools/apiCards.inc +++ b/MangoPaySDK/tools/apiCards.inc @@ -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'); + } } \ No newline at end of file diff --git a/MangoPaySDK/tools/apiPayIns.inc b/MangoPaySDK/tools/apiPayIns.inc index a3e1243f..d1c0d7f8 100644 --- a/MangoPaySDK/tools/apiPayIns.inc +++ b/MangoPaySDK/tools/apiPayIns.inc @@ -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)) diff --git a/tests/cases/cardRegistrations.php b/tests/cases/cardRegistrations.php index 3bf54b95..46d1c93b 100644 --- a/tests/cases/cardRegistrations.php +++ b/tests/cases/cardRegistrations.php @@ -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); + } } \ No newline at end of file