Skip to content

Commit 59b610d

Browse files
Merge pull request #103 from buckaroo-it/BA-918-add-swish
BA-918 Add Swish payment method
2 parents 21f7940 + 74e16cb commit 59b610d

5 files changed

Lines changed: 87 additions & 0 deletions

File tree

example/transaction/swish.js

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

example/transaction/swish.ts

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

src/PaymentMethods/Swish/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 Swish extends PayablePaymentMethod {
5+
public defaultServiceCode(): ServiceCode {
6+
return 'swish';
7+
}
8+
}

src/PaymentMethods/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,7 @@ export { default as przelewy24 } from './Przelewy24';
8282
export { default as sepadirectdebit } from './SEPA';
8383
export { default as subscriptions } from './Subscriptions';
8484
export { default as surepay } from './Surepay';
85+
export { default as swish } from './Swish';
8586
export { default as thunes } from './Thunes';
8687
export { default as alipay } from './Alipay';
8788
export { default as trustly } from './Trustly';

tests/PaymentMethods/Swish.test.ts

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

0 commit comments

Comments
 (0)