diff --git a/MangoPay/ApiMandates.php b/MangoPay/ApiMandates.php index 06f58a9f..763b41d3 100644 --- a/MangoPay/ApiMandates.php +++ b/MangoPay/ApiMandates.php @@ -50,4 +50,16 @@ public function GetAll(& $pagination = null, $filter = null, $sorting = null) { return $this->GetList('mandates_all', $pagination, 'MangoPay\Mandate', null, $filter, $sorting); } + + /** + * Retrieves list of Transactions pertaining to a certain Mandate + * @param string $mandateId Mandate identifier + * @param \MangoPay\Pagination $pagination Pagination object + * @param \MangoPay\FilterTransactions $filter Filtering object + * @param \MangoPay\Sorting $sorting Sorting object + */ + public function GetTransactions($mandateId, & $pagination = null, $filter = null, $sorting = null) + { + return $this->GetList('transactions_get_for_mandate', $pagination, '\MangoPay\Transaction', $mandateId, $filter, $sorting); + } } diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 131b7907..61a593bc 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -171,8 +171,10 @@ protected function getLogger() 'ubo_declaration_update' => array( '/ubodeclarations/%s', RequestType::PUT ), 'ubo_declaration_get' => array( '/ubodeclarations/%s', RequestType::GET ), + 'transactions_get_for_mandate' => array( '/mandates/%s/transactions', RequestType::GET ), 'transactions_get_for_card' => array( '/cards/%s/transactions', RequestType::GET ), 'transactions_get_for_bank_account' => array( '/bankaccounts/%s/transactions', RequestType::GET ) + ); /** diff --git a/tests/cases/mandates.php b/tests/cases/mandates.php index 62a39fdd..d22bbd4f 100644 --- a/tests/cases/mandates.php +++ b/tests/cases/mandates.php @@ -46,4 +46,15 @@ function test_Mandates_GetAll() { $this->assertTrue(count($mandates) > 0); } + + function test_Mandate_GetTransactions() { + $mandate = $this->getJohnsMandate(); + $pagination = new \MangoPay\Pagination(); + $filter = new \MangoPay\FilterTransactions(); + + $transactions = $this->_api->Mandates->GetTransactions($mandate->Id, $pagination, $filter); + + $this->assertNotNull($transactions); + $this->assertIsA($transactions, 'array'); + } }