Skip to content

Commit

Permalink
Add Blik payment method
Browse files Browse the repository at this point in the history
  • Loading branch information
DjellzeBllaca committed May 3, 2024
1 parent 65f0390 commit 3a00788
Show file tree
Hide file tree
Showing 6 changed files with 113 additions and 0 deletions.
24 changes: 24 additions & 0 deletions example/transaction/blik.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import buckarooClient from '../buckarooClient';

const blik = buckarooClient.method('blik');

//Pay
blik
.pay({
currency: 'PLN',
amountDebit: 10.00,
invoice: 'Blik Test Plugins Example',
description: 'Blik Test Plugins Example',
email: 'test@buckaroo.nl',
})
.request();
//Refund
blik
.refund({
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
currency: 'PLN',
amountCredit: 5.00,
invoice: 'Refund Blik Test Plugins Example',
description: 'Refund Blik Test Plugins Example',
})
.request();
24 changes: 24 additions & 0 deletions example/transaction/blik.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import buckarooClient from '../buckarooClient';

const blik = buckarooClient.method('blik');

//Pay
blik
.pay({
currency: 'PLN',
amountDebit: 10.00,
invoice: 'Blik Test Plugins Example',
description: 'Blik Test Plugins Example',
email: 'test@buckaroo.nl',
})
.request();
//Refund
blik
.refund({
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
currency: 'PLN',
amountCredit: 5.00,
invoice: 'Refund Blik Test Plugins Example',
description: 'Refund Blik Test Plugins Example',
})
.request();
11 changes: 11 additions & 0 deletions src/PaymentMethods/Blik/Models/Pay.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { IPaymentRequest, ServiceParameter } from '../../../Models';

export interface IPay extends IPaymentRequest {
email?: string;
}

export class Pay extends ServiceParameter {
set email(value: string) {
this.set('email', value);
}
}
19 changes: 19 additions & 0 deletions src/PaymentMethods/Blik/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { PayablePaymentMethod } from '../../Services';
import { IRefundRequest } from '../../Models';
import { IPay, Pay } from './Models/Pay';
import { ServiceCode } from '../../Utils';

export default class Blik extends PayablePaymentMethod {

public defaultServiceCode(): ServiceCode {
return 'blik';
}

pay(payload: IPay) {
return super.pay(payload, new Pay(payload));
}

refund(payload: IRefundRequest) {
return super.refund(payload);
}
}
1 change: 1 addition & 0 deletions src/PaymentMethods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export { default as bancontactmrcash } from './Bancontact';
export { default as transfer } from './BankTransfer';
export { default as belfius } from './Belfius';
export { default as billink } from './Billink';
export { default as blik } from './Blik';
export { default as buckaroovoucher } from './BuckarooVoucher';
export { default as BuckarooWalletCollecting } from './BuckarooWallet';
export { default as CreditCard } from './CreditCard';
Expand Down
34 changes: 34 additions & 0 deletions tests/PaymentMethods/Blik.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import buckarooClientTest from '../BuckarooClient.test';

const blik = buckarooClientTest.method('blik');

describe('Testing Blik methods', () => {
test('Pay', async () => {
return blik
.pay({
currency: 'PLN',
amountDebit: 10.00,
invoice: 'Blik Test Plugin Example',
description: 'Blik Test Plugin Example',
email: 'test@buckaroo.nl',
})
.request()
.then((res) => {
expect(res.isPendingProcessing()).toBeTruthy();
});
});
test('Refund', async () => {
return blik
.refund({
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
currency: 'PLN',
amountCredit: 5.00,
invoice: 'Refund Blik Test Plugin Example',
description: 'Refund Blik Test Plugin Example',
})
.request()
.then((info) => {
expect(info.httpResponse.status).toEqual(200)
});
});
});

0 comments on commit 3a00788

Please sign in to comment.