Skip to content

Commit

Permalink
added Blik Web payin
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Sep 11, 2023
1 parent 08ccff7 commit 26678eb
Show file tree
Hide file tree
Showing 11 changed files with 163 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 @@ -48,6 +48,7 @@ module.exports = {
"payins_mbway-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/mbway", "POST"],
"payins_multibanco-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/multibanco", "POST"],
"payins_satispay-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/satispay", "POST"],
"payins_blik-web_create": ["/${apiVersion}/${clientId}/payins/payment-methods/blik", "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/PayInPaymentDetailsBlik.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
var _ = require('underscore');
var PayInPaymentDetails = require('./PayInPaymentDetails');

var PayInPaymentDetailsBlik = 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 = PayInPaymentDetailsBlik;
5 changes: 4 additions & 1 deletion lib/models/PayInPaymentType.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,8 @@ module.exports = {
ApplePay: 'APPLEPAY',
GooglePay: 'GOOGLEPAY',
Payconiq: 'PAYCONIQ',
Mbway: 'MBWAY'
Mbway: 'MBWAY',
Multibanco: 'MULTIBANCO',
Satispay: 'SATISPAY',
Blik: 'BLIK'
};
6 changes: 6 additions & 0 deletions lib/services/PayIns.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ var Refund = require('../models/Refund');
var PayInRecurringRegistration = require('../models/PayInRecurringRegistration');
var PayInPaymentDetailsPayconiq = require('../models/PayInPaymentDetailsPayconiq');
const RecurringPayIn = require('../models/RecurringPayIn');
const PayInPaymentDetailsMultibanco = require("../models/PayInPaymentDetailsMultibanco");
const PayInPaymentDetailsSatispay = require("../models/PayInPaymentDetailsSatispay");
const PayInPaymentDetailsBlik = require("../models/PayInPaymentDetailsBlik");

var PayIns = Service.extend({
/**
Expand Down Expand Up @@ -224,6 +227,9 @@ var PayIns = Service.extend({
if (payIn.PaymentDetails instanceof PayInPaymentDetailsGooglePay) return 'googlepay';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsPayconiq) return 'payconiq';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsMbway) return 'mbway';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsMultibanco) return 'multibanco';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsSatispay) return 'satispay';
if (payIn.PaymentDetails instanceof PayInPaymentDetailsBlik) return 'blik';

throw new Error('PayIn needs a PaymentType');
},
Expand Down
29 changes: 29 additions & 0 deletions 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 @@ -1085,6 +1085,46 @@ describe('PayIns', function () {
});
});

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

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

describe('Create', function () {
it('should create the PayIn', function () {
expect(payIn.Id).not.to.be.undefined;
expect(payIn.PaymentType).to.equal('BLIK');
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('BLIK');
expect(getPayIn.ExecutionType).to.equal('WEB');
expect(getPayIn.Phone).not.to.be.null;
});
});
});

// describe('Card PreAuthorized Deposit', function () {
// var payIn;
//
Expand Down
1 change: 1 addition & 0 deletions typings/enums.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export namespace enums {
Mbway: "MBWAY";
Multibanco: "MULTIBANCO";
Satispay: "SATISPAY";
Blik: "BLIK";
}

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 @@ -602,6 +602,19 @@ api.PayIns.create({
const d = data; // $ExpectType SatispayWebPayInData
});

api.PayIns.create({
PaymentType: "BLIK",
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 BlikWebPayInData
});

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 @@ -29,7 +29,8 @@ export namespace payIn {
| DirectDebitDirectPayInData
| MbwayWebPayInData
| MultibancoWebPayInData
| SatispayWebPayInData;
| SatispayWebPayInData
| BlikWebPayInData;

type PayInPaymentType = ValueOf<enums.IPayInPaymentType>;

Expand Down Expand Up @@ -378,6 +379,18 @@ export namespace payIn {
Country: CountryISO;
}

interface BlikWebPayInData extends BasePayInData {
ExecutionType: "WEB";

PaymentType: "BLIK";

/**
* 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 @@ -640,6 +653,43 @@ export namespace payIn {
Tag?: string;
}

interface CreateBlikWebPayIn {
ExecutionType: "WEB";

PaymentType: "BLIK";

/**
* 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 @@ -20,7 +20,8 @@ export class PayIns {
MethodOverload<payIn.CreateDirectDebitWebPayIn, payIn.DirectDebitWebPayInData> &
MethodOverload<payIn.CreateMbwayWebPayIn, payIn.MbwayWebPayInData> &
MethodOverload<payIn.CreateMultibancoWebPayIn, payIn.MultibancoWebPayInData> &
MethodOverload<payIn.CreateSatispayWebPayIn, payIn.SatispayWebPayInData>;
MethodOverload<payIn.CreateSatispayWebPayIn, payIn.SatispayWebPayInData> &
MethodOverload<payIn.CreateBlikWebPayIn, payIn.BlikWebPayInData>;

/**
* 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 @@ -162,7 +162,8 @@ export type ApiMethod =
| "payins_mbway-web_create"
| "payins_paypal-web_create_v2"
| "payins_multibanco-web_create"
| "payins_satispay-web_create";
| "payins_satispay-web_create"
| "payins_blik-web_create";

export type CountryISO =
| "AD"
Expand Down

0 comments on commit 26678eb

Please sign in to comment.