Skip to content

Commit

Permalink
Merge pull request #386 from Mangopay/feature/implement_cardinfo
Browse files Browse the repository at this point in the history
feature / Added CardInfo to 4 endpoints
  • Loading branch information
silvianagh authored Dec 22, 2023
2 parents 7f2c4bf + 6465e03 commit 3f4a159
Show file tree
Hide file tree
Showing 11 changed files with 197 additions and 6 deletions.
32 changes: 32 additions & 0 deletions lib/models/CardInfo.js
Original file line number Diff line number Diff line change
@@ -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;
6 changes: 5 additions & 1 deletion lib/models/CardPreAuthorization.js
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,11 @@ var CardPreAuthorization = Model.extend({
/*
* Applied3DSVersion
*/
Applied3DSVersion: null
Applied3DSVersion: null,
/*
* Information about the card
*/
CardInfo: null
},

getSubObjects: function() {
Expand Down
3 changes: 2 additions & 1 deletion lib/models/Deposit.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ module.exports = EntityBase.extend({
Billing: null,
Shipping: null,
Requested3DSVersion: null,
Applied3DSVersion: null
Applied3DSVersion: null,
CardInfo: null
}
});
3 changes: 2 additions & 1 deletion lib/models/PayInPaymentDetailsCardDirect.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ var PayInPaymentDetailsCardDirect = PayInPaymentDetailsCard.extend({
CardId: null,
IpAddress: null,
Shipping: null,
BrowserInfo: null
BrowserInfo: null,
CardInfo: null
})
});

Expand Down
3 changes: 2 additions & 1 deletion test/services/CardPreAuthorizations.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
var expect = require('chai').expect;

var api = require('../main');
var helpers = require('../helpers');

describe('Card PreAuthorizations', function() {
Expand Down Expand Up @@ -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;
});
});

Expand Down
9 changes: 9 additions & 0 deletions test/services/Deposits.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
var _ = require('underscore');
var expect = require('chai').expect;
var helpers = require('../helpers');
var api = require('../main');

describe('Deposits', function () {

Expand All @@ -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 () {
Expand Down
92 changes: 91 additions & 1 deletion test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
});
});

Expand Down Expand Up @@ -728,6 +729,95 @@ describe('PayIns', function () {
})
})

describe('Create a Recurring Payment Check Card Info', 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){
Expand Down
36 changes: 35 additions & 1 deletion typings/models/card.d.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CurrencyISO } from "../types";
import { CountryISO, CurrencyISO } from "../types";
import { entityBase } from "./entityBase";

export namespace card {
Expand All @@ -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
Expand Down Expand Up @@ -70,4 +72,36 @@ export namespace card {
Id: string;
Active?: false;
}

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;
}
}
4 changes: 4 additions & 0 deletions typings/models/cardPreauthorization.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ import { base } from "../base";
import { money } from "./money";
import { securityInfo } from "./securityInfo";
import { shipping } from "./shipping";
import { card } from "./card";

export namespace cardPreAuthorization {
import BillingData = billing.BillingData;
import BrowserInfoData = base.BrowserInfoData;
import MoneyData = money.MoneyData;
import SecurityInfoData = securityInfo.SecurityInfoData;
import ShippingData = shipping.ShippingData;
import CardInfoData = card.CardInfoData;

type PreAuthorizationExecutionType = "DIRECT";

Expand Down Expand Up @@ -140,5 +142,7 @@ export namespace cardPreAuthorization {
* Contains every useful information's related to the user shipping
*/
Shipping: ShippingData;

CardInfo: CardInfoData;
}
}
4 changes: 4 additions & 0 deletions typings/models/deposit.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { payIn } from "./payIn";
import { base } from "../base";
import { billing } from "./billing";
import { shipping } from "./shipping";
import { card } from "./card";

export namespace deposit {
import MoneyData = money.MoneyData;
Expand All @@ -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<enums.IDepositStatus>;

Expand Down Expand Up @@ -64,6 +66,8 @@ export namespace deposit {
Requested3DSVersion: _3DSVersion;

Applied3DSVersion: _3DSVersion;

CardInfo: CardInfoData;
}

interface CreateDeposit {
Expand Down
11 changes: 11 additions & 0 deletions typings/models/payIn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";

Expand Down Expand Up @@ -310,6 +311,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 {
Expand Down Expand Up @@ -1269,6 +1275,11 @@ export namespace payIn {
Applied3DSVersion: _3DSVersion;

RecurringPayinRegistrationId: string;

/**
* Information about the card
*/
CardInfo: CardInfoData;
}

interface CreateRecurringPayInCIT {
Expand Down

0 comments on commit 3f4a159

Please sign in to comment.