From e6475f0ae9365fb81c64f9a844703792fe2b05c6 Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Thu, 21 Dec 2023 12:29:38 +0200 Subject: [PATCH 1/3] Added CardInfo to 4 endpoints --- lib/models/CardInfo.js | 32 +++++++++ lib/models/CardPreAuthorization.js | 6 +- lib/models/Deposit.js | 3 +- lib/models/PayIn.js | 6 +- test/services/PayIns.js | 89 ++++++++++++++++++++++++ typings/models/card.d.ts | 15 +++- typings/models/cardPreauthorization.d.ts | 4 ++ typings/models/deposit.d.ts | 4 ++ typings/models/payIn.d.ts | 6 ++ 9 files changed, 160 insertions(+), 5 deletions(-) create mode 100644 lib/models/CardInfo.js diff --git a/lib/models/CardInfo.js b/lib/models/CardInfo.js new file mode 100644 index 0000000..97071f3 --- /dev/null +++ b/lib/models/CardInfo.js @@ -0,0 +1,32 @@ +var EntityBase = require('./EntityBase'); + +var CardInfo = EntityBase.extend({ + defaults: { + /** + * The 6-digit bank identification number (BIN) of the card issuer. + */ + BIN: null, + /** + * The name of the card issuer. + */ + IssuingBank: null, + /** + * TThe country where the card was issued. + */ + IssuerCountryCode: null, + /** + * The type of card product: DEBIT, CREDIT, CHARGE CARD. + */ + Type: null, + /** + * The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc. + */ + Brand: null, + /** + * The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc. + */ + SubType: null + } +}); + +module.exports = CardInfo; \ No newline at end of file diff --git a/lib/models/CardPreAuthorization.js b/lib/models/CardPreAuthorization.js index be93226..b3e7de4 100644 --- a/lib/models/CardPreAuthorization.js +++ b/lib/models/CardPreAuthorization.js @@ -116,7 +116,11 @@ var CardPreAuthorization = Model.extend({ /* * Applied3DSVersion */ - Applied3DSVersion: null + Applied3DSVersion: null, + /* + * Information about the card + */ + CardInfo: null }, getSubObjects: function() { diff --git a/lib/models/Deposit.js b/lib/models/Deposit.js index 00dfa08..c3bba82 100644 --- a/lib/models/Deposit.js +++ b/lib/models/Deposit.js @@ -23,6 +23,7 @@ module.exports = EntityBase.extend({ Billing: null, Shipping: null, Requested3DSVersion: null, - Applied3DSVersion: null + Applied3DSVersion: null, + CardInfo: null } }); diff --git a/lib/models/PayIn.js b/lib/models/PayIn.js index fb8f521..8ffcc49 100644 --- a/lib/models/PayIn.js +++ b/lib/models/PayIn.js @@ -19,7 +19,11 @@ var PayIn = Transaction.extend({ /** * One of PayInExecutionDetails implementations, depending on ExecutionType */ - ExecutionDetails: null + ExecutionDetails: null, + /** + * Information about the card + */ + CardInfo: null }), getReadOnlyProperties: function() { diff --git a/test/services/PayIns.js b/test/services/PayIns.js index 4341edb..745fe8f 100644 --- a/test/services/PayIns.js +++ b/test/services/PayIns.js @@ -728,6 +728,95 @@ describe('PayIns', function () { }) }) + describe('Create a Recurring Payment Check Card Data', function() { + var recurring; + before(function(done){ + recurringPayin = { + AuthorId: john.Id, + CardId: cardId, + CreditedUserId: john.Id, + CreditedWalletId: walletId, + FirstTransactionDebitedFunds: { + Amount: 10, + Currency: 'EUR' + }, + FirstTransactionFees: { + Amount: 1, + Currency: 'EUR' + }, + Billing: { + FirstName: 'Joe', + LastName: 'Blogs', + Address: { + AddressLine1: '1 MangoPay Street', + AddressLine2: 'The Loop', + City: 'Paris', + Region: 'Ile de France', + PostalCode: '75001', + Country: 'FR' + } + }, + Shipping: { + FirstName: 'Joe', + LastName: 'Blogs', + Address: { + AddressLine1: '1 MangoPay Street', + AddressLine2: 'The Loop', + City: 'Paris', + Region: 'Ile de France', + PostalCode: '75001', + Country: 'FR' + } + }, + FreeCycles: 0 + }; + + api.PayIns.createRecurringPayment(recurringPayin, function(data, response){ + recurring = data; + }).then(function(){ + cit = { + RecurringPayinRegistrationId: recurring.Id, + BrowserInfo: { + AcceptHeader: "text/html, application/xhtml+xml, application/xml;q=0.9, /;q=0.8", + JavaEnabled: true, + Language: "FR-FR", + ColorDepth: 4, + ScreenHeight: 1800, + ScreenWidth: 400, + JavascriptEnabled: true, + TimeZoneOffset: "+60", + UserAgent: "Mozilla/5.0 (iPhone; CPU iPhone OS 13_6_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" + }, + IpAddress: "2001:0620:0000:0000:0211:24FF:FE80:C12C", + SecureModeReturnURL: "http://www.my-site.com/returnurl", + StatementDescriptor: "lorem", + Tag: "custom meta", + DebitedFunds: { + Amount: 10, + Currency: 'EUR' + }, + Fees: { + Amount: 1, + Currency: 'EUR' + }, + }; + + api.PayIns.createRecurringPayInRegistrationCIT(cit, function(data, response){ + createCit = data; + done(); + }); + }); + }); + + it('should be created', function() { + expect(createCit.CardInfo).to.not.be.null; + expect(createCit.CardInfo.Type).to.not.be.null; + expect(createCit.CardInfo.Brand).to.not.be.null; + expect(createCit.CardInfo.IssuingBank).to.not.be.null; + expect(createCit.CardInfo.BIN).to.not.be.null; + }); + }); + describe('Get Recurring Payment', function () { var recurring; before(function(done){ diff --git a/typings/models/card.d.ts b/typings/models/card.d.ts index 7f95bf6..68e928f 100644 --- a/typings/models/card.d.ts +++ b/typings/models/card.d.ts @@ -1,5 +1,5 @@ -import { CurrencyISO } from "../types"; -import { entityBase } from "./entityBase"; +import {CountryISO, CurrencyISO} from "../types"; +import {entityBase} from "./entityBase"; export namespace card { type CardType = "CB_VISA_MASTERCARD" | "DINERS" | "MASTERPASS" | "MAESTRO" | "P24" | "IDEAL" | "BCMC" | "PAYLIB"; @@ -8,6 +8,8 @@ export namespace card { type CardValidity = "UNKNOWN" | "VALID" | "INVALID"; + type CardInfoType = "DEBIT" | "CREDIT" | "CHARGE CARD"; + interface CardData extends entityBase.EntityBaseData { /** * The expiry date of the card - must be in format MMYY @@ -70,4 +72,13 @@ export namespace card { Id: string; Active?: false; } + + interface CardInfoData { + BIN: string; + IssuingBank: string; + IssuerCountryCode: CountryISO; + Type: CardInfoType; + Brand: string; + SubType: string; + } } diff --git a/typings/models/cardPreauthorization.d.ts b/typings/models/cardPreauthorization.d.ts index dc142c6..988d0e0 100644 --- a/typings/models/cardPreauthorization.d.ts +++ b/typings/models/cardPreauthorization.d.ts @@ -5,6 +5,7 @@ import { base } from "../base"; import { money } from "./money"; import { securityInfo } from "./securityInfo"; import { shipping } from "./shipping"; +import { card } from "mangopay2-nodejs-sdk"; export namespace cardPreAuthorization { import BillingData = billing.BillingData; @@ -12,6 +13,7 @@ export namespace cardPreAuthorization { import MoneyData = money.MoneyData; import SecurityInfoData = securityInfo.SecurityInfoData; import ShippingData = shipping.ShippingData; + import CardInfoData = card.CardInfoData; type PreAuthorizationExecutionType = "DIRECT"; @@ -140,5 +142,7 @@ export namespace cardPreAuthorization { * Contains every useful information's related to the user shipping */ Shipping: ShippingData; + + CardInfo: CardInfoData; } } diff --git a/typings/models/deposit.d.ts b/typings/models/deposit.d.ts index cb289d2..0c40610 100644 --- a/typings/models/deposit.d.ts +++ b/typings/models/deposit.d.ts @@ -6,6 +6,7 @@ import { payIn } from "./payIn"; import { base } from "../base"; import { billing } from "./billing"; import { shipping } from "./shipping"; +import { card } from "mangopay2-nodejs-sdk"; export namespace deposit { import MoneyData = money.MoneyData; @@ -15,6 +16,7 @@ export namespace deposit { import ShippingData = shipping.ShippingData; import CompleteBillingData = billing.CompleteBillingData; import _3DSVersion = payIn._3DSVersion; + import CardInfoData = card.CardInfoData; type DepositStatus = ValueOf; @@ -64,6 +66,8 @@ export namespace deposit { Requested3DSVersion: _3DSVersion; Applied3DSVersion: _3DSVersion; + + CardInfo: CardInfoData; } interface CreateDeposit { diff --git a/typings/models/payIn.d.ts b/typings/models/payIn.d.ts index 22dafdb..73dbd30 100644 --- a/typings/models/payIn.d.ts +++ b/typings/models/payIn.d.ts @@ -18,6 +18,7 @@ export namespace payIn { import ShippingData = shipping.ShippingData; import CreateShipping = shipping.CreateShipping; import CreateBilling = billing.CreateBilling; + import CardInfoData = card.CardInfoData; type _3DSVersion = "V1" | "V2_1"; @@ -134,6 +135,11 @@ export namespace payIn { * The type of execution for the payin */ ExecutionType: PayInExecutionType; + + /** + * Information about the card + */ + CardInfo: CardInfoData; } interface CardWebPayInData extends BasePayInData { From 7bd216ef5eb5968917606a6a9b368c68ddbde0fd Mon Sep 17 00:00:00 2001 From: Silviana Ghita Date: Thu, 21 Dec 2023 13:57:04 +0200 Subject: [PATCH 2/3] Added test for Deposit CardInfo --- test/services/Deposits.js | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/test/services/Deposits.js b/test/services/Deposits.js index 5d83a3a..62d21d6 100644 --- a/test/services/Deposits.js +++ b/test/services/Deposits.js @@ -1,6 +1,7 @@ var _ = require('underscore'); var expect = require('chai').expect; var helpers = require('../helpers'); +var api = require('../main'); describe('Deposits', function () { @@ -17,6 +18,14 @@ describe('Deposits', function () { it('should be created', function () { expect(deposit).not.to.be.undefined; }); + + it('check card info', function () { + expect(deposit.CardInfo).not.to.be.undefined; + expect(deposit.CardInfo.Type).not.to.be.undefined; + expect(deposit.CardInfo.Brand).not.to.be.undefined; + expect(deposit.CardInfo.IssuerCountryCode).not.to.be.undefined; + expect(deposit.CardInfo.BIN).not.to.be.undefined; + }); }); describe('Get', function () { From 6465e03c85bfa125ad86cbcab5fa102b1feb3943 Mon Sep 17 00:00:00 2001 From: Iulian Masar Date: Fri, 22 Dec 2023 15:08:04 +0200 Subject: [PATCH 3/3] small changes --- lib/models/PayIn.js | 6 +---- lib/models/PayInPaymentDetailsCardDirect.js | 3 ++- test/services/CardPreAuthorizations.js | 3 ++- test/services/PayIns.js | 5 ++-- typings/models/card.d.ts | 27 +++++++++++++++++++-- typings/models/cardPreauthorization.d.ts | 2 +- typings/models/deposit.d.ts | 2 +- typings/models/payIn.d.ts | 15 ++++++++---- 8 files changed, 45 insertions(+), 18 deletions(-) diff --git a/lib/models/PayIn.js b/lib/models/PayIn.js index 8ffcc49..fb8f521 100644 --- a/lib/models/PayIn.js +++ b/lib/models/PayIn.js @@ -19,11 +19,7 @@ var PayIn = Transaction.extend({ /** * One of PayInExecutionDetails implementations, depending on ExecutionType */ - ExecutionDetails: null, - /** - * Information about the card - */ - CardInfo: null + ExecutionDetails: null }), getReadOnlyProperties: function() { diff --git a/lib/models/PayInPaymentDetailsCardDirect.js b/lib/models/PayInPaymentDetailsCardDirect.js index 389e80e..22e18a3 100644 --- a/lib/models/PayInPaymentDetailsCardDirect.js +++ b/lib/models/PayInPaymentDetailsCardDirect.js @@ -6,7 +6,8 @@ var PayInPaymentDetailsCardDirect = PayInPaymentDetailsCard.extend({ CardId: null, IpAddress: null, Shipping: null, - BrowserInfo: null + BrowserInfo: null, + CardInfo: null }) }); diff --git a/test/services/CardPreAuthorizations.js b/test/services/CardPreAuthorizations.js index 6740388..1d6d23e 100644 --- a/test/services/CardPreAuthorizations.js +++ b/test/services/CardPreAuthorizations.js @@ -1,5 +1,5 @@ var expect = require('chai').expect; - +var api = require('../main'); var helpers = require('../helpers'); describe('Card PreAuthorizations', function() { @@ -27,6 +27,7 @@ describe('Card PreAuthorizations', function() { expect(preAuthorization.ExecutionType).to.equal('DIRECT'); expect(preAuthorization.PayInId).to.be.null; expect(preAuthorization.RemainingFunds).to.exist; + expect(preAuthorization.CardInfo).to.not.be.null; }); }); diff --git a/test/services/PayIns.js b/test/services/PayIns.js index 745fe8f..ab8598e 100644 --- a/test/services/PayIns.js +++ b/test/services/PayIns.js @@ -74,7 +74,8 @@ describe('PayIns', function () { expect(payIn.AuthorId).to.equal(john.Id); expect(payIn.Status).to.equal('SUCCEEDED'); expect(payIn.Type).to.equal('PAYIN'); - expect(payIn.SecurityInfo.AVSResult).to.equal('NO_CHECK') + expect(payIn.SecurityInfo.AVSResult).to.equal('NO_CHECK'); + expect(payIn.CardInfo).not.to.be.undefined; }); }); @@ -728,7 +729,7 @@ describe('PayIns', function () { }) }) - describe('Create a Recurring Payment Check Card Data', function() { + describe('Create a Recurring Payment Check Card Info', function() { var recurring; before(function(done){ recurringPayin = { diff --git a/typings/models/card.d.ts b/typings/models/card.d.ts index 68e928f..b5c65b6 100644 --- a/typings/models/card.d.ts +++ b/typings/models/card.d.ts @@ -1,5 +1,5 @@ -import {CountryISO, CurrencyISO} from "../types"; -import {entityBase} from "./entityBase"; +import { CountryISO, CurrencyISO } from "../types"; +import { entityBase } from "./entityBase"; export namespace card { type CardType = "CB_VISA_MASTERCARD" | "DINERS" | "MASTERPASS" | "MAESTRO" | "P24" | "IDEAL" | "BCMC" | "PAYLIB"; @@ -74,11 +74,34 @@ export namespace card { } interface CardInfoData { + /** + * The 6-digit bank identification number (BIN) of the card issuer. + */ BIN: string; + + /** + * The name of the card issuer. + */ IssuingBank: string; + + /** + * The country where the card was issued. + */ IssuerCountryCode: CountryISO; + + /** + * The type of card product: DEBIT, CREDIT, CHARGE CARD. + */ Type: CardInfoType; + + /** + * The card brand. Examples include: AMERICAN EXPRESS, DISCOVER, JCB, MASTERCARD, VISA, etc. + */ Brand: string; + + /** + * The subtype of the card product. Examples include: CLASSIC, GOLD, PLATINUM, PREPAID, etc. + */ SubType: string; } } diff --git a/typings/models/cardPreauthorization.d.ts b/typings/models/cardPreauthorization.d.ts index 988d0e0..3f7181c 100644 --- a/typings/models/cardPreauthorization.d.ts +++ b/typings/models/cardPreauthorization.d.ts @@ -5,7 +5,7 @@ import { base } from "../base"; import { money } from "./money"; import { securityInfo } from "./securityInfo"; import { shipping } from "./shipping"; -import { card } from "mangopay2-nodejs-sdk"; +import { card } from "./card"; export namespace cardPreAuthorization { import BillingData = billing.BillingData; diff --git a/typings/models/deposit.d.ts b/typings/models/deposit.d.ts index 0c40610..22c271f 100644 --- a/typings/models/deposit.d.ts +++ b/typings/models/deposit.d.ts @@ -6,7 +6,7 @@ import { payIn } from "./payIn"; import { base } from "../base"; import { billing } from "./billing"; import { shipping } from "./shipping"; -import { card } from "mangopay2-nodejs-sdk"; +import { card } from "./card"; export namespace deposit { import MoneyData = money.MoneyData; diff --git a/typings/models/payIn.d.ts b/typings/models/payIn.d.ts index 73dbd30..28a8cc5 100644 --- a/typings/models/payIn.d.ts +++ b/typings/models/payIn.d.ts @@ -135,11 +135,6 @@ export namespace payIn { * The type of execution for the payin */ ExecutionType: PayInExecutionType; - - /** - * Information about the card - */ - CardInfo: CardInfoData; } interface CardWebPayInData extends BasePayInData { @@ -306,6 +301,11 @@ export namespace payIn { * This is the URL where to redirect users to proceed to 3D secure validation */ SecureModeRedirectURL: string; + + /** + * Information about the card + */ + CardInfo: CardInfoData; } interface MbwayWebPayInData extends BasePayInData { @@ -1265,6 +1265,11 @@ export namespace payIn { Applied3DSVersion: _3DSVersion; RecurringPayinRegistrationId: string; + + /** + * Information about the card + */ + CardInfo: CardInfoData; } interface CreateRecurringPayInCIT {