Skip to content

Commit

Permalink
Merge pull request #435 from Mangopay/feature/pre-authorization-trans…
Browse files Browse the repository at this point in the history
…actions

added new method for CardPreauthorization transactions
  • Loading branch information
catacraciun authored Oct 23, 2020
2 parents 4273b28 + e75c7f1 commit 0f79dfd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions MangoPay/ApiCardPreAuthorizations.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
3 changes: 3 additions & 0 deletions tests/cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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()
Expand Down

0 comments on commit 0f79dfd

Please sign in to comment.