diff --git a/example/transaction/swish.js b/example/transaction/swish.js new file mode 100644 index 0000000..2451499 --- /dev/null +++ b/example/transaction/swish.js @@ -0,0 +1,24 @@ +import buckarooClient from '../buckarooClient'; +import { uniqid } from '../../src'; + +const swish = buckarooClient.method('swish'); + +//Pay +swish + .pay({ + currency: 'SEK', + amountDebit: 10.0, + invoice: uniqid(), + description: 'Swish Payment', + }) + .request(); +//Refund +swish + .refund({ + originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + currency: 'SEK', + amountCredit: 10.0, + invoice: uniqid(), + description: 'Swish Refund', + }) + .request(); diff --git a/example/transaction/swish.ts b/example/transaction/swish.ts new file mode 100644 index 0000000..fa3a19d --- /dev/null +++ b/example/transaction/swish.ts @@ -0,0 +1,22 @@ +import buckarooClient from '../buckarooClient'; +import { uniqid } from '../../src/Utils'; + +const bizum = buckarooClient.method('bizum'); + +//Pay +bizum + .pay({ + amountDebit: 10.1, + invoice: uniqid(), + description: 'Bizum Payment', + }) + .request(); +//Refund +bizum + .refund({ + originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', + amountCredit: 10.1, + invoice: uniqid(), + description: 'Bizum Refund', + }) + .request(); diff --git a/src/PaymentMethods/Swish/index.ts b/src/PaymentMethods/Swish/index.ts new file mode 100644 index 0000000..afb8379 --- /dev/null +++ b/src/PaymentMethods/Swish/index.ts @@ -0,0 +1,8 @@ +import { PayablePaymentMethod } from '../../Services'; +import { ServiceCode } from '../../Utils'; + +export default class Swish extends PayablePaymentMethod { + public defaultServiceCode(): ServiceCode { + return 'swish'; + } +} diff --git a/src/PaymentMethods/index.ts b/src/PaymentMethods/index.ts index 85d2251..998cdef 100644 --- a/src/PaymentMethods/index.ts +++ b/src/PaymentMethods/index.ts @@ -81,6 +81,7 @@ export { default as przelewy24 } from './Przelewy24'; export { default as sepadirectdebit } from './SEPA'; export { default as subscriptions } from './Subscriptions'; export { default as surepay } from './Surepay'; +export { default as swish } from './Swish'; export { default as thunes } from './Thunes'; export { default as alipay } from './Alipay'; export { default as trustly } from './Trustly'; diff --git a/tests/PaymentMethods/Swish.test.ts b/tests/PaymentMethods/Swish.test.ts new file mode 100644 index 0000000..2df7dc8 --- /dev/null +++ b/tests/PaymentMethods/Swish.test.ts @@ -0,0 +1,32 @@ +import { IRefundRequest, PaymentMethodInstance } from '../../src'; +import buckarooClientTest from '../BuckarooClient.test'; +import { createRefundPayload } from '../Payloads'; + +let method: PaymentMethodInstance<'swish'>; + +beforeEach(() => { + method = buckarooClientTest.method('swish'); +}); + +describe('Swish methods', () => { + test('Pay', async () => { + const response = await method + .pay({ + currency: 'SEK', + amountDebit: 10, + }) + .request(); + expect(response.isPendingProcessing()).toBeTruthy(); + }); + test.only('Refund', async () => { + const response = await method + .refund( + createRefundPayload({ + currency: 'SEK', + originalTransactionKey: '571519D5237B40D884B6D95245ED953B', + }) + ) + .request(); + expect(response.isSuccess()).toBeTruthy(); + }); +});