Skip to content

Commit

Permalink
Merge pull request #621 from Mangopay/feature/implement_cardinfo
Browse files Browse the repository at this point in the history
feature / Added CardInfo parameter to 4 endpoints
  • Loading branch information
silvianagh authored Dec 22, 2023
2 parents febcfb9 + 8f9578a commit 8e8bd5e
Show file tree
Hide file tree
Showing 7 changed files with 117 additions and 10 deletions.
42 changes: 42 additions & 0 deletions MangoPay/CardInfo.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace MangoPay;

class CardInfo extends Libraries\Dto
{
/**
* The 6-digit bank identification number (BIN) of the card issuer.
* @var string
*/
public $BIN;

/**
* The name of the card issuer.
* @var string
*/
public $IssuingBank;

/**
* The country where the card was issued.
* @var string
*/
public $IssuerCountryCode;

/**
* The type of card product: DEBIT, CREDIT, CHARGE CARD.
* @var string
*/
public $Type;

/**
* The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc.
* @var string
*/
public $Brand;

/**
* The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc.
* @var string
*/
public $SubType;
}
6 changes: 6 additions & 0 deletions MangoPay/CardPreAuthorization.php
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,12 @@ class CardPreAuthorization extends Libraries\EntityBase
*/
public $Applied3DSVersion;

/**
* Information of the card
* @var object
*/
public $CardInfo;

/**
* Get array with mapping which property is object and what type of object
* @return array
Expand Down
6 changes: 6 additions & 0 deletions MangoPay/Deposit.php
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,12 @@ class Deposit extends Libraries\EntityBase
*/
public $Applied3DSVersion;

/**
* Information of the card
* @var object
*/
public $CardInfo;

/**
* Get array with mapping which property is object and what type of object
* @return array
Expand Down
6 changes: 6 additions & 0 deletions MangoPay/PayInPaymentDetailsCard.php
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,10 @@ class PayInPaymentDetailsCard extends Libraries\Dto implements PayInPaymentDetai
* @var string
*/
public $BankName;

/**
* Information of the card
* @var object
*/
public $CardInfo;
}
12 changes: 12 additions & 0 deletions tests/Cases/CardPreAuthorizationsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,18 @@ public function test_CardPreAuthorization_Get()
$this->assertNotNull($getCardPreAuthorization->RemainingFunds);
}

public function test_CardPreAuthorization_CheckCardInfo()
{
$cardPreAuthorization = $this->getJohnsCardPreAuthorization();

$getCardPreAuthorization = $this->_api->CardPreAuthorizations->Get($cardPreAuthorization->Id);

$this->assertNotNull($getCardPreAuthorization->CardInfo);
$this->assertNotNull($getCardPreAuthorization->CardInfo->Type);
$this->assertNotNull($getCardPreAuthorization->CardInfo->Brand);
$this->assertNotNull($getCardPreAuthorization->CardInfo->IssuingBank);
}


// function test_CardPreAuthorization_Update()
// {
Expand Down
17 changes: 17 additions & 0 deletions tests/Cases/DepositTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,23 @@ public function test_Deposits_Create()
$this->assertNotNull($deposit);
}

/**
* @throws \Exception
*/
public function test_Deposits_CheckCardInfo()
{
$user = $this->getJohn();
$cardRegistration = $this->getUpdatedCardRegistration($user->Id);

$deposit = $this->_api->Deposits->Create($this->getNewDeposit($cardRegistration->CardId, $user->Id));

$this->assertNotNull($deposit);
$this->assertNotNull($deposit->CardInfo);
$this->assertNotNull($deposit->CardInfo->Type);
$this->assertNotNull($deposit->CardInfo->Brand);
$this->assertNotNull($deposit->CardInfo->IssuingBank);
}

/**
* @throws \Exception
*/
Expand Down
38 changes: 28 additions & 10 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,14 @@

namespace MangoPay\Tests\Cases;

use MangoPay\AVSResult;
use MangoPay\BankingAlias;
use MangoPay\BrowserInfo;
use MangoPay\CreateCardPreAuthorizedDepositPayIn;
use MangoPay\CurrencyIso;
use MangoPay\DebitedBankAccount;
use MangoPay\Libraries\Exception;
use MangoPay\Money;
use MangoPay\PayIn;
use MangoPay\PayInExecutionType;
use MangoPay\PayInPaymentDetails;
use MangoPay\PayInPaymentDetailsBankWire;
use MangoPay\PayInPaymentDetailsCard;
use MangoPay\PayInPaymentType;
use MangoPay\PayInRecurringRegistrationUpdate;
use MangoPay\PayInStatus;
use MangoPay\RecurringPayInCIT;
use MangoPay\Shipping;
use MangoPay\TransactionStatus;

/**
Expand Down Expand Up @@ -79,6 +69,10 @@ public function test_PayIns_Create_CardDirect()
$this->assertEquals($wallet->Balance->Amount, $beforeWallet->Balance->Amount + $payIn->CreditedFunds->Amount);
$this->assertEquals(PayInStatus::Succeeded, $payIn->Status);
$this->assertEquals('PAYIN', $payIn->Type);

$this->assertNotNull($payIn->PaymentDetails->CardInfo);
$this->assertNotNull($payIn->PaymentDetails->CardInfo->BIN);
$this->assertNotNull($payIn->PaymentDetails->CardInfo->Type);
}

public function test_PayIns_Get_CardDirect()
Expand Down Expand Up @@ -598,6 +592,30 @@ public function test_Create_Recurring_PayIn_CIT()
$this->assertNotNull($result);
}

public function test_Create_Recurring_PayIn_CIT_Check_CardInfo()
{
self::$JohnsWalletWithMoney = null;// Reset the cache value

$registration = $this->getRecurringPayin();

$cit = new RecurringPayInCIT();
$cit->RecurringPayinRegistrationId = $registration->Id;
$cit->IpAddress = "2001:0620:0000:0000:0211:24FF:FE80:C12C";
$cit->SecureModeReturnURL = "http://www.my-site.com/returnurl";
$cit->StatementDescriptor = "lorem";
$cit->Tag = "custom meta";
$cit->BrowserInfo = $this->getBrowserInfo();

$result = $this->_api->PayIns->CreateRecurringPayInRegistrationCIT($cit);

$this->assertNotNull($result);
$card_info = $result->PaymentDetails->CardInfo;
$this->assertNotEmpty($card_info);
$this->assertNotEmpty($card_info->Brand);
$this->assertNotEmpty($card_info->Type);
$this->assertNotEmpty($card_info->IssuingBank);
}

public function test_Create_Recurring_PayIn_CIT_With_Debited_Funds_And_Fees()
{
self::$JohnsWalletWithMoney = null;// Reset the cache value
Expand Down

0 comments on commit 8e8bd5e

Please sign in to comment.