Skip to content

Commit

Permalink
Merge pull request #382 from Mangopay/feature/add_parameter_to_ideal_…
Browse files Browse the repository at this point in the history
…endpoint

improvement / Added new parameters to legacy IDEAL endpoint
  • Loading branch information
iulian03 authored Dec 6, 2023
2 parents e4e0c3b + 2d59795 commit 32852a2
Show file tree
Hide file tree
Showing 5 changed files with 97 additions and 2 deletions.
12 changes: 11 additions & 1 deletion lib/models/PayInPaymentDetailsCardWeb.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,17 @@ var PayInPaymentDetailsCardWeb = PayInPaymentDetailsCard.extend({
/*
* Shipping
*/
Shipping: null
Shipping: null,

/**
* The BIC identifier of the end-user’s bank
*/
Bic: null,

/**
* Name of the end-user’s bank
*/
BankName: null,
})
});

Expand Down
38 changes: 37 additions & 1 deletion test/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -954,5 +954,41 @@ module.exports = {
};
api.PayIns.create(payIn, callback);
});
}
},

getLegacyPayInIdealCardWeb: function(api, user, callback) {
var wallet = {
Owners: [user.Id],
Currency: 'EUR',
Description: 'WALLET IN EUR'
};

api.Wallets.create(wallet).then(function(){
var payIn = new api.models.PayIn({
CreditedWalletId: wallet.Id,
AuthorId: user.Id,
DebitedFunds: new api.models.Money({
Amount: 1000,
Currency: 'EUR'
}),
Fees: new api.models.Money({
Amount: 0,
Currency: 'EUR'
}),
PaymentType: 'CARD',
PaymentDetails: new api.models.PayInPaymentDetailsCard({
CardType: 'IDEAL',
Bic: 'REVOLT21'
}),
ExecutionType: 'WEB',
ExecutionDetails: new api.models.PayInPaymentDetailsCard({
ReturnURL: 'https://test.com',
TemplateURL: 'https://TemplateURL.com',
SecureMode: 'DEFAULT',
Culture: 'fr'
})
});
api.PayIns.create(payIn, callback);
});
},
};
24 changes: 24 additions & 0 deletions test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1259,6 +1259,30 @@ describe('PayIns', function () {
});
});

describe('Ideal Legacy Web', function () {
var payIn;

before(function (done) {
helpers.getLegacyPayInIdealCardWeb(api, john, function (data) {
payIn = data;
done();
});
});

describe('Create', function () {
it('should create the legacy PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.BankName).not.to.be.null;
expect(payIn.CardType).to.equal('IDEAL');
expect(payIn.PaymentType).to.equal('CARD');
expect(payIn.ExecutionType).to.equal('WEB');
expect(payIn.AuthorId).to.equal(john.Id);
expect(payIn.Type).to.equal('PAYIN');
expect(payIn.Phone).not.to.be.null;
});
});
});

// skip because we cannot generate new paymentData in the tests
describe.skip('GooglePay V2', function () {
var googlePayIn, wallet;
Expand Down
15 changes: 15 additions & 0 deletions typings/mangopay2-nodejs-sdk-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -703,6 +703,21 @@ api.PayIns.create({
const d = data; // $ExpectType GiropayWebPayInData
});

api.PayIns.create({
PaymentType: "CARD",
ExecutionType: "WEB",
AuthorId: "user-id",
CreditedWalletId: "wallet-id",
Fees: {Amount: 100, Currency: "GBP"},
DebitedFunds: {Amount: 2000, Currency: "GBP"},
ReturnURL: "https://secure-return.co",
Culture: "FR",
Bic: "RBRBNL21",
CardType: "IDEAL"
}).then(data => {
const d = data; // $ExpectType CardWebPayInData
});

api.PayIns.create({
PaymentType: "CARD",
ExecutionType: "WEB",
Expand Down
10 changes: 10 additions & 0 deletions typings/models/payIn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,11 @@ export namespace payIn {
* The URL to redirect to user to for them to proceed with the payment
*/
RedirectURL: string;

/**
* Name of the end-user’s bank
*/
BankName: string;
}

interface CreateCardWebPayIn {
Expand Down Expand Up @@ -252,6 +257,11 @@ export namespace payIn {
* Contains every useful information's related to the user shipping
*/
Shipping?: ShippingData;

/**
* The BIC identifier of the end-user’s bank
*/
Bic?: string;
}

interface CardDirectPayInData extends BasePayInData {
Expand Down

0 comments on commit 32852a2

Please sign in to comment.