Skip to content

Commit

Permalink
implemented PaymentMethodMetadata endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Feb 21, 2024
1 parent 05b8357 commit df0fd7f
Show file tree
Hide file tree
Showing 5 changed files with 110 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/apiMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ module.exports = {
"payins_ideal-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/ideal", "POST"],
"payins_giropay-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/giropay", "POST"],

"payment_method_metadata_get": ["/${apiVersion}/${clientId}/payment-methods/metadata", "POST"],

"payouts_bankwire_create": ["/${apiVersion}/${clientId}/payouts/bankwire/", "POST"],
"payouts_bankwire_get": ["/${apiVersion}/${clientId}/payouts/bankwire/${id}", "GET"],
"payouts_get": ["/${apiVersion}/${clientId}/payouts/${id}", "GET"],
Expand Down
16 changes: 16 additions & 0 deletions lib/models/BinData.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
var EntityBase = require('./EntityBase');

var BinData = EntityBase.extend({
defaults: {
/**
* The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc.
*/
Subtype: null,
/**
* The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc.
*/
Brand: null
}
});

module.exports = BinData;
46 changes: 46 additions & 0 deletions lib/models/PaymentMethodMetadata.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
var EntityBase = require('./EntityBase');

var BinData = EntityBase.extend({
defaults: {
/**
* The type of metadata. Allowed values: BIN, GOOGLE_PAY
*/
Type: null,
/**
* The bank identification number (BIN). (Format: 6 or 8 digits)
*/
Bin: null,
/**
* The tokenized payment data provided by the third-party payment method.
*/
Token: null,
/**
* 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.
*/
TokenFormat: null,
/**
* The type of the card. Allowed / Returned / Default values: CREDIT, DEBIT, CHARGE CARD
*/
CardType: null,
/**
* The country where the card was issued. Format: ISO-3166 alpha-2 two-letter country code
*/
IssuerCountryCode: null,
/**
* The name of the card issuer.
*/
IssuingBank: null,
/**
* Whether the card is held in a personal or commercial capacity.
*/
CommercialIndicator: null,
/**
* Additional data about the card based on the BIN. In the case of co-branded card products, two objects are returned.
*/
BinData: null
}
});

module.exports = BinData;
18 changes: 18 additions & 0 deletions lib/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ const PayInPaymentDetailsBlik = require("../models/PayInPaymentDetailsBlik");
const PayInPaymentDetailsKlarna = require("../models/PayInPaymentDetailsKlarna");
const PayInPaymentDetailsIdeal = require("../models/PayInPaymentDetailsIdeal");
const PayInPaymentDetailsGiropay = require("../models/PayInPaymentDetailsGiropay");
const PaymentMethodMetadata = require('../models/PaymentMethodMetadata');


var PayIns = Service.extend({
/**
Expand Down Expand Up @@ -233,6 +235,22 @@ var PayIns = Service.extend({
return this._api.method('payins_googlepay-direct_create_v2', callback, options);
},

/**
*
* @param metadata POST body which should contain the 'Type' and 'Bin' (if the type is BIN) or 'Token' (if the type is GOOGLE_PAY)
* @param callback Callback function
* @param options Request options
* @returns PaymentMethodMetadata
*/
getPaymentMethodMetadata: function(metadata, callback, options) {
options = this._api._getOptions(callback, options, {
data: metadata,
dataClass: PaymentMethodMetadata
});

return this._api.method('payment_method_metadata_get', callback, options);
},

getPaymentKey: function(payIn) {
if (payIn.PaymentType) {
return payIn.PaymentType.toLowerCase().replace('_', '');
Expand Down
28 changes: 28 additions & 0 deletions test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1495,6 +1495,34 @@ describe('PayIns', function () {
});
});

describe('Payment Method Metadata', function () {
var metadata;
var payIn;

before(function (done) {
helpers.getNewPayInCardDirect(api, john, function (createdPayIn) {
payIn = createdPayIn
var metadataPost = {
Type: "BIN",
Bin: payIn.CardInfo.BIN
}

api.PayIns.getPaymentMethodMetadata(metadataPost, function (data) {
metadata = data;
done();
});
});
});

describe('Fetch Metadata', function () {
it('should fetch the payment method metadata', function () {
expect(metadata.Type).to.equal('BIN')
expect(metadata.Bin).to.equal(payIn.CardInfo.BIN);
});
});

});

// describe('Card PreAuthorized Deposit', function () {
// var payIn;
//
Expand Down

0 comments on commit df0fd7f

Please sign in to comment.