From e75c7f142cc457136bc1cb1215f2012d7f9a3782 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Wed, 21 Oct 2020 09:21:27 +0300 Subject: [PATCH] added new method for CardPreauthorization transactions --- MangoPay/ApiCardPreAuthorizations.php | 5 +++++ MangoPay/Libraries/ApiBase.php | 1 + tests/cases/PayInsTest.php | 3 +++ 3 files changed, 9 insertions(+) diff --git a/MangoPay/ApiCardPreAuthorizations.php b/MangoPay/ApiCardPreAuthorizations.php index 746ab284..1715d8d1 100644 --- a/MangoPay/ApiCardPreAuthorizations.php +++ b/MangoPay/ApiCardPreAuthorizations.php @@ -35,4 +35,9 @@ public function Update($cardPreAuthorization) { return $this->SaveObject('preauthorization_save', $cardPreAuthorization, '\MangoPay\CardPreAuthorization'); } + + public function GetTransactions($cardPreAuthorizationId, & $pagination = null, $filter = null, $sorting = null) + { + return $this->GetList('preauthorization_transactions_get', $pagination, '\MangoPay\Transaction', $cardPreAuthorizationId, $filter, $sorting); + } } diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 5c037339..d7c74d20 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -47,6 +47,7 @@ protected function getLogger() 'preauthorizations_get_for_card' => array('/cards/%s/preauthorizations', RequestType::GET), 'preauthorizations_get_for_user' => array('/users/%s/preauthorizations', RequestType::GET), 'preauthorization_save' => array('/preauthorizations/%s', RequestType::PUT), + 'preauthorization_transactions_get' => array('/preauthorizations/%s/transactions', RequestType::GET), 'card_get' => array('/cards/%s', RequestType::GET), 'cards_get_by_fingerprint' => array('/cards/fingerprints/%s', RequestType::GET), diff --git a/tests/cases/PayInsTest.php b/tests/cases/PayInsTest.php index 63c7a936..f8aa23d2 100644 --- a/tests/cases/PayInsTest.php +++ b/tests/cases/PayInsTest.php @@ -134,6 +134,8 @@ function test_PayIns_PreAuthorizedDirect() $createPayIn = $this->_api->PayIns->Create($payIn); + $transactions = $this->_api->CardPreAuthorizations->GetTransactions($cardPreAuthorization->Id); + $this->assertTrue($createPayIn->Id > 0); $this->assertEquals($wallet->Id, $createPayIn->CreditedWalletId); $this->assertEquals(\MangoPay\PayInPaymentType::Preauthorized, $createPayIn->PaymentType); @@ -146,6 +148,7 @@ function test_PayIns_PreAuthorizedDirect() $this->assertEquals($user->Id, $createPayIn->AuthorId); $this->assertEquals(PayInStatus::Succeeded, $createPayIn->Status); $this->assertEquals('PAYIN', $createPayIn->Type); + $this->assertEquals($transactions[0]->Status, TransactionStatus::Succeeded); } function test_PayIns_BankWireDirect_Create()