diff --git a/MangoPay/ApiCards.php b/MangoPay/ApiCards.php index 21e294f7..e4894783 100644 --- a/MangoPay/ApiCards.php +++ b/MangoPay/ApiCards.php @@ -66,4 +66,14 @@ public function GetTransactions($cardId, & $pagination = null, $filter = null, $ { return $this->GetList('transactions_get_for_card', $pagination, '\MangoPay\Transaction', $cardId, $filter, $sorting); } + + /** + * Validate a card + * @param $cardId + * @return \MangoPay\Card + * @throws Libraries\Exception + */ + public function ValidateCard($cardId){ + return $this->GetObject('card_validate', '\MangoPay\Card', $cardId); + } } \ No newline at end of file diff --git a/MangoPay/Libraries/ApiBase.php b/MangoPay/Libraries/ApiBase.php index 5c3b4bea..5c037339 100644 --- a/MangoPay/Libraries/ApiBase.php +++ b/MangoPay/Libraries/ApiBase.php @@ -51,6 +51,7 @@ protected function getLogger() 'card_get' => array('/cards/%s', RequestType::GET), 'cards_get_by_fingerprint' => array('/cards/fingerprints/%s', RequestType::GET), 'card_save' => array('/cards/%s', RequestType::PUT), + 'card_validate' => array('/cards/%s/validate', RequestType::POST), // pay ins URLs 'payins_card-web_create' => array( '/payins/card/web/', RequestType::POST ), diff --git a/tests/cases/CardsTest.php b/tests/cases/CardsTest.php index 5a6462ef..fe2f7756 100644 --- a/tests/cases/CardsTest.php +++ b/tests/cases/CardsTest.php @@ -2,6 +2,7 @@ namespace MangoPay\Tests\Cases; +use MangoPay\Libraries\Exception; use MangoPay\SortDirection; use MangoPay\Sorting; @@ -53,4 +54,20 @@ function test_Card_GetTransactions() $this->assertNotNull($transactions); $this->assertInternalType('array', $transactions); } + + function test_Card_Validate() + { + $new_api = $this->buildNewMangoPayApi(); + + $john = $this->getNewJohn(); + $payIn = $this->getNewPayInCardDirect($john->Id); + $card = $new_api->Cards->Get($payIn->PaymentDetails->CardId); + + try { + $validatedCard = $new_api->Cards->ValidateCard($card->Id); + $this->assertNotNull($validatedCard); + } catch (Exception $e) { + print_r("can't test due to client issues"); + } + } } \ No newline at end of file