Skip to content

Commit bbfe456

Browse files
Merge pull request #104 from buckaroo-it/BA-927-add-wero
BA-927 Add Wero payment method
2 parents 59b610d + bd86df5 commit bbfe456

5 files changed

Lines changed: 166 additions & 0 deletions

File tree

example/transaction/wero.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
import buckarooClient from '../buckarooClient';
2+
import { uniqid } from '../../src';
3+
4+
const wero = buckarooClient.method('Wero');
5+
6+
wero
7+
.pay({
8+
amountDebit: 100,
9+
invoice: uniqid(),
10+
description: 'Wero Payment',
11+
})
12+
.request();
13+
14+
wero
15+
.refund({
16+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
17+
amountCredit: 100,
18+
invoice: uniqid(),
19+
description: 'Wero Refund',
20+
}).request();
21+
22+
wero
23+
.authorize({
24+
invoice: uniqid(),
25+
description: 'Wero Authorize',
26+
amountDebit: 100,
27+
})
28+
.request();
29+
30+
wero
31+
.cancelAuthorize({
32+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
33+
amountCredit: 100,
34+
invoice: uniqid(),
35+
})
36+
.request();
37+
38+
wero
39+
.capture({
40+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
41+
amountDebit: 100,
42+
invoice: uniqid(),
43+
description: 'Wero Capture',
44+
})
45+
.request();

example/transaction/wero.ts

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
import buckarooClient from '../buckarooClient';
2+
import buckaroo, { uniqid } from '../../src';
3+
4+
const wero = buckarooClient.method('Wero');
5+
6+
wero.pay({
7+
amountDebit: 10,
8+
invoice: uniqid(),
9+
description: 'Wero Payment',
10+
}).request();
11+
12+
wero.refund({
13+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
14+
amountCredit: 10,
15+
invoice: uniqid(),
16+
description: 'Wero Refund',
17+
}).request();
18+
19+
wero.authorize({
20+
invoice: uniqid(),
21+
description: 'Wero Authorize',
22+
amountDebit: 100,
23+
}).request();
24+
25+
wero.cancelAuthorize({
26+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
27+
amountCredit: 100,
28+
invoice: uniqid(),
29+
}).request();
30+
31+
wero.capture({
32+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
33+
amountDebit: 100,
34+
invoice: uniqid(),
35+
description: 'Wero Capture',
36+
}).request();

src/PaymentMethods/Wero/index.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { IPaymentRequest, IRefundRequest, IRequest } from '../../Models';
2+
import { PayablePaymentMethod } from '../../Services';
3+
import { ServiceCode } from '../../Utils';
4+
5+
export default class Wero extends PayablePaymentMethod {
6+
public defaultServiceCode(): ServiceCode {
7+
return 'wero';
8+
}
9+
10+
authorize(payload: IPaymentRequest) {
11+
this.setPayPayload(payload);
12+
this.setServiceList('Authorize');
13+
return super.transactionRequest();
14+
}
15+
16+
cancelAuthorize(payload: IRefundRequest) {
17+
this.setServiceList('CancelAuthorize');
18+
return super.transactionRequest(payload);
19+
}
20+
21+
capture(payload: IRequest) {
22+
this.setPayPayload(payload);
23+
this.setServiceList('Capture');
24+
return super.transactionRequest();
25+
}
26+
}

src/PaymentMethods/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,3 +92,4 @@ export { default as In3 } from './In3';
9292
export { default as noservice } from './NoService';
9393
export { default as externalpayment } from './ExternalPayment';
9494
export { default as ClickToPay } from './ClickToPay';
95+
export { default as wero } from './Wero';

tests/PaymentMethods/Wero.test.ts

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import buckarooClientTest from '../BuckarooClient.test';
2+
import { PaymentMethodInstance, uniqid } from '../../src';
3+
4+
let method: PaymentMethodInstance<'wero'>;
5+
6+
beforeEach(() => {
7+
method = buckarooClientTest.method('wero');
8+
});
9+
10+
describe('Wero methods', () => {
11+
test('Pay', async () => {
12+
const response = await method
13+
.pay({
14+
amountDebit: 10,
15+
})
16+
.request();
17+
expect(response.isPendingProcessing()).toBeTruthy();
18+
});
19+
test('Refund', async () => {
20+
const response = await method
21+
.refund({
22+
amountCredit: 10,
23+
invoice: uniqid(),
24+
originalTransactionKey: 'C0D904513E2D40FC826C9C76XXXXXXXX',
25+
})
26+
.request();
27+
expect(response.isSuccess()).toBeTruthy();
28+
});
29+
test('Authorize', async () => {
30+
const response = await method
31+
.authorize({
32+
amountDebit: 10,
33+
invoice: uniqid(),
34+
})
35+
.request();
36+
expect(response.isPendingProcessing()).toBeTruthy();
37+
});
38+
test('CancelAuthorize', async () => {
39+
const response = await method
40+
.cancelAuthorize({
41+
originalTransactionKey: 'C0D904513E2D40FC826C9C76XXXXXXXX',
42+
amountCredit: 10
43+
})
44+
.request();
45+
expect(response.isSuccess()).toBeTruthy();
46+
});
47+
test('Capture', async () => {
48+
const response = await method
49+
.capture({
50+
originalTransactionKey: 'C0D904513E2D40FC826C9C76XXXXXXXX',
51+
amountDebit: 10,
52+
description: 'Test Capture Transaction',
53+
invoice: uniqid(),
54+
})
55+
.request();
56+
expect(response.isSuccess()).toBeTruthy();
57+
});
58+
});

0 commit comments

Comments
 (0)