Skip to content

Commit

Permalink
Merge pull request #625 from Mangopay/feature/bin_metadata_endpoint
Browse files Browse the repository at this point in the history
feature/ Implemented bin metadata endpoint
  • Loading branch information
iulian03 authored Feb 13, 2024
2 parents 006def7 + afdd750 commit 9f8ecb5
Show file tree
Hide file tree
Showing 4 changed files with 92 additions and 0 deletions.
10 changes: 10 additions & 0 deletions MangoPay/ApiPayIns.php
Original file line number Diff line number Diff line change
Expand Up @@ -163,4 +163,14 @@ public function CreateGooglePay($payIn, $idempotencyKey = null)
{
return $this->CreateObject('payins_googlepay-direct_create_v2', $payIn, '\MangoPay\PayIn', null, null, $idempotencyKey);
}

/**
* Look up metadata from BIN or Google Pay token
* @param \MangoPay\PaymentMethodMetadata $paymentMethodMetadata \MangoPay\PaymentMethodMetadata object
* @return \MangoPay\PaymentMethodMetadata Object returned from API
*/
public function GetPaymentMethodMetadata(PaymentMethodMetadata $paymentMethodMetadata, $idempotencyKey = null)
{
return $this->CreateObject('payment_method-metadata', $paymentMethodMetadata, '\MangoPay\PaymentMethodMetadata', null, null, $idempotencyKey);
}
}
2 changes: 2 additions & 0 deletions MangoPay/Libraries/ApiBase.php
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,8 @@ protected function getLogger()
'payins_ideal-web_create' => ['/payins/payment-methods/ideal', RequestType::POST],
'payins_giropay-web_create' => ['/payins/payment-methods/giropay', RequestType::POST],

'payment_method-metadata' => ['/payment-methods/metadata', RequestType::POST],

'payins_recurring_registration' => ['/recurringpayinregistrations', RequestType::POST],
'payins_recurring_registration_get' => ['/recurringpayinregistrations/%s', RequestType::GET],
'payins_recurring_registration_put' => ['/recurringpayinregistrations/%s', RequestType::PUT],
Expand Down
63 changes: 63 additions & 0 deletions MangoPay/PaymentMethodMetadata.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
<?php

namespace MangoPay;

class PaymentMethodMetadata extends Libraries\EntityBase
{
/**
* The type of metadata. Allowed values: BIN, GOOGLE_PAY
* @var string
*/
public $Type;

/**
* The bank identification number (BIN). (Format: 6 or 8 digits)
* @var string
*/
public $Bin;

/**
* The tokenized payment data provided by the third-party payment method.
* @var string
*/
public $Token;

/**
* In the case of Google Pay, the format of the Token.
* PAN_ONLY – The card is registered in the Google account and requires 3DS authentication.
* CRYPTOGRAM_3DS – The card is enrolled in the customer’s Google Wallet and authentication is handled by the Android device.
* @var string
*/
public $TokenFormat;

/**
* The type of the card. Allowed / Returned / Default values: CREDIT, DEBIT, CHARGE CARD
* @var string
*/
public $CardType;

/**
* The country where the card was issued. Format: ISO-3166 alpha-2 two-letter country code
* @var string
*
*/
public $IssuerCountryCode;

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

/**
* Whether the card is held in a personal or commercial capacity.
* @var string
*/
public $CommercialIndicator;

/**
* Additional data about the card based on the BIN. In the case of co-branded card products, two objects are returned.
* @var array
*/
public $BinData;
}
17 changes: 17 additions & 0 deletions tests/Cases/PayInsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -898,6 +898,23 @@ public function test_PayIns_Create_Giropay_Web()
$this->assertEquals($payIn->Id, $fetchedPayIn->Id);
}

public function test_CardDirect_getPaymentMethodMetadata()
{
$payin = $this->getNewPayInCardDirect();

$payment_method_metadata = new \MangoPay\PaymentMethodMetadata();
$payment_method_metadata->Type = "BIN";
$payment_method_metadata->Bin = ($payin->PaymentDetails->CardInfo->BIN);

$result_metadata = $this->_api->PayIns->GetPaymentMethodMetadata($payment_method_metadata);

$this->assertNotNull($result_metadata);
$this->assertNotNull($result_metadata->IssuerCountryCode);
$this->assertNotNull($result_metadata->IssuingBank);
$this->assertNotNull($result_metadata->BinData);
$this->assertNotNull($result_metadata->CardType);
}

// /**
// * @throws \Exception
// */
Expand Down

0 comments on commit 9f8ecb5

Please sign in to comment.