Skip to content

Commit f8b19c9

Browse files
committed
BA-899 Add Twint payment method
1 parent f3c2d06 commit f8b19c9

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

example/transaction/twint.js

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import buckarooClient from '../buckarooClient';
2+
import { uniqid } from '../../src';
3+
4+
const twint = buckarooClient.method('twint');
5+
6+
//Pay
7+
twint
8+
.pay({
9+
currency: 'CHF',
10+
amountDebit: 10.1,
11+
invoice: uniqid(),
12+
description: 'Twint Payment',
13+
})
14+
.request();
15+
//Refund
16+
twint
17+
.refund({
18+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
19+
amountCredit: 10.1,
20+
invoice: uniqid(),
21+
description: 'Twint Refund',
22+
})
23+
.request();

example/transaction/twint.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import buckarooClient from '../buckarooClient';
2+
import { uniqid } from '../../src/Utils';
3+
4+
const twint = buckarooClient.method('twint');
5+
6+
//Pay
7+
twint
8+
.pay({
9+
currency: 'CHF',
10+
amountDebit: 10.1,
11+
invoice: uniqid(),
12+
description: 'Twint Payment',
13+
})
14+
.request();
15+
//Refund
16+
twint
17+
.refund({
18+
originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
19+
amountCredit: 10.1,
20+
invoice: uniqid(),
21+
description: 'Twint Refund',
22+
})
23+
.request();

src/PaymentMethods/Twint/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { PayablePaymentMethod } from '../../Services';
2+
import { ServiceCode } from '../../Utils';
3+
4+
export default class Twint extends PayablePaymentMethod {
5+
public defaultServiceCode(): ServiceCode {
6+
return 'twint';
7+
}
8+
}

src/PaymentMethods/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ export { default as surepay } from './Surepay';
8484
export { default as thunes } from './Thunes';
8585
export { default as alipay } from './Alipay';
8686
export { default as trustly } from './Trustly';
87+
export { default as twint } from './Twint';
8788
export { default as wechatpay } from './WeChatPay';
8889
export { default as In3 } from './In3';
8990
export { default as noservice } from './NoService';

tests/PaymentMethods/Twint.test.ts

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import buckarooClientTest from '../BuckarooClient.test';
2+
import { IRefundRequest, PaymentMethodInstance } from '../../src';
3+
import { createRefundPayload } from '../Payloads';
4+
5+
let method: PaymentMethodInstance<'twint'>;
6+
7+
beforeEach(() => {
8+
method = buckarooClientTest.method('twint');
9+
});
10+
11+
describe('testing methods', () => {
12+
test('Pay Simple Payload', async () => {
13+
const response = await method
14+
.pay({
15+
amountDebit: 100,
16+
currency: 'CHF',
17+
})
18+
.request();
19+
expect(response.isPendingProcessing()).toBeTruthy();
20+
});
21+
22+
test('Refund', async () => {
23+
const response = await method
24+
.refund(
25+
createRefundPayload<IRefundRequest>({
26+
originalTransactionKey: '1B649F2796AA466F8D8AE695XXXXXXXX',
27+
})
28+
)
29+
.request();
30+
expect(response.isSuccess()).toBeTruthy();
31+
});
32+
});

0 commit comments

Comments
 (0)