Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added new method for CardPreauthorization transactions #435

Merged
merged 1 commit into from
Oct 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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