Skip to content

Commit

Permalink
added Multibanco Web payin
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Sep 11, 2023
1 parent 3b53f7b commit c6bc433
Show file tree
Hide file tree
Showing 9 changed files with 154 additions and 4 deletions.
1 change: 1 addition & 0 deletions lib/apiMethods.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ module.exports = {
"payins_payconiq-web_create": ["/${apiVersion}/${clientId}/payins/payconiq/web", "POST"],
"payins_create_card_pre_authorized_deposit": ["/${apiVersion}/${clientId}/payins/deposit-preauthorized/direct/full-capture", "POST"],
"payins_mbway-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/mbway", "POST"],
"payins_multibanco-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/multibanco", "POST"],

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

var PayInPaymentDetailsMultibanco = PayInPaymentDetails.extend({
defaults: {
/**
* Custom description to show on the user's bank statement.
* It can be up to 10 char alpha-numeric and space.
*/
StatementDescriptor: null
}
});

module.exports = PayInPaymentDetailsMultibanco;
31 changes: 30 additions & 1 deletion test/helpers.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 40 additions & 0 deletions test/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1003,6 +1003,46 @@ describe('PayIns', function () {
expect(getPayIn.ExecutionType).to.equal('WEB');
});
});
})

describe('Multibanco Web', function () {
var payIn;

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

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

describe('Get', function () {
var getPayIn;
before(function (done) {
api.PayIns.get(payIn.Id, function (data, response) {
getPayIn = data;
done()
});
});

it('should get the PayIn', function () {
expect(getPayIn.Id).to.equal(payIn.Id);
expect(getPayIn.PaymentType).to.equal('MULTIBANCO');
expect(getPayIn.ExecutionType).to.equal('WEB');
expect(getPayIn.Phone).not.to.be.null;
});
});
});

// describe('Card PreAuthorized Deposit', function () {
Expand Down
1 change: 1 addition & 0 deletions typings/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export namespace enums {
PayPal: "PAYPAL";
Payconiq: "PAYCONIQ";
Mbway: "MBWAY";
Multibanco: "MULTIBANCO";
}

interface IMandateStatus {
Expand Down
13 changes: 13 additions & 0 deletions typings/mangopay2-nodejs-sdk-tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -575,6 +575,19 @@ api.PayIns.create({
const d = data; // $ExpectType MbwayWebPayInData
});

api.PayIns.create({
PaymentType: "MULTIBANCO",
ExecutionType: "WEB",
AuthorId: "user-id",
Fees: {Amount: 100, Currency: "GBP"},
DebitedFunds: {Amount: 2000, Currency: "GBP"},
ReturnURL: "http://test.com",
Tag: "test tag",
StatementDescriptor: "test"
}).then(data => {
const d = data; // $ExpectType MultibancoWebPayInData
});

api.PayIns.create({
PaymentType: "CARD",
ExecutionType: "WEB",
Expand Down
52 changes: 51 additions & 1 deletion typings/models/payIn.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export namespace payIn {
| BankWireDirectPayInData
| PayconiqWebPayInData
| DirectDebitDirectPayInData
| MbwayWebPayInData;
| MbwayWebPayInData
| MultibancoWebPayInData;

type PayInPaymentType = ValueOf<enums.IPayInPaymentType>;

Expand Down Expand Up @@ -347,6 +348,18 @@ export namespace payIn {
Culture: CountryISO;
}

interface MultibancoWebPayInData extends BasePayInData {
ExecutionType: "WEB";

PaymentType: "MULTIBANCO";

/**
* A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric
* characters or spaces. See here for important info. Note that each bank handles this information differently, some show less or no information.
*/
StatementDescriptor: string;
}

interface CreateCardDirectPayIn {
ExecutionType: "DIRECT";

Expand Down Expand Up @@ -530,6 +543,43 @@ export namespace payIn {
Culture?: CountryISO;
}

interface CreateMultibancoWebPayIn {
ExecutionType: "WEB";

PaymentType: "MULTIBANCO";

/**
* A user's ID
*/
AuthorId: string;

/**
* Information about the funds that are being debited
*/
DebitedFunds: MoneyData;

/**
* Information about the fees that were taken by the client for this transaction (and were hence transferred to the Client's platform wallet)
*/
Fees: MoneyData;

/**
* The URL to redirect to after the payment, whether the transaction
*/
ReturnURL: string;

/**
* A custom description to appear on the user's bank statement. It can be up to 10 characters long, and can only include alphanumeric characters or spaces.
* See here for important info. Note that each bank handles this information differently, some show less or no information.
*/
StatementDescriptor?: string;

/**
* Custom data that you can add to this item
*/
Tag?: string;
}

interface LineItemData {
/**
* Item name
Expand Down
3 changes: 2 additions & 1 deletion typings/services/PayIns.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ export class PayIns {
MethodOverload<payIn.CreatePayconiqWebPayInData, payIn.PayconiqWebPayInData> &
MethodOverload<payIn.CreateDirectDebitDirectPayIn, payIn.DirectDebitDirectPayInData> &
MethodOverload<payIn.CreateDirectDebitWebPayIn, payIn.DirectDebitWebPayInData> &
MethodOverload<payIn.CreateMbwayWebPayIn, payIn.MbwayWebPayInData>;
MethodOverload<payIn.CreateMbwayWebPayIn, payIn.MbwayWebPayInData> &
MethodOverload<payIn.CreateMultibancoWebPayIn, payIn.MultibancoWebPayInData>;

/**
* Get pay-in
Expand Down
3 changes: 2 additions & 1 deletion typings/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,8 @@ export type ApiMethod =
| "transactions_get_for_bank_account"
| "idempotency_response_get"
| "payins_mbway-web_create"
| "payins_paypal-web_create_v2";
| "payins_paypal-web_create_v2"
| "payins_multibanco-web_create";

export type CountryISO =
| "AD"
Expand Down

0 comments on commit c6bc433

Please sign in to comment.