Skip to content

Commit

Permalink
Merge pull request #427 from Mangopay/feature/card-validity
Browse files Browse the repository at this point in the history
Feature/card validity
  • Loading branch information
catacraciun authored Sep 25, 2020
2 parents e45b60e + f103cd4 commit 10c6c48
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MangoPay/ApiCards.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
1 change: 1 addition & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 ),
Expand Down
17 changes: 17 additions & 0 deletions tests/cases/CardsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

namespace MangoPay\Tests\Cases;

use MangoPay\Libraries\Exception;
use MangoPay\SortDirection;
use MangoPay\Sorting;

Expand Down Expand Up @@ -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");
}
}
}

0 comments on commit 10c6c48

Please sign in to comment.