diff --git a/.babelrc b/.babelrc new file mode 100644 index 00000000..8848b6b7 --- /dev/null +++ b/.babelrc @@ -0,0 +1,16 @@ +{ + "plugins": [ + "@babel/plugin-proposal-class-properties" + ], + "presets": [ + "@babel/preset-typescript", + [ + "@babel/preset-env", + { + "targets": { + "node": "6.9" + } + } + ] + ] +} diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 00000000..0782fb75 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +[*] +charset = utf-8 +end_of_line = crlf +indent_size = 4 +indent_style = space +insert_final_newline = false +max_line_length = 200 +tab_width = 4 +trim_trailing_whitespace = true +ij_continuation_indent_size = 4 +ij_formatter_off_tag = @formatter:off +ij_formatter_on_tag = @formatter:on +ij_formatter_tags_enabled = true +ij_smart_tabs = false +ij_visual_guides = none +ij_wrap_on_typing = false \ No newline at end of file diff --git a/.github/workflows/sonarqube.yml b/.github/workflows/sonarqube.yml new file mode 100644 index 00000000..19ac64b6 --- /dev/null +++ b/.github/workflows/sonarqube.yml @@ -0,0 +1,20 @@ +on: + push: + branches: + - main + - develop + pull_request: + types: [opened, synchronize, reopened] +name: SonarQube PR Analysis +jobs: + sonarqube: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + fetch-depth: 0 + - name: SonarQube Scan + uses: sonarsource/sonarqube-scan-action@master + env: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_HOST_URL: ${{ secrets.SONAR_HOST_URL }} diff --git a/.gitignore b/.gitignore index 071aebbc..22fd4251 100644 --- a/.gitignore +++ b/.gitignore @@ -6,7 +6,6 @@ dist/ *.lock *.cache package-lock.json -*.js *.map *.d.ts .idea/ diff --git a/.prettierignore b/.prettierignore index 53c37a16..1521c8b7 100644 --- a/.prettierignore +++ b/.prettierignore @@ -1 +1 @@ -dist \ No newline at end of file +dist diff --git a/.prettierrc.json b/.prettierrc.json index 216efb86..7b308a2f 100644 --- a/.prettierrc.json +++ b/.prettierrc.json @@ -1,8 +1,10 @@ { - "printWidth": 100, + "bracketSpacing": true, + "printWidth": 120, + "trailingComma": "es5", "tabWidth": 4, "singleQuote": true, - "bracketSameLine": true, - "trailingComma": "none", - "semi": false + "singleAttributePerLine": true, + "htmlWhitespaceSensitivity": "ignore", + "bracketSameLine": false } diff --git a/CHANGELOG.md b/CHANGELOG.md new file mode 100644 index 00000000..2e193626 --- /dev/null +++ b/CHANGELOG.md @@ -0,0 +1,20 @@ +# Changelog + +All notable changes to this project will be documented in this file. + +--- + +## [Released] + +## [1.0.0] + +- Refactor method calls. +- Batch api calls. +- Response and push validation. +- Add general models. +- Add PayByBank +- Add In3 new + +## [0.9.0] + +- Beta release. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 11412766..042bdfac 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -2,23 +2,24 @@ ### Repository setup: -- Fork the repository to your account -- more details about [how to fork a repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) can be found [here](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo): +- Fork the repository to your account +- more details about [how to fork a repo](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo) can be + found [here](https://docs.github.com/en/github/getting-started-with-github/fork-a-repo): ### Making changes: -- create a branch from develop branch -- name of the branch shoul be something like: `feature/GITHUB-ISSUE-ID-slug` (eg: `feature/50-configprovider-update`) -- including unit tests is encouraged +- create a branch from develop branch +- name of the branch shoul be something like: `feature/GITHUB-ISSUE-ID-slug` (eg: `feature/50-configprovider-update`) +- including unit tests is encouraged ### Pull Request: -- open the PR to develop branch -- if there is no issue referenced, add a description about the problem and the way it is being solved -- Allow edits from maintainers +- open the PR to develop branch +- if there is no issue referenced, add a description about the problem and the way it is being solved +- Allow edits from maintainers ### Contribution to refactoring: -- include unit tests -- open the Pull Request -- check that git workflows checks have passed +- include unit tests +- open the Pull Request +- check that git workflows checks have passed diff --git a/README.md b/README.md index 2b4b35ed..31bb1ada 100644 --- a/README.md +++ b/README.md @@ -1,9 +1,9 @@ -
# Node SDK + [![Latest release](https://badgen.net/github/release/buckaroo-it/BuckarooSDK_Node)](https://github.com/buckaroo-it/BuckarooSDK_Node/releases)
@@ -11,7 +11,9 @@
--- + ### Index + - [About](#about) - [Requirements](#requirements) - [Installation](#installation) @@ -19,18 +21,21 @@ - [Contribute](#contribute) - [Versioning](#versioning) - [Additional information](#additional-information) + --- ### About -Buckaroo is the the Payment Service Provider for all your online payments with more than 15,000 companies relying on Buckaroo's platform to securely process their payments, subscriptions and unpaid invoices. Buckaroo developed their own Node SDK. The SDK is a modern, open-source Node.js library that makes it easy to integrate your Javascript application with Buckaroo's services. Start accepting payments today with Buckaroo. +Buckaroo is the Payment Service Provider for all your online payments with more than 15,000 companies relying on Buckaroo's platform to securely process their payments, subscriptions and unpaid +invoices. Buckaroo developed their own Node SDK. The SDK is a modern, open-source Node.js library that makes it easy to integrate your Javascript application with Buckaroo's services. Start accepting +payments today with Buckaroo. ### Requirements To use the Buckaroo API client, the following things are required: -- A Buckaroo account ([Dutch](https://www.buckaroo.nl/start) or [English](https://www.buckaroo.eu/solutions/request-form)) -- Node.js 6.14.× or greater +- A Buckaroo account ([Dutch](https://www.buckaroo.nl/start) or [English](https://www.buckaroo.eu/solutions/request-form)) +- Node.js 6.14.× or greater ### Installation @@ -43,37 +48,54 @@ npm install @buckaroo/buckaroo_sdk Initiate the buckaroo client with your website key and secret key. The keys can be retrieved from your [Buckaroo account](https://plaza.buckaroo.nl/Login). ```javascript -import { initializeBuckarooClient } from './BuckarooClient' -initializeBuckarooClient({ websiteKey: 'KEY', secretKey: 'SECRET' }) +import Buckaroo from '@buckaroo/buckaroo_sdk'; + +const buckarooClient = Buckaroo.InitializeClient( + { + secretKey: 'KEY', + websiteKey: 'SECRET', + }, + { + mode: 'TEST', // OR 'LIVE' + currency: 'EUR', + returnURL: 'RETURN_URL', + pushURL: 'PUSH_URL', + } +) ``` Create a payment with all the available payment methods. In this example, we show how to create a credit card payment. Each payment has a slightly different payload. ```javascript -import creditCard from './PaymentMethods/CreditCard' - -const payment = await creditCard().pay({ - amountDebit: 10, - name: 'Mastercard', - invoice: 'UNIQUE-INVOICE-NO' -}) +const payment = await buckarooClient + .method('mastercard') + .pay({ + amountDebit: 100, + }) + .request(); ``` After you create a transaction, you can retrieve several transaction information on demand. ```javascript -const transactionKey = payment.Key +const transaction = buckarooClient.transaction(payment.getTransactionKey()); -import { buckarooClient } from './BuckarooClient' - -buckarooClient().status(transactionKey) // Retrieve transaction status -buckarooClient().refundInfo(transactionKey) // Retrieve refund info -buckarooClient().cancelInfo(transactionKey) // Retrieve cancellation info +await transaction.status(); // Retrieve transaction status +await transaction.refundInfo(); // Retrieve refund info +await transaction.cancelInfo(); // Retrieve cancellation info ``` Find our full documentation online on [docs.buckaroo.io](https://docs.buckaroo.io/docs/node-sdk). +### Regarding Usage Outside of Node.js +This library is written in JavaScript, a versatile programming language with broad applicability. While it's technically possible to integrate this library into a website or mobile application, it's strongly advised against doing so. + +In the standard configuration, you make requests to the Buckaroo API using one of our provided libraries, typically from your server (such as a Node.js server). Your secret key is securely stored on this server, inaccessible to external entities. + +However, if you incorporate this library directly into a website or app, your secret key will be exposed to users. This could enable users to take actions on your behalf using that key. + #### Need more examples? + More examples can be found in the [examples folder](https://github.com/buckaroo-it/BuckarooSDK_Node/tree/master/example) ### Contribute @@ -87,14 +109,14 @@ If you want to contribute as well, then please follow our [Contribution Guidelin -- **MAJOR:** Breaking changes that require additional testing/caution -- **MINOR:** Changes that should not have a big impact -- **PATCHES:** Bug and hotfixes only +- **MAJOR:** Breaking changes that require additional testing/caution +- **MINOR:** Changes that should not have a big impact +- **PATCHES:** Bug and hotfixes only ### Additional information -- **Support:** https://support.buckaroo.eu/contact -- **Contact:** [support@buckaroo.nl](mailto:support@buckaroo.nl) or [+31 (0)30 711 50 50](tel:+310307115050) +- **Support:** https://support.buckaroo.eu/contact +- **Contact:** [support@buckaroo.nl](mailto:support@buckaroo.nl) or [+31 (0)30 711 50 50](tel:+310307115050) ## License diff --git a/example/BuckarooClient.ts b/example/BuckarooClient.ts deleted file mode 100644 index bccdd989..00000000 --- a/example/BuckarooClient.ts +++ /dev/null @@ -1,33 +0,0 @@ -import buckarooClient, { initializeBuckarooClient } from '../src/BuckarooClient' - -initializeBuckarooClient( - { secretKey: 'secretKey', websiteKey: 'websiteKey' }, - { - mode: 'test', - currency: 'EUR', - pushURL: process.env.BPE_PUSH_URL || '', - returnURL: process.env.BPE_RETURN_URL || '', - returnURLCancel: process.env.BPE_RETURN_URL_CANCEL || '', - baseUrl: process.env.BPE_BASE_URL || '' - } -) -async function getSpecificationsOfIdeal() { - return await buckarooClient() - .specification('ideal', 1) - .then((res) => { - expect(res).toBeDefined() - }) -} -async function startTransactionRequest() { - return await buckarooClient() - .transactionRequest({ - currency: 'EUR', - amountDebit: 10, - servicesExcludedForClient: 'ideal', - servicesSelectableByClient: 'ideal,bancontactmrcash,paypal' - }) - .then((res) => { - expect(res).toBeDefined() - }) -} -export default buckarooClient diff --git a/example/CreditManagment.ts b/example/CreditManagment.ts deleted file mode 100644 index 8b84f9c4..00000000 --- a/example/CreditManagment.ts +++ /dev/null @@ -1,26 +0,0 @@ -require('./BuckarooClient') -import CreditManagement from '../src/PaymentMethods/CreditManagement' - -const creditManagement = new CreditManagement() - -;(async () => { - try { - const info = await creditManagement.invoiceInfo({ - invoice: 'test1' - }) - - const infoMultiple = await creditManagement.invoiceInfo({ - invoice: 'invoice1', - invoices: [ - { - invoiceNumber: 'invoice2' - }, - { - invoiceNumber: 'invoice3' - } - ] - }) - } catch (error) { - console.warn(error) - } -})() diff --git a/example/ValidateResponse.ts b/example/ValidateResponse.ts deleted file mode 100644 index 7d2a6637..00000000 --- a/example/ValidateResponse.ts +++ /dev/null @@ -1,22 +0,0 @@ -import {ReplyHandler} from "../src/Handlers/Reply/ReplyHandler"; - -const buckarooClient = require('./BuckarooClient') - -const JsonDATA = '{"Key":"5340604668D74435AA344E1428ED1292","Invoice":"62d68b6c8ab0c","ServiceCode":"ideal","Status":{"Code":{"Code":190,"Description":"Success"},"SubCode":{"Code":"S001","Description":"Transaction successfully processed"},"DateTime":"2022-07-19T12:46:12"},"IsTest":true,"Order":"ORDER_NO_62d68b6ca2df3","Currency":"EUR","AmountDebit":10.1,"TransactionType":"C021","Services":[{"Name":"ideal","Action":null,"Parameters":[{"Name":"consumerIssuer","Value":"ABN AMRO"},{"Name":"transactionId","Value":"0000000000000001"},{"Name":"consumerName","Value":"J. de Tèster"},{"Name":"consumerIBAN","Value":"NL44RABO0123456789"},{"Name":"consumerBIC","Value":"RABONL2U"}],"VersionAsProperty":2}],"CustomParameters":null,"AdditionalParameters":{"List":[{"Name":"initiated_by_magento","Value":"1"},{"Name":"service_action","Value":"something"}]},"MutationType":1,"RelatedTransactions":null,"IsCancelable":false,"IssuingCountry":null,"StartRecurrent":false,"Recurring":false,"CustomerName":"J. de Tèster","PayerHash":"2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da","PaymentKey":"AEC974D455FF4A4B9B4C21E437A04838","Description":null}' -const auth_header = 'hmac N8hyQHxZ9W:swtPNR5+XSxKBYUJIWpJ8W/zDcZVuUJGn5kUR0HJEZg=:d550afab01d74207ad75f4ffe3e76beb:1686733946'; - -const url = 'https://buckaroo.dev/push' - -//Validate Json Response -let replyHandler = new ReplyHandler(buckarooClient().getCredentials(),JsonDATA,auth_header,url) -replyHandler.validate() -replyHandler.isValid // Returns true or false - -const HttpData = `ADD_service_action=1&brq_amount=10.10&brq_currency=EUR&brq_customer_name=J.+de+T%C3%A8ster&brq_invoicenumber=5fe146d9f7b198&brq_ordernumber=5fe146d9f78dd8&brq_payer_hash=2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da&brq_payment=82F023D0AE17443C9C674E8DEFE5279B&brq_payment_method=ideal&brq_SERVICE_ideal_consumerBIC=RABONL2U&brq_SERVICE_ideal_consumerIBAN=NL44RABO0123456789&brq_SERVICE_ideal_consumerIssuer=ABN+AMRO&brq_SERVICE_ideal_consumerName=J.+de+T%C3%A8ster&brq_SERVICE_ideal_transactionId=0000000000000001&brq_statuscode=190&brq_statuscode_detail=S001&brq_statusmessage=Transaction+successfully+processed&brq_test=true&brq_timestamp=2023-06-14+12%3A30%3A06&brq_transactions=85A3373B1A284B8F8E1D175CA5C0273B&brq_websitekey=N8hyQHxZ9W&brq_signature=62be159a87975a45d7b025cfbbff968c2dc8b9a1` - - -//Validate Http Response - -replyHandler = new ReplyHandler(buckarooClient().getCredentials(),HttpData) -replyHandler.validate() -replyHandler.isValid // Returns true or false diff --git a/example/additional_services/creditManagment.js b/example/additional_services/creditManagment.js new file mode 100644 index 00000000..28f87470 --- /dev/null +++ b/example/additional_services/creditManagment.js @@ -0,0 +1,63 @@ +import buckaroo from '../buckarooClient'; +const creditManagement = buckaroo.method('CreditManagement3'); +// Sometimes we need to combine multiple payments. +// By calling "combine" it will combine the payload of the method with the next method or a given payload. +const invoice = creditManagement.createCombinedInvoice({ + invoice: '', + applyStartRecurrent: false, + invoiceAmount: 10, + invoiceAmountVAT: 1, + invoiceDate: '', + dueDate: '', + schemeKey: '2amq34', + maxStepIndex: 1, + allowedServices: 'ideal,mastercard', + debtor: { + code: 'johnsmith4' + }, + email: 'youremail@example.nl', + phone: { + mobile: '06198765432' + }, + person: { + culture: 'nl-NL', + title: 'Msc', + initials: 'JS', + firstName: 'Test', + lastNamePrefix: 'Jones', + lastName: 'Aflever', + gender: 'male' + }, + company: { + culture: 'nl-NL', + name: 'My Company Corporation', + vatApplicable: true, + vatNumber: 'NL140619562B01', + chamberOfCommerce: '20091741' + }, + address: { + street: 'Hoofdtraat', + houseNumber: '90', + houseNumberAdditional: 'A', + zipcode: '8441ER', + city: 'Heerenveen', + state: 'Friesland', + country: 'NL' + } +}); +const sepadirectdebit = buckaroo.method('sepadirectdebit'); +sepadirectdebit + .combine(invoice.data) + .pay({ + invoice: '', + amountDebit: 10.1, + iban: 'NL13TEST0123456789', + bic: 'TESTNL2A', + collectdate: '2022-06-03', + mandateReference: '1DCtestreference', + mandateDate: '2022-07-03', + customer: { + name: 'John Smith' + } +}) + .request(); diff --git a/example/additional_services/creditManagment.ts b/example/additional_services/creditManagment.ts new file mode 100644 index 00000000..77cb68f0 --- /dev/null +++ b/example/additional_services/creditManagment.ts @@ -0,0 +1,67 @@ +import buckaroo from '../buckarooClient'; + +const creditManagement = buckaroo.method('CreditManagement3'); + +// Sometimes we need to combine multiple payments. +// By calling "combine" it will combine the payload of the method with the next method or a given payload. + +const invoice = creditManagement.createCombinedInvoice({ + invoice: '', + applyStartRecurrent: false, + invoiceAmount: 10, + invoiceAmountVAT: 1, + invoiceDate: '', + dueDate: '', + schemeKey: '2amq34', + maxStepIndex: 1, + allowedServices: 'ideal,mastercard', + debtor: { + code: 'johnsmith4', + }, + email: 'youremail@example.nl', + phone: { + mobile: '06198765432', + }, + person: { + culture: 'nl-NL', + title: 'Msc', + initials: 'JS', + firstName: 'Test', + lastNamePrefix: 'Jones', + lastName: 'Aflever', + gender: 'male', + }, + company: { + culture: 'nl-NL', + name: 'My Company Corporation', + vatApplicable: true, + vatNumber: 'NL140619562B01', + chamberOfCommerce: '20091741', + }, + address: { + street: 'Hoofdtraat', + houseNumber: '90', + houseNumberAdditional: 'A', + zipcode: '8441ER', + city: 'Heerenveen', + state: 'Friesland', + country: 'NL', + }, +}); + +buckaroo + .method('sepadirectdebit') + .combine(invoice.data) + .pay({ + invoice: '', + amountDebit: 10.1, + iban: 'NL13TEST0123456789', + bic: 'TESTNL2A', + collectdate: '2022-06-03', + mandateReference: '1DCtestreference', + mandateDate: '2022-07-03', + customer: { + name: 'John Smith', + }, + }) + .request(); diff --git a/example/subscription.ts b/example/additional_services/subscription.js similarity index 54% rename from example/subscription.ts rename to example/additional_services/subscription.js index b0d1740f..2b84c343 100644 --- a/example/subscription.ts +++ b/example/additional_services/subscription.js @@ -1,7 +1,6 @@ -require('./BuckarooClient') -import Subscriptions from '../src/PaymentMethods/Subscriptions' -import Ideal from '../src/PaymentMethods/Ideal' - +require('../buckarooClient'); +import Subscriptions from '../../src/PaymentMethods/Subscriptions'; +import Ideal from '../../src/PaymentMethods/Ideal'; const subscription = new Subscriptions().createCombined({ address: undefined, allowedServices: '', @@ -15,26 +14,23 @@ const subscription = new Subscriptions().createCombined({ customerBIC: '', customerIBAN: '', debtor: { code: '' }, - email: { - email: '345345345', - }, + email: '345345345', includeTransaction: false, mandateReference: '', - person: undefined, - phone: undefined, - ratePlan: undefined, - ratePlanCharge: undefined, subscriptionGuid: '', termStartDay: 0, termStartMonth: 0, termStartWeek: '', transactionVatPercentage: 0 -}) - -;(async () => { - const combinedPayment = await new Ideal().combine(subscription).pay({ - issuer: 'ABNANL2A', - amountDebit: 10 +}); +(async () => { + const combinedPayment = await new Ideal() + .pay({ + amountDebit: 1, + currency: 'EUR', + description: 'test' }) - console.log(combinedPayment) -})() + .combine('subscriptions') + .create({}); + console.log(combinedPayment); +})(); diff --git a/example/additional_services/subscription.ts b/example/additional_services/subscription.ts new file mode 100644 index 00000000..6b253898 --- /dev/null +++ b/example/additional_services/subscription.ts @@ -0,0 +1,36 @@ +import buckaroo from '../buckarooClient'; + +const subscription = buckaroo.method('CreditManagement3'); + +subscription.createCombined({ + address: undefined, + allowedServices: '', + b2b: '', + bankAccount: { accountName: '', bic: '', iban: '' }, + billingTiming: 0, + company: undefined, + configuration: undefined, + configurationCode: '', + customerAccountName: '', + customerBIC: '', + customerIBAN: '', + debtor: { code: '' }, + email: '345345345', + includeTransaction: false, + mandateReference: '', + subscriptionGuid: '', + termStartDay: 0, + termStartMonth: 0, + termStartWeek: '', + transactionVatPercentage: 0, +}); + +buckaroo + .method('ideal') + .combine(subscription) + .pay({ + amountDebit: 1, + currency: 'EUR', + description: 'test', + }) + .request(); diff --git a/example/buckarooClient.js b/example/buckarooClient.js new file mode 100644 index 00000000..112e489e --- /dev/null +++ b/example/buckarooClient.js @@ -0,0 +1,12 @@ +import Buckaroo from "@buckaroo/buckaroo_sdk"; +const buckaroo = Buckaroo.InitializeClient({ + secretKey: 'secret', + websiteKey: 'website' +}); +buckaroo.config = { + mode: 'TEST', + currency: 'EUR', + returnURL: 'https://example.com/return', + pushURL: 'https://example.com/push' +}; +export default buckaroo; diff --git a/example/buckarooClient.ts b/example/buckarooClient.ts new file mode 100644 index 00000000..5f276ac5 --- /dev/null +++ b/example/buckarooClient.ts @@ -0,0 +1,16 @@ +import Buckaroo from '@buckaroo/buckaroo_sdk'; + +const buckaroo = Buckaroo.InitializeClient( + { + secretKey: process.env.BPE_SECRET_KEY || '', + websiteKey: process.env.BPE_WEBSITE_KEY || '', + }, + { + mode: 'TEST', + currency: 'EUR', + returnURL: 'https://example.com/return', + pushURL: 'https://example.com/push', + } +); + +export default buckaroo; diff --git a/example/creditCard.ts b/example/creditCard.ts deleted file mode 100644 index 28dccab9..00000000 --- a/example/creditCard.ts +++ /dev/null @@ -1,16 +0,0 @@ -require('./BuckarooClient') -import CreditCard from '../src/PaymentMethods/CreditCard' - -const paymentMethod = new CreditCard() - -;(async () => { - try { - const info = await paymentMethod.pay({ - invoice: 'test1', - amountDebit: 12, - name: 'Visa' - }) - } catch (error) { - console.warn(error) - } -})() diff --git a/example/ideal.ts b/example/ideal.ts deleted file mode 100644 index a808e4ed..00000000 --- a/example/ideal.ts +++ /dev/null @@ -1,19 +0,0 @@ -require('../BuckarooClient.test') - -import Ideal from '../src/PaymentMethods/Ideal' - -const ideal = new Ideal() -async function startIdealPayment() { - return await ideal.pay({ - amountDebit: 10.1, - issuer: 'ABNANL2A', - clientIP: { - address: '123.456.789.123', - type: 0 - }, - description: 'Ideal Payment' - }) -} -startIdealPayment().then((response) => { - response.getRedirectUrl() -}) diff --git a/example/klarna.ts b/example/klarna.ts deleted file mode 100644 index eab0ea7f..00000000 --- a/example/klarna.ts +++ /dev/null @@ -1,27 +0,0 @@ -require('./BuckarooClient') -import Klarna from '../src/PaymentMethods/Klarna' - -const klarna = new Klarna() - -klarna.pay({ - article: [ - { - description: '', - grossUnitPrice: 0, - identifier: '', - quantity: '', - vatPercentage: '' - } - ], - amountDebit: 0, - billingCustomer: { - city: '', - country: '', - email: '', - firstName: '', - lastName: '', - postalCode: '', - street: '', - streetNumber: '' - } -}) diff --git a/example/payByBank.ts b/example/payByBank.ts deleted file mode 100644 index 6a6c77b8..00000000 --- a/example/payByBank.ts +++ /dev/null @@ -1,12 +0,0 @@ -require('../BuckarooClient.test') - -import PaymentInitiation from '../src/PaymentMethods/PaymentInitiation' - -const payByBank = new PaymentInitiation() -async function startPayByBankPayment() { - return await payByBank.pay({ - amountDebit: 10.1, - issuer: 'ABNANL2A', - countryCode: "NL", - }) -} diff --git a/example/response/push.js b/example/response/push.js new file mode 100644 index 00000000..8047966e --- /dev/null +++ b/example/response/push.js @@ -0,0 +1,39 @@ +import buckaroo from '../buckarooClient'; +import { ReplyHandler } from '../../src/Handlers/Reply/ReplyHandler'; +//START HTTP POST PUSH +let post_data = `{ + "brq_amount": "10.10", + "brq_currency": "EUR", + "brq_customer_name": "J. de Tèster", + "brq_invoicenumber": "SDKDevelopment.com_INVOICE_NO_628c6d032af90", + "brq_ordernumber": "SDKDevelopment.com_ORDER_NO_628c6d032af95", + "brq_payer_hash": "2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da", + "brq_payment": "D44ACDD0F99D4A1C811D2CD3EFDB05BA", + "brq_payment_method": "ideal", + "brq_SERVICE_ideal_consumerBIC": "RABONL2U", + "brq_SERVICE_ideal_consumerIBAN": "NL44RABO0123456789", + "brq_SERVICE_ideal_consumerIssuer": "ABN AMRO", + "brq_SERVICE_ideal_consumerName": "J. de Tèster", + "brq_SERVICE_ideal_transactionId": "0000000000000001", + "brq_statuscode": "190", + "brq_statuscode_detail": "S001", + "brq_statusmessage": "Transaction successfully processed", + "brq_test": "true", + "brq_timestamp": "2022-05-24 07:29:09", + "brq_transactions": "4C1BE53E2C42412AB32A799D9316E7DD", + "brq_websitekey": "IBjihN7Fhp", + "brq_signature": "bf7a62c830da2d2e004199919a8fe0d53b0668f5", +}`; +let reply_handler = new ReplyHandler(buckaroo.credentials, post_data); +reply_handler.validate(); +reply_handler.isValid(); // Return either true or false +//END HTTP POST PUSH +//START JSON PUSH +const auth_header = 'IBjihN7Fhp:0YvyjYAzDQ28W+hQi80f2nhe0Z1QFJLbz7IH//6LsAU=:cad1832100784f57a6e6de835d9f3638:1658227572'; +post_data = + '{"transaction":{"Key":"5340604668D74435AA344E1428ED1292","Invoice":"62d68b6c8ab0c","ServiceCode":"ideal","Status":{"Code":{"Code":190,"Description":"Success"},"SubCode":{"Code":"S001","Description":"transaction successfully processed"},"DateTime":"2022-07-19T12:46:12"},"IsTest":true,"Order":"ORDER_NO_62d68b6ca2df3","Currency":"EUR","AmountDebit":10.1,"TransactionType":"C021","Services":[{"Name":"ideal","Action":null,"Parameters":[{"Name":"consumerIssuer","Value":"ABN AMRO"},{"Name":"transactionId","Value":"0000000000000001"},{"Name":"consumerName","Value":"J. de Tèster"},{"Name":"consumerIBAN","Value":"NL44RABO0123456789"},{"Name":"consumerBIC","Value":"RABONL2U"}],"VersionAsProperty":2}],"CustomParameters":null,"AdditionalParameters":{"List":[{"Name":"initiated_by_magento","Value":"1"},{"Name":"service_action","Value":"something"}]},"MutationType":1,"RelatedTransactions":null,"IsCancelable":false,"IssuingCountry":null,"StartRecurrent":false,"Recurring":false,"CustomerName":"J. de Tèster","PayerHash":"2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da","PaymentKey":"AEC974D455FF4A4B9B4C21E437A04838","Description":null}}'; +const uri = 'https://buckaroo.dev/push'; +reply_handler = new ReplyHandler(buckaroo.credentials, post_data, auth_header, uri); +reply_handler.validate(); +reply_handler.isValid(); // Return either true or false +//END JSON PUSH diff --git a/example/response/push.ts b/example/response/push.ts new file mode 100644 index 00000000..17c9b2f5 --- /dev/null +++ b/example/response/push.ts @@ -0,0 +1,43 @@ +import buckaroo from '../buckarooClient'; +import { ReplyHandler } from '../../src/Handlers/Reply/ReplyHandler'; + +//START HTTP POST PUSH +let post_data = `{ + "brq_amount": "10.10", + "brq_currency": "EUR", + "brq_customer_name": "J. de Tèster", + "brq_invoicenumber": "SDKDevelopment.com_INVOICE_NO_628c6d032af90", + "brq_ordernumber": "SDKDevelopment.com_ORDER_NO_628c6d032af95", + "brq_payer_hash": "2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da", + "brq_payment": "D44ACDD0F99D4A1C811D2CD3EFDB05BA", + "brq_payment_method": "ideal", + "brq_SERVICE_ideal_consumerBIC": "RABONL2U", + "brq_SERVICE_ideal_consumerIBAN": "NL44RABO0123456789", + "brq_SERVICE_ideal_consumerIssuer": "ABN AMRO", + "brq_SERVICE_ideal_consumerName": "J. de Tèster", + "brq_SERVICE_ideal_transactionId": "0000000000000001", + "brq_statuscode": "190", + "brq_statuscode_detail": "S001", + "brq_statusmessage": "Transaction successfully processed", + "brq_test": "true", + "brq_timestamp": "2022-05-24 07:29:09", + "brq_transactions": "4C1BE53E2C42412AB32A799D9316E7DD", + "brq_websitekey": "IBjihN7Fhp", + "brq_signature": "bf7a62c830da2d2e004199919a8fe0d53b0668f5", +}`; + +let reply_handler = new ReplyHandler(buckaroo.credentials, post_data); +reply_handler.validate(); +reply_handler.isValid(); // Return either true or false +//END HTTP POST PUSH + +//START JSON PUSH +const auth_header = 'IBjihN7Fhp:0YvyjYAzDQ28W+hQi80f2nhe0Z1QFJLbz7IH//6LsAU=:cad1832100784f57a6e6de835d9f3638:1658227572'; +post_data = + '{"transaction":{"Key":"5340604668D74435AA344E1428ED1292","Invoice":"62d68b6c8ab0c","ServiceCode":"ideal","Status":{"Code":{"Code":190,"Description":"Success"},"SubCode":{"Code":"S001","Description":"transaction successfully processed"},"DateTime":"2022-07-19T12:46:12"},"IsTest":true,"Order":"ORDER_NO_62d68b6ca2df3","Currency":"EUR","AmountDebit":10.1,"TransactionType":"C021","Services":[{"Name":"ideal","Action":null,"Parameters":[{"Name":"consumerIssuer","Value":"ABN AMRO"},{"Name":"transactionId","Value":"0000000000000001"},{"Name":"consumerName","Value":"J. de Tèster"},{"Name":"consumerIBAN","Value":"NL44RABO0123456789"},{"Name":"consumerBIC","Value":"RABONL2U"}],"VersionAsProperty":2}],"CustomParameters":null,"AdditionalParameters":{"List":[{"Name":"initiated_by_magento","Value":"1"},{"Name":"service_action","Value":"something"}]},"MutationType":1,"RelatedTransactions":null,"IsCancelable":false,"IssuingCountry":null,"StartRecurrent":false,"Recurring":false,"CustomerName":"J. de Tèster","PayerHash":"2d26d34584a4eafeeaa97eed10cfdae22ae64cdce1649a80a55fafca8850e3e22cb32eb7c8fc95ef0c6f96669a21651d4734cc568816f9bd59c2092911e6c0da","PaymentKey":"AEC974D455FF4A4B9B4C21E437A04838","Description":null}}'; +const uri = 'https://buckaroo.dev/push'; + +reply_handler = new ReplyHandler(buckaroo.credentials, post_data, auth_header, uri); +reply_handler.validate(); +reply_handler.isValid(); // Return either true or false +//END JSON PUSH diff --git a/example/transaction/creditCard.js b/example/transaction/creditCard.js new file mode 100644 index 00000000..03b9c67d --- /dev/null +++ b/example/transaction/creditCard.js @@ -0,0 +1,15 @@ +require('../buckarooClient'); +import CreditCard from '../../src/PaymentMethods/CreditCard'; +const paymentMethod = new CreditCard('nexi'); +(async () => { + try { + const info = await paymentMethod.pay({ + invoice: 'test1', + amountDebit: 12 + }); + console.log(info); + } + catch (error) { + console.warn(error); + } +})(); diff --git a/example/transaction/creditCard.ts b/example/transaction/creditCard.ts new file mode 100644 index 00000000..505902fd --- /dev/null +++ b/example/transaction/creditCard.ts @@ -0,0 +1,6 @@ +import buckaroo from '../buckarooClient'; + +buckaroo.method('nexi').pay({ + invoice: 'test1', + amountDebit: 12, +}); diff --git a/example/transaction/ideal.js b/example/transaction/ideal.js new file mode 100644 index 00000000..a44f74a6 --- /dev/null +++ b/example/transaction/ideal.js @@ -0,0 +1,20 @@ +import buckarooClient from '../buckarooClient'; +const ideal = buckarooClient.method('ideal'); +//Pay +ideal + .pay({ + amountDebit: 10.1, + issuer: 'ABNANL2A', + description: 'Ideal Payment' +}) + .request(); +//Refund +ideal + .refund({ + originalTransactionKey: '', + amountCredit: 10.1, + invoice: '' +}) + .request(); +//Issuers +ideal.issuers(); diff --git a/example/transaction/ideal.ts b/example/transaction/ideal.ts new file mode 100644 index 00000000..b61ac5c9 --- /dev/null +++ b/example/transaction/ideal.ts @@ -0,0 +1,23 @@ +import buckarooClient from '../buckarooClient'; + +const ideal = buckarooClient.method('ideal'); + +//Pay +ideal + .pay({ + amountDebit: 10.1, + issuer: 'ABNANL2A', + description: 'Ideal Payment', + }) + .request(); +//Refund +ideal + .refund({ + originalTransactionKey: '', + amountCredit: 10.1, + invoice: '', + }) + .request(); + +//Issuers +ideal.issuers(); diff --git a/jest.config.js b/jest.config.js index 9d1dd1c9..ab7459e0 100644 --- a/jest.config.js +++ b/jest.config.js @@ -3,5 +3,5 @@ module.exports = { testEnvironment: 'node', testRegex: '/tests/.*.test.(ts|tsx)$', modulePathIgnorePatterns: ['/tests/.*(.d.ts)'], - moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'] -} + moduleFileExtensions: ['ts', 'tsx', 'js', 'jsx', 'json', 'node'], +}; diff --git a/package.json b/package.json index d04f07a9..b98c9888 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,19 @@ { "name": "@buckaroo/buckaroo_sdk", - "version": "0.9.0", + "version": "1.0.0", "description": "Buckaroo payment SDK", - "main": "dist/BuckarooClient.js", + "main": "dist/buckaroo.cjs.js", + "module": "dist/buckaroo.esm.js", + "types": "dist/index.d.ts", "engines": { "node": ">=6.14" }, "scripts": { - "prepare": "npm run build", - "build": "tsc", + "build": "yarn build:library && yarn build:declarations", + "dev": "yarn dev:library && yarn build:declarations", + "build:library": "rollup --config rollup.config.js", + "dev:library": "rollup --config rollup.config.js -w", + "build:declarations": "tsc --project tsconfig-declarations.json", "test": "jest", "prettier": "prettier --write ." }, @@ -23,6 +28,13 @@ "author": "Rinor Haziri", "license": "ISC", "devDependencies": { + "@babel/plugin-proposal-class-properties": "^7.18.6", + "@babel/preset-env": "^7.23.2", + "@babel/preset-typescript": "^7.23.2", + "@rollup/plugin-babel": "^6.0.4", + "@rollup/plugin-json": "^6.0.1", + "@rollup/plugin-node-resolve": "^15.2.3", + "@rollup/plugin-typescript": "^11.1.5", "@types/crypto-js": "^4.1.1", "@types/jest": "^29.4.0", "@types/node": "^18.11.18", @@ -33,7 +45,6 @@ "typescript": "^4.9.4" }, "dependencies": { - "axios": "^1.3.5", "crypto-js": "^4.1.1", "ip-address": "^8.1.0" }, @@ -46,6 +57,6 @@ }, "homepage": "https://github.com/buckaroo-it/BuckarooSDK_Node#readme", "files": [ - "dist/**/*" + "dist" ] } diff --git a/rollup.config.js b/rollup.config.js new file mode 100644 index 00000000..dfa12a13 --- /dev/null +++ b/rollup.config.js @@ -0,0 +1,47 @@ +const { join } = require('path'); +const json = require('@rollup/plugin-json'); +const resolve = require('@rollup/plugin-node-resolve'); +const babel = require('@rollup/plugin-babel'); +const typescript = require('@rollup/plugin-typescript'); + +module.exports = { + input: join('src', 'index.ts'), + external: [ + // These Node.js internals are external to our bundles… + 'crypto', + 'https', + 'querystring', + 'url', + 'util', + // …as are the dependencies listed in our package.json. + ...Object.keys(require('./package.json').dependencies), + ], + output: [ + { file: join('dist', 'buckaroo.cjs.js'), format: 'cjs' }, + { file: join('dist', 'buckaroo.esm.js'), format: 'es' }, + ], + plugins: [ + typescript(), + json(), + resolve({ + extensions: ['.ts'], + moduleDirectories: ['src'], + preferBuiltins: true, + }), + babel({ + extensions: ['.ts'], + }), + { + name: 'cert', + transform(code, id) { + if (id.endsWith('.pem') == false) { + return null; + } + return { + code: `export default ${JSON.stringify(code)}`, + map: { mappings: '' }, + }; + }, + }, + ], +}; diff --git a/sonar-project.properties b/sonar-project.properties new file mode 100644 index 00000000..a1b5f9b5 --- /dev/null +++ b/sonar-project.properties @@ -0,0 +1,9 @@ +# Unique key for the project +sonar.projectKey=buckaroo:node_sdk + +# Display name and version for the SonarQube UI +sonar.projectName=Buckaroo Node SDK +sonar.projectVersion=1.0 + +# Path to the source code, relative to the sonar-project.properties file +sonar.sources=. diff --git a/src/BuckarooClient.ts b/src/BuckarooClient.ts deleted file mode 100644 index 8d2f5a29..00000000 --- a/src/BuckarooClient.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { IConfig, ICredentials } from './Utils/Types' -import { Client } from './Request/Client' - -let _client: Client -export function initializeBuckarooClient(credentials: ICredentials, config?: IConfig) { - if (!_client) { - _client = Client.initialize(credentials, config) - } - return _client -} -const BuckarooClient = () => (_client instanceof Client ? _client : Client.initialize()) -export default BuckarooClient diff --git a/src/Constants/CreditManagementInstallmentInterval.ts b/src/Constants/CreditManagementInstallmentInterval.ts index 245163cc..2902e8af 100644 --- a/src/Constants/CreditManagementInstallmentInterval.ts +++ b/src/Constants/CreditManagementInstallmentInterval.ts @@ -8,7 +8,7 @@ enum CreditManagementInstallmentInterval { TWOMONTHS = 'TwoMonths', QUARTERYEAR = 'QuarterYear', HALFYEAR = 'HalfYear', - YEAR = 'Year' + YEAR = 'Year', } -export default CreditManagementInstallmentInterval +export default CreditManagementInstallmentInterval; diff --git a/src/Constants/Endpoints.ts b/src/Constants/Endpoints.ts index afdb6cad..bd6b8885 100644 --- a/src/Constants/Endpoints.ts +++ b/src/Constants/Endpoints.ts @@ -1,10 +1,13 @@ enum Endpoints { - LIVE = 'https://checkout.buckaroo.nl/', - TEST = 'https://testcheckout.buckaroo.nl/' + LIVE = 'https://checkout.buckaroo.nl', + TEST = 'https://testcheckout.buckaroo.nl', } -enum RequestType { - Data = 1, - Transaction = 2 + +export enum RequestTypes { + Data = '/json/DataRequest', + Transaction = '/json/Transaction', + BatchData = '/json/batch/DataRequests', + BatchTransaction = '/json/batch/Transactions', } -export { RequestType } -export default Endpoints + +export default Endpoints; diff --git a/src/Constants/Gender.ts b/src/Constants/Gender.ts index dda7de2b..0a4f8284 100644 --- a/src/Constants/Gender.ts +++ b/src/Constants/Gender.ts @@ -2,6 +2,7 @@ enum Gender { UNKNOWN = 0, MALE = 1, FEMALE = 2, - NOT_APPLICABLE = 9 + NOT_APPLICABLE = 9, } -export default Gender + +export default Gender; diff --git a/src/Constants/HttpMethods.ts b/src/Constants/HttpMethods.ts index 2903572c..1d12e316 100644 --- a/src/Constants/HttpMethods.ts +++ b/src/Constants/HttpMethods.ts @@ -1,5 +1,6 @@ enum HttpMethods { GET = 'GET', - POST = 'POST' + POST = 'POST', } -export default HttpMethods + +export default HttpMethods; diff --git a/src/Constants/IPProtocolVersion.ts b/src/Constants/IPProtocolVersion.ts index 47af76ef..eb8f8d0d 100644 --- a/src/Constants/IPProtocolVersion.ts +++ b/src/Constants/IPProtocolVersion.ts @@ -1,16 +1,28 @@ -import * as IpAddress from 'ip-address' +import * as IpAddress from 'ip-address'; + +import { getIPAddress } from '../Utils'; export class IPProtocolVersion { - public static readonly IPV4: number = 0 - public static readonly IPV6: number = 1 + public static readonly IPV4: number = 0; + public static readonly IPV6: number = 1; public static getVersion(ipAddress: string = '0.0.0.0'): number { if (IpAddress.Address4.isValid(ipAddress)) { - return IPProtocolVersion.IPV4 + return IPProtocolVersion.IPV4; } if (IpAddress.Address6.isValid(ipAddress)) { - return IPProtocolVersion.IPV6 + return IPProtocolVersion.IPV6; } - throw new Error(`Invalid IP address: ${ipAddress}`) + throw new Error(`Invalid IP address: ${ipAddress}`); + } +} + +export class ClientIP { + type: IPProtocolVersion; + address: string; + + constructor(ipAddress: string = getIPAddress()) { + this.type = IPProtocolVersion.getVersion(ipAddress); + this.address = ipAddress; } } diff --git a/src/Constants/RecipientCategory.ts b/src/Constants/RecipientCategory.ts index 542fed45..edd1954d 100644 --- a/src/Constants/RecipientCategory.ts +++ b/src/Constants/RecipientCategory.ts @@ -1,7 +1,6 @@ enum RecipientCategory { - PERSON = 'Person', - COMPANY = 'Company', - B2B = 'B2B', - B2C = 'B2C' + PERSON = 'PERSON', + COMPANY = 'COMPANY', } -export default RecipientCategory + +export default RecipientCategory; diff --git a/src/Constants/ResponseStatus.ts b/src/Constants/ResponseStatus.ts index cb768207..81b2b57e 100644 --- a/src/Constants/ResponseStatus.ts +++ b/src/Constants/ResponseStatus.ts @@ -1,17 +1,18 @@ enum ResponseStatus { - BUCKAROO_STATUSCODE_SUCCESS = '190', - BUCKAROO_STATUSCODE_FAILED = '490', - BUCKAROO_STATUSCODE_VALIDATION_FAILURE = '491', - BUCKAROO_STATUSCODE_TECHNICAL_ERROR = '492', - BUCKAROO_STATUSCODE_REJECTED = '690', - BUCKAROO_STATUSCODE_WAITING_ON_USER_INPUT = '790', - BUCKAROO_STATUSCODE_PENDING_PROCESSING = '791', - BUCKAROO_STATUSCODE_WAITING_ON_CONSUMER = '792', - BUCKAROO_STATUSCODE_PAYMENT_ON_HOLD = '793', - BUCKAROO_STATUSCODE_CANCELLED_BY_USER = '890', - BUCKAROO_STATUSCODE_CANCELLED_BY_MERCHANT = '891', - BUCKAROO_AUTHORIZE_TYPE_CANCEL = 'I014', - BUCKAROO_AUTHORIZE_TYPE_ACCEPT = 'I013', - BUCKAROO_AUTHORIZE_TYPE_GROUP_TRANSACTION = 'I150' + STATUSCODE_SUCCESS = '190', + STATUSCODE_FAILED = '490', + STATUSCODE_VALIDATION_FAILURE = '491', + STATUSCODE_TECHNICAL_ERROR = '492', + STATUSCODE_REJECTED = '690', + STATUSCODE_WAITING_ON_USER_INPUT = '790', + STATUSCODE_PENDING_PROCESSING = '791', + STATUSCODE_WAITING_ON_CONSUMER = '792', + STATUSCODE_PAYMENT_ON_HOLD = '793', + STATUSCODE_CANCELLED_BY_USER = '890', + STATUSCODE_CANCELLED_BY_MERCHANT = '891', + AUTHORIZE_TYPE_CANCEL = 'I014', + AUTHORIZE_TYPE_ACCEPT = 'I013', + AUTHORIZE_TYPE_GROUP_TRANSACTION = 'I150', } -export default ResponseStatus + +export default ResponseStatus; diff --git a/src/Constants/index.ts b/src/Constants/index.ts new file mode 100644 index 00000000..c7dbcd7f --- /dev/null +++ b/src/Constants/index.ts @@ -0,0 +1,11 @@ +import Endpoints, { RequestTypes } from './Endpoints'; + +export { default as CreditManagementInstallmentInterval } from './CreditManagementInstallmentInterval'; +export { default as Gender } from './Gender'; +export { default as HttpMethods } from './HttpMethods'; +export * from './IPProtocolVersion'; +export * from './ResponseStatus'; +export { default as RecipientCategory } from './RecipientCategory'; +export { default as ResponseStatus } from './ResponseStatus'; + +export { Endpoints, RequestTypes }; \ No newline at end of file diff --git a/src/Handlers/Credentials.ts b/src/Handlers/Credentials.ts new file mode 100644 index 00000000..5accfd98 --- /dev/null +++ b/src/Handlers/Credentials.ts @@ -0,0 +1,27 @@ +import { ICredentials } from '../Utils'; +import { Request } from '../Request'; +import { RequestTypes } from '../Constants'; + +export class Credentials implements ICredentials { + secretKey: string; + websiteKey: string; + + constructor(secretKey: string, websiteKey: string) { + this.secretKey = secretKey; + this.websiteKey = websiteKey; + } + + confirm() { + return Request.Specification(RequestTypes.Transaction, { + name: 'ideal', + version: 2, + }) + .request() + .then((response) => { + return response.httpResponse.status === 200; + }) + .catch(() => { + return false; + }); + } +} diff --git a/src/Handlers/Reply/ReplyHandler.ts b/src/Handlers/Reply/ReplyHandler.ts index bd28fd24..9319088a 100644 --- a/src/Handlers/Reply/ReplyHandler.ts +++ b/src/Handlers/Reply/ReplyHandler.ts @@ -1,68 +1,68 @@ -import crypto from "crypto"; -import HttpMethods from "../../Constants/HttpMethods"; -import {ICredentials} from "../../Utils/Types"; -import {Hmac} from "../../Request/Hmac"; -import buckarooClient from "../../BuckarooClient"; +import crypto from 'crypto'; +import { ICredentials } from '../../Utils'; +import { Hmac } from '../../Request'; +import { HttpMethods } from '../../Constants'; export class ReplyHandler { - private readonly data: object - private readonly uri?: string - private readonly auth_header?: string - private credentials: ICredentials; - private _isValid: boolean = false + private readonly _data: object; + private readonly uri?: string; + private readonly auth_header?: string; + private readonly credentials: ICredentials; + private _isValid: boolean = false; + private strategy: 'JSON' | 'HTTP' = 'JSON'; + private method?: string; - constructor(credentials: ICredentials, data: string,auth_header?: string, uri?: string) { - try { - this.data = JSON.parse(data) - } catch (e){ - let objData = {} - new URLSearchParams(data).forEach((value, name)=>{ - objData[name] = value - }) - this.data = objData - } - this.credentials = credentials - this.uri = uri - this.auth_header = auth_header + constructor(credentials: ICredentials, data: string, auth_header?: string, uri?: string, httpMethod?: string) { + this._data = this.formatStringData(data); + this.credentials = credentials; + this.uri = uri; + this.auth_header = auth_header; + this.method = httpMethod; } - get isValid(){ - return this._isValid + + isValid(): boolean { + return this._isValid; } + validate() { - if(this.data["Key"] && this.auth_header && this.uri) { - this._isValid = this.validateJson(this.auth_header) - return this + if (this.strategy === 'HTTP') { + let { brq_signature, BRQ_SIGNATURE, ...data } = this._data as any; + this._isValid = this.validateHttp(data, brq_signature || BRQ_SIGNATURE); + return this; } - - if (this.data["brq_signature"] || this.data["BRQ_SIGNATURE"]){ - let { brq_signature , BRQ_SIGNATURE, ...data} = this.data as any - this._isValid = this.validateHttp(data,brq_signature || BRQ_SIGNATURE) - return this + if (this.strategy === 'JSON' && this.auth_header && this.uri) { + this._isValid = this.validateJson(this.auth_header, this.uri, JSON.stringify(this._data)); + return this; } - - throw new Error('Invalid reply data') + throw new Error('Invalid response data'); } - private validateJson(auth_header:string){ - let header = auth_header.split(':') - let providedHash = header[1] - let nonce = header[2] - let time = header[3] - let hmac = new Hmac(HttpMethods.POST,this.uri,this.data,nonce,time) - - let hash = hmac.hashData(hmac.getHashString()) + private formatStringData(value: string) { + try { + let data = JSON.parse(value); + this.strategy = 'JSON'; + return data; + } catch (e) { + let objData: Record = InstanceType;
+
+export function getMethod(code: Code): PaymentMethodInstance {
+ const methodClass = AllPaymentMethods[code];
+ if (!methodClass) {
+ throw new Error(`Invalid payment method code: ${code}`);
+ }
+
+ return new methodClass(code as any) as PaymentMethodInstance;
+}
diff --git a/src/Utils/Types.ts b/src/Utils/Types.ts
index 91b12c01..a40e3d88 100644
--- a/src/Utils/Types.ts
+++ b/src/Utils/Types.ts
@@ -1,26 +1,21 @@
+import { ServiceCode } from './MethodTypes';
+
export declare interface IConfig {
- mode: 'live' | 'test'
- currency: string
- returnURL: string
- returnURLCancel: string
- pushURL: string
- baseUrl: string
+ mode: Mode;
+ currency: string;
+ continueOnIncomplete?: 0 | 1;
+ returnURL?: string;
+ returnURLCancel?: string;
+ pushURL?: string;
+ returnURLError?: string;
+ returnURLReject?: string;
+ activePaymentMethods?: ServiceCode[];
+ disabledPaymentMethods?: ServiceCode[];
}
export declare interface ICredentials {
- websiteKey: string
- secretKey: string
-}
-
-export type IPAddress = {
- address: string
- type: number
+ websiteKey: string;
+ secretKey: string;
}
-export type ParameterTypes = string | number | boolean | undefined
-export declare type AdditionalParameter = {
- [name: string]: ParameterTypes
-}
-export declare interface ServiceParameters {
- [name: string]: ParameterTypes | ParameterTypes[] | ServiceParameters | ServiceParameters[]
-}
+export type Mode = 'LIVE' | 'TEST';
diff --git a/src/Utils/index.ts b/src/Utils/index.ts
new file mode 100644
index 00000000..6ff6c310
--- /dev/null
+++ b/src/Utils/index.ts
@@ -0,0 +1,3 @@
+export * from './MethodTypes';
+export * from './Types';
+export * from './Functions';
\ No newline at end of file
diff --git a/src/buckaroo.ts b/src/buckaroo.ts
new file mode 100644
index 00000000..fd92bc90
--- /dev/null
+++ b/src/buckaroo.ts
@@ -0,0 +1,69 @@
+import { getMethod, IConfig, ICredentials, PaymentMethodInstance, ServiceCode } from './Utils';
+import { HttpsClient, Request } from './Request';
+import { Agent } from 'https';
+import NoService from './PaymentMethods/NoService';
+import { TransactionService } from './Services';
+import { Credentials } from './Handlers';
+
+export default class Buckaroo {
+ private static _client: Buckaroo;
+ private readonly _credentials: Credentials;
+ private readonly _httpClient: HttpsClient;
+ private _config: IConfig;
+
+ constructor(credentials: ICredentials, config?: IConfig, agent?: Agent) {
+ this._credentials = new Credentials(credentials.secretKey, credentials.websiteKey);
+ this._config = { ...(config ?? { mode: 'TEST', currency: 'EUR' }) };
+ this._httpClient = new HttpsClient(agent);
+ }
+
+ static get Client(): Buckaroo {
+ return this._client;
+ }
+
+ get config(): IConfig {
+ return { ...this._config };
+ }
+
+ set config(value: IConfig) {
+ this._config = value;
+ }
+
+ get credentials(): ICredentials {
+ return this._credentials;
+ }
+
+ get httpClient() {
+ return this._httpClient;
+ }
+
+ get batch() {
+ return {
+ transaction: Request.BatchTransaction,
+ data: Request.BatchDataRequest,
+ };
+ }
+
+ static InitializeClient(credentials: ICredentials, config?: IConfig, agent?: Agent): Buckaroo {
+ return (this._client = new this(credentials, config, agent));
+ }
+
+ method(): NoService;
+ method(name: Name): PaymentMethodInstance;
+ method(name?: K) {
+ if (!name) {
+ return new NoService();
+ }
+ return getMethod(name);
+ }
+
+ confirmCredentials() {
+ return this._credentials.confirm();
+ }
+
+ transaction(key: string) {
+ return new TransactionService(key);
+ }
+}
+
+export { Buckaroo };
\ No newline at end of file
diff --git a/src/index.ts b/src/index.ts
new file mode 100644
index 00000000..1708bd9c
--- /dev/null
+++ b/src/index.ts
@@ -0,0 +1,12 @@
+import Buckaroo from './buckaroo';
+
+export * from './Constants';
+export * from './Handlers';
+export * from './Models';
+export * from './PaymentMethods';
+export * from './Request';
+export * from './Services';
+export * from './Utils';
+
+export default Buckaroo;
+export { Buckaroo };
\ No newline at end of file
diff --git a/tests/BuckarooClient.test.js b/tests/BuckarooClient.test.js
new file mode 100644
index 00000000..0c11eb77
--- /dev/null
+++ b/tests/BuckarooClient.test.js
@@ -0,0 +1,13 @@
+import Buckaroo from '../src';
+require('dotenv').config();
+const BuckarooClient = Buckaroo.InitializeClient({
+ secretKey: process.env.BPE_SECRET_KEY || '',
+ websiteKey: process.env.BPE_WEBSITE_KEY || ''
+}, {
+ mode: process.env.BPE_MODE === 'LIVE' ? 'LIVE' : 'TEST',
+ currency: process.env.BPE_CURRENCY_CODE || 'EUR',
+ returnURL: process.env.BPE_RETURN_URL || '',
+ returnURLCancel: process.env.BPE_RETURN_URL_CANCEL || '',
+ pushURL: process.env.BPE_PUSH_URL || ''
+});
+export default BuckarooClient;
diff --git a/tests/BuckarooClient.test.ts b/tests/BuckarooClient.test.ts
index fed52b0b..f69f792e 100644
--- a/tests/BuckarooClient.test.ts
+++ b/tests/BuckarooClient.test.ts
@@ -1,16 +1,18 @@
-import { initializeBuckarooClient } from '../src/BuckarooClient'
-require('dotenv').config()
-export default initializeBuckarooClient(
+import Buckaroo from '../src';
+
+require('dotenv').config();
+
+const BuckarooClient = Buckaroo.InitializeClient(
{
secretKey: process.env.BPE_SECRET_KEY || '',
- websiteKey: process.env.BPE_WEBSITE_KEY || ''
+ websiteKey: process.env.BPE_WEBSITE_KEY || '',
},
{
- mode: process.env.BPE_MODE === 'live' ? 'live' : 'test',
+ mode: process.env.BPE_MODE === 'LIVE' ? 'LIVE' : 'TEST',
currency: process.env.BPE_CURRENCY_CODE || 'EUR',
returnURL: process.env.BPE_RETURN_URL || '',
returnURLCancel: process.env.BPE_RETURN_URL_CANCEL || '',
pushURL: process.env.BPE_PUSH_URL || '',
- baseUrl: process.env.BPE_BASE_URL || ''
}
-)
+);
+export default BuckarooClient;
diff --git a/tests/Client.test.js b/tests/Client.test.js
new file mode 100644
index 00000000..fe724816
--- /dev/null
+++ b/tests/Client.test.js
@@ -0,0 +1,72 @@
+import client from './BuckarooClient.test';
+import { TransactionResponse } from '../src/Models/Response/TransactionResponse';
+import { HttpClientResponse } from '../src/Models/Response/HttpClientResponse';
+import { uniqid } from '../src/Utils/Functions';
+import { creditManagementTestInvoice } from "./PaymentMethods/CreditManagment.test";
+describe('Testing Buckaroo Client', () => {
+ test('Credentials', () => {
+ return client
+ .confirmCredentials()
+ .then((response) => {
+ expect(response).toBeTruthy();
+ });
+ });
+ test('Batch transaction', async () => {
+ const transactionData = [];
+ for (let i = 0; i < 3; i++) {
+ let invoice = client
+ .method('CreditManagement3')
+ .createCombinedInvoice(creditManagementTestInvoice())
+ .combine('sepadirectdebit')
+ .pay({
+ invoice: uniqid(),
+ amountDebit: 10.1,
+ iban: 'NL13TEST0123456789',
+ bic: 'TESTNL2A',
+ collectdate: '2024-07-03',
+ mandateReference: '1DCtestreference',
+ mandateDate: '2022-07-03',
+ customer: {
+ name: 'John Smith'
+ }
+ });
+ transactionData.push(invoice.data);
+ }
+ await client
+ .batch(transactionData)
+ .request()
+ .then((response) => {
+ expect(response).toBeTruthy();
+ })
+ .catch((err) => {
+ expect(err).toBeUndefined();
+ });
+ });
+ describe('Transaction', () => {
+ const transactionService = client.transaction('39F3EC520A3F4A25B0A1899D4FF0E1CB');
+ test('transaction Status', async () => {
+ await transactionService
+ .status()
+ .then((res) => {
+ expect(res instanceof TransactionResponse).toBeTruthy();
+ })
+ .catch((err) => {
+ expect(err).toBeUndefined();
+ });
+ });
+ test('transaction Cancel Info', async () => {
+ await transactionService
+ .cancelInfo()
+ .then((res) => {
+ expect(res instanceof HttpClientResponse).toBeTruthy();
+ });
+ });
+ test('transaction Refund Info', async () => {
+ await transactionService
+ .refundInfo()
+ .then((res) => {
+ expect(res instanceof HttpClientResponse).toBeTruthy();
+ });
+ });
+ });
+});
diff --git a/tests/Client.test.ts b/tests/Client.test.ts
new file mode 100644
index 00000000..d4880e4e
--- /dev/null
+++ b/tests/Client.test.ts
@@ -0,0 +1,68 @@
+import client from './BuckarooClient.test';
+import { HttpClientResponse, IRequest, TransactionResponse, uniqid } from '../src';
+import { creditManagementTestInvoice } from './PaymentMethods/CreditManagment.test';
+
+describe('Testing Buckaroo Client', () => {
+ test('Credentials', () => {
+ return client.confirmCredentials().then((response) => {
+ expect(response).toBeTruthy();
+ });
+ });
+ test('Batch transaction', async () => {
+ const transactionData: IRequest[] = [];
+ const creditManagement = client.method('CreditManagement3');
+ const sepaDirectDebit = client.method('sepadirectdebit');
+ for (let i = 0; i < 3; i++) {
+ const combinedInvoice = creditManagement.createCombinedInvoice(creditManagementTestInvoice());
+
+ const sepaRequest = sepaDirectDebit.combine(combinedInvoice.data).pay({
+ iban: 'NL39RABO0300065264',
+ bic: 'RABONL2U',
+ mandateReference: '1DCtestreference',
+ mandateDate: '2022-07-03',
+ collectDate: '2020-07-03',
+ amountDebit: 10.1,
+ customer: {
+ name: 'John Smith',
+ },
+ invoice: uniqid('TestInvoice'),
+ });
+
+ transactionData.push(sepaRequest.data);
+ }
+
+ await client.batch
+ .transaction(transactionData)
+ .request()
+ .then((response) => {
+ expect(response.data.message === '3 transactions were queued for processing.').toBeTruthy();
+ })
+ .catch((err) => {
+ expect(err).toBeUndefined();
+ });
+ });
+ describe('Transaction', () => {
+ const transactionService = client.transaction('39F3EC520A3F4A25B0A1899D4FF0E1CB');
+ test('transaction Status', async () => {
+ await transactionService
+ .status()
+ .then((res) => {
+ expect(res instanceof TransactionResponse).toBeTruthy();
+ })
+ .catch((err) => {
+ expect(err).toBeUndefined();
+ });
+ });
+ test('transaction Cancel Info', async () => {
+ await transactionService.cancelInfo().then((res) => {
+ expect(res instanceof HttpClientResponse).toBeTruthy();
+ });
+ });
+
+ test('transaction Refund Info', async () => {
+ await transactionService.refundInfo().then((res) => {
+ expect(res instanceof HttpClientResponse).toBeTruthy();
+ });
+ });
+ });
+});
diff --git a/tests/Models/index.js b/tests/Models/index.js
new file mode 100644
index 00000000..b8a9fbe0
--- /dev/null
+++ b/tests/Models/index.js
@@ -0,0 +1,60 @@
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+import { getIPAddress } from '../../src/Utils/Functions';
+export const TestPerson = {
+ birthDate: '1990-01-01',
+ category: RecipientCategory.PERSON,
+ culture: '321',
+ firstName: 'John',
+ gender: 'male',
+ initials: 'R.T',
+ lastName: 'Do',
+ lastNamePrefix: 'testlastprefix',
+ placeOfBirth: 't',
+ title: 'title'
+};
+export const TestCompany = {
+ category: RecipientCategory.COMPANY,
+ careOf: 'test',
+ chamberOfCommerce: 'test',
+ companyName: 'testCompany',
+ culture: 'culture',
+ vatApplicable: false,
+ vatNumber: '321'
+};
+export const TestAddress = {
+ city: 'city',
+ country: 'NL',
+ houseNumber: '2313432',
+ houseNumberAdditional: '324',
+ state: 'state',
+ street: 'street',
+ zipcode: '32323'
+};
+export const TestArticle = {
+ description: 'test',
+ identifier: 'identifier',
+ price: 10,
+ quantity: 2,
+ type: 'PhysicalArticle',
+ unitCode: '23',
+ vatCategory: '323',
+ vatPercentage: 1
+};
+export const TestPhone = {
+ fax: '23232',
+ landline: '323123',
+ mobile: '21312332'
+};
+export const TestEmail = 'test@hotmail.com';
+export const TestBankAccount = {
+ accountName: 'accountName',
+ bic: 'bic',
+ iban: 'iban'
+};
+export const TestBilling = {
+ recipient: TestPerson,
+ address: TestAddress,
+ phone: TestPhone,
+ email: TestEmail
+};
+export const TestIp = getIPAddress();
diff --git a/tests/Models/index.ts b/tests/Models/index.ts
new file mode 100644
index 00000000..bca7510f
--- /dev/null
+++ b/tests/Models/index.ts
@@ -0,0 +1,83 @@
+import {
+ Gender,
+ getIPAddress,
+ IAddress,
+ IArticle,
+ IBankAccount,
+ ICompany,
+ IPerson,
+ IPhone,
+ RecipientCategory,
+ uniqid,
+} from '../../src';
+
+export const TestPerson: IPerson = {
+ birthDate: '1990-01-01',
+ category: RecipientCategory.PERSON,
+ culture: '321',
+ firstName: 'John',
+ gender: 'male',
+ initials: 'R.T',
+ lastName: 'Do',
+ lastNamePrefix: 'testlastprefix',
+ placeOfBirth: 't',
+ title: 'title',
+};
+export const TestCompany: ICompany = {
+ category: RecipientCategory.COMPANY,
+ careOf: 'test',
+ chamberOfCommerce: 'test',
+ companyName: 'testCompany',
+ culture: 'culture',
+ vatApplicable: false,
+ vatNumber: '321',
+};
+export const TestAddress: IAddress = {
+ city: 'city',
+ country: 'NL',
+ houseNumber: '2313432',
+ houseNumberAdditional: '324',
+ state: 'state',
+ street: 'street',
+ zipcode: '32323',
+};
+export const TestArticle: IArticle = {
+ description: 'test',
+ identifier: 'identifier',
+ price: 10,
+ quantity: 2,
+ type: 'PhysicalArticle',
+ unitCode: '23',
+ vatCategory: '323',
+ vatPercentage: 1,
+};
+
+export const TestPhone: IPhone = {
+ fax: '23232',
+ landline: '323123',
+ mobile: '21312332',
+};
+export const TestEmail = 'test@hotmail.com';
+export const TestBankAccount: IBankAccount = {
+ accountName: 'accountName',
+ bic: 'bic',
+ iban: 'iban',
+};
+export const TestBilling = {
+ recipient: TestPerson,
+ address: TestAddress,
+ phone: TestPhone,
+ email: TestEmail,
+};
+
+export const TestCustomer = {
+ identificationNumber: uniqid(),
+ gender: Gender.FEMALE,
+ culture: TestPerson.culture,
+ initials: TestPerson.initials,
+ lastName: TestPerson.lastName,
+ firstName: TestPerson.firstName,
+ birthDate: '1990-01-01',
+};
+
+export const TestIp = getIPAddress();
diff --git a/tests/PaymentMethods/AfterPay.test.js b/tests/PaymentMethods/AfterPay.test.js
new file mode 100644
index 00000000..5e1780c9
--- /dev/null
+++ b/tests/PaymentMethods/AfterPay.test.js
@@ -0,0 +1,122 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { RequestTypes } from '../../src/Constants/Endpoints';
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+const method = buckarooClientTest.method('afterpay');
+describe('AfterPay methods', () => {
+ test('Pay', () => {
+ return method
+ .pay(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ invoice: 'testinvoice 123',
+ originalTransactionKey: '4E8BD922192746C3918BF4077CXXXXXX',
+ amountCredit: 1.23
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authorize', async () => {
+ await method
+ .authorize(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('CancelAuthorize', async () => {
+ await method
+ .cancelAuthorize({
+ invoice: 'testinvoice 123',
+ originalTransactionKey: '4E8BD922192746C3918BF4077CXXXXXX',
+ amountCredit: 1.23
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Capture', async () => {
+ await method
+ .capture({
+ ...paymentPayload,
+ originalTransactionKey: '123456789'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('PayRemainder', async () => {
+ await method
+ .payRemainder({})
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('AuthorizeRemainder', async () => {
+ await method
+ .authorizeRemainder({})
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Spercifications', async () => {
+ return method
+ .specification(RequestTypes.Transaction)
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
+const paymentPayload = {
+ clientIP: '127.0.0.1',
+ amountDebit: 40,
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'John Smith',
+ firstName: 'John',
+ lastName: 'Do',
+ birthDate: '1990-01-01',
+ companyName: 'buckarooTest',
+ conversationLanguage: 'NL',
+ identificationNumber: 'IdNumber12345',
+ customerNumber: 'customerNumber12345'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'a',
+ zipcode: '1234AB',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ email: 'test@buckaroo.nl',
+ phone: {
+ mobile: '0612345678',
+ landline: '0513123456'
+ }
+ },
+ articles: [
+ {
+ vatPercentage: 21,
+ price: 10,
+ description: 'Test',
+ quantity: 4,
+ identifier: 'test'
+ }
+ ],
+ description: 'Test',
+ merchantImageUrl: 'https://www.buckaroo.nl/Themes/Buckaroo/Content/images/logo.png'
+};
diff --git a/tests/PaymentMethods/AfterPay.test.ts b/tests/PaymentMethods/AfterPay.test.ts
index 3e24a537..fc826fe8 100644
--- a/tests/PaymentMethods/AfterPay.test.ts
+++ b/tests/PaymentMethods/AfterPay.test.ts
@@ -1,126 +1,94 @@
-import Afterpay from '../../src/PaymentMethods/Afterpay/index'
-import { IPay } from '../../src/PaymentMethods/Afterpay/Model/Pay'
-import { RefundPayload } from '../../src/Models/ITransaction'
-import RecipientCategory from '../../src/Constants/RecipientCategory'
-require('../BuckarooClient.test')
+import buckarooClientTest from '../BuckarooClient.test';
+import { IPay } from '../../src/PaymentMethods/Afterpay/Model/Pay';
+import { getIPAddress, RecipientCategory, uniqid } from '../../src';
-const method = new Afterpay()
-describe('AfterPay methods', () => {
+const paymentPayload: IPay = {
+ invoice: uniqid(),
+ clientIP: getIPAddress(),
+ amountDebit: 100,
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '01-01-1990',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ email: 'test@buckaroo.nl',
+ phone: {
+ mobile: '0612345678',
+ landline: '0201234567',
+ },
+ },
+ articles: [
+ {
+ vatPercentage: 21,
+ price: 10,
+ description: 'Test',
+ quantity: 4,
+ identifier: 'test',
+ },
+ ],
+};
- test('Pay', async () => {
- await method.pay(payload).then((data) => {
- expect(data.isSuccess()).toBeTruthy()
- })
- })
+const method = buckarooClientTest.method('afterpay');
+describe('AfterPay methods', () => {
+ test('Pay', () => {
+ return method
+ .pay(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
- await method.refund({ ...refundPayload }).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await method
+ .refund({
+ invoice: paymentPayload.invoice, //Set invoice number of the transaction to refund
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', //Set transaction key of the transaction to refund
+ amountCredit: paymentPayload.amountDebit,
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeDefined();
+ });
+ });
test('Authorize', async () => {
- await method.authorize(payload).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await method
+ .authorize(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
test('CancelAuthorize', async () => {
- await method.cancelAuthorize(refundPayload).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await method
+ .cancelAuthorize({
+ invoice: paymentPayload.invoice,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: 100,
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
test('Capture', async () => {
await method
.capture({
- amountDebit: 4,
- invoice: '123456789',
- originalTransactionKey: '123456789'
+ ...paymentPayload,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('PayRemainder', async () => {
- await method.payRemainder(payload).then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('AuthorizeRemainder', async () => {
- await method.authorizeRemainder(payload).then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
-
-let refundPayload: RefundPayload = {
- amountCredit: 14,
- originalTransactionKey: '123456789'
-}
-
-let payload: IPay = {
- amountDebit: 14,
- clientIP: '127.0.0.1',
-
- shippingCustomer: {
- city: 'rew',
- country: 'NL',
- street: 'fsd',
- streetNumber: '423',
- streetNumberAdditional: 'ewr',
- postalCode: '1234AB',
- email: 'example@hotmail.com',
- phone: '+31201234567',
- mobilePhone: '+31612345678',
- birthDate: '1999-11-21',
- careOf: '',
- category: RecipientCategory.PERSON,
- conversationLanguage: 'NL',
- customerNumber: 'a',
- firstName: 'a',
- identificationNumber: '675',
- lastName: 'a',
- salutation: 'Mr'
- },
- billingCustomer: {
- city: 'rew',
- country: 'NL',
- street: 'fsd',
- streetNumber: '423',
- streetNumberAdditional: 'ewr',
- postalCode: '1234AB',
- email: 'example@hotmail.com',
- phone: '+31201234567',
- mobilePhone: '+31612345678',
- birthDate: '1999-11-21',
- careOf: '',
- category: RecipientCategory.PERSON,
- conversationLanguage: 'NL',
- customerNumber: 'a',
- firstName: 'a',
- identificationNumber: '675',
- lastName: 'a',
- salutation: 'Mr'
- },
- article: [
- {
- description: 'ter',
- identifier: '423f',
- imageUrl: '',
- quantity: 1,
- type: 'PhysicalArticle',
- unitCode: '',
- url: '',
- vatPercentage: 0,
- grossUnitPrice: 7
-
- },
- {
- description: 'ter',
- identifier: '423f',
- unitCode: '',
- type: 'PhysicalArticle',
- quantity: 1,
- vatPercentage: 0,
- grossUnitPrice: 7
- }
- ]
-}
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/AfterPayDigiAccept.test.js b/tests/PaymentMethods/AfterPayDigiAccept.test.js
new file mode 100644
index 00000000..c415788a
--- /dev/null
+++ b/tests/PaymentMethods/AfterPayDigiAccept.test.js
@@ -0,0 +1,114 @@
+import { RequestTypes } from '../../src/Constants/Endpoints';
+import { TestBilling } from '../Models';
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+import Gender from '../../src/Constants/Gender';
+const method = buckarooClientTest.method('afterpaydigiaccept');
+describe('AfterPayDigiAccept methods', () => {
+ test('Authorize', async () => {
+ await method
+ .authorize({
+ amountDebit: 0,
+ articles: [],
+ bankAccount: '',
+ bankCode: '',
+ billing: TestBilling,
+ clientIP: '',
+ merchantImageUrl: '',
+ ourReference: '',
+ summaryImageUrl: '',
+ yourReference: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Pay', async () => {
+ await method
+ .pay({ ...paymentPayload, clientIP: '127.0.0.1' })
+ .request()
+ .then((data) => {
+ expect(data.data).toBeDefined();
+ });
+ });
+ test('Specification', async () => {
+ await method
+ .specification(RequestTypes.Transaction)
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
+const paymentPayload = {
+ amountDebit: 40.5,
+ b2b: true,
+ addressesDiffer: true,
+ customerIPAddress: '0.0.0.0',
+ shippingCosts: 0.5,
+ costCentre: 'Test',
+ department: 'Test',
+ establishmentNumber: 123456,
+ billing: {
+ recipient: {
+ gender: Gender.FEMALE,
+ initials: 'AB',
+ lastName: 'Do',
+ birthDate: '1990-01-01',
+ culture: 'NL'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'a',
+ zipcode: '1234AB',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0698765433'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ shipping: {
+ recipient: {
+ culture: 'NL',
+ gender: Gender.MALE,
+ initials: 'YJ',
+ lastName: 'Jansen',
+ companyName: 'Buckaroo B.V.',
+ birthDate: '1990-01-01',
+ chamberOfCommerce: '12345678',
+ vatNumber: 'NL12345678'
+ },
+ address: {
+ street: 'Kalverstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'b',
+ zipcode: '4321EB',
+ city: 'Amsterdam',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0698765433'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ articles: [
+ {
+ identifier: uniqid(),
+ description: 'Blue Toy Car',
+ price: 10.0,
+ quantity: 2,
+ vatCategory: '1'
+ },
+ {
+ identifier: uniqid(),
+ description: 'Red Toy Car',
+ price: 10.0,
+ quantity: 2,
+ vatCategory: '1'
+ }
+ ]
+};
diff --git a/tests/PaymentMethods/AfterPayDigiAccept.test.ts b/tests/PaymentMethods/AfterPayDigiAccept.test.ts
index 197fe5ce..09eccb13 100644
--- a/tests/PaymentMethods/AfterPayDigiAccept.test.ts
+++ b/tests/PaymentMethods/AfterPayDigiAccept.test.ts
@@ -1,27 +1,105 @@
-require('../BuckarooClient.test')
-import AfterPayDigiAccept from '../../src/PaymentMethods/AfterpayDigiAccept'
+import { Gender, getIPAddress, RequestTypes, uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
+import { IPay } from '../../src/PaymentMethods/AfterpayDigiAccept/Model/Pay';
-const method = new AfterPayDigiAccept()
+const method = buckarooClientTest.method('afterpaydigiaccept');
+const paymentPayload: IPay = {
+ amountDebit: 100,
+ order: uniqid(),
+ invoice: uniqid(),
+ b2b: true,
+ addressesDiffer: true,
+ customerIPAddress: getIPAddress(),
+ shippingCosts: 0.5,
+ costCentre: 'Test',
+ department: 'Test',
+ establishmentNumber: 123456,
+ billing: {
+ recipient: {
+ gender: Gender.FEMALE,
+ initials: 'AB',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ culture: 'NL',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ shipping: {
+ recipient: {
+ culture: 'NL',
+ gender: Gender.MALE,
+ initials: 'TA',
+ lastName: 'Acceptatie',
+ companyName: 'Buckaroo B.V.',
+ chamberOfCommerce: 'XXXXXX41',
+ birthDate: '1990-01-01',
+ vatNumber: 'NLXXXXXXXXXXB01',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ articles: [
+ {
+ identifier: uniqid(),
+ description: 'Blue Toy Car',
+ price: 10.0,
+ quantity: 2,
+ vatCategory: '1',
+ },
+ {
+ identifier: uniqid(),
+ description: 'Red Toy Car',
+ price: 10.0,
+ quantity: 2,
+ vatCategory: '1',
+ },
+ ],
+};
describe('AfterPayDigiAccept methods', () => {
test('Authorize', async () => {
await method
- .authorize({
- amountDebit: 14,
- clientIP: '127.0.0.1'
- })
+ .authorize(paymentPayload)
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('Pay', async () => {
await method
- .pay({
- amountDebit: 14,
- clientIP: '127.0.0.1'
- })
+ .pay(paymentPayload)
+ .request()
.then((data) => {
- expect(data.data).toBeDefined()
- })
- })
-})
+ expect(data.data).toBeDefined();
+ });
+ });
+ test('Specification', async () => {
+ await method
+ .specification(RequestTypes.Transaction)
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
\ No newline at end of file
diff --git a/tests/PaymentMethods/Alipay.test.js b/tests/PaymentMethods/Alipay.test.js
new file mode 100644
index 00000000..21b692b1
--- /dev/null
+++ b/tests/PaymentMethods/Alipay.test.js
@@ -0,0 +1,26 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const alipay = buckarooClientTest.method('alipay');
+describe('Alipay methods', () => {
+ test('Pay Simple Payload', async () => {
+ await alipay
+ .pay({
+ amountDebit: 10,
+ useMobileView: false
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await alipay
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: 'F397777A251645F8BDD81547B5005B4B'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Alipay.test.ts b/tests/PaymentMethods/Alipay.test.ts
index c7263d0f..7a1ae36e 100644
--- a/tests/PaymentMethods/Alipay.test.ts
+++ b/tests/PaymentMethods/Alipay.test.ts
@@ -1,32 +1,30 @@
-require('../BuckarooClient.test')
-import Alipay from '../../src/PaymentMethods/Alipay'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new Alipay()
+const alipay = buckarooClientTest.method('alipay');
describe('Alipay methods', () => {
test('Pay Simple Payload', async () => {
- await method
+ await alipay
.pay({
- amountDebit: 10,
- useMobileView: false
+ amountDebit: 100,
+ useMobileView: false,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
- await method
+ await alipay
.refund({
- amountCredit: 5,
- originalTransactionKey: 'F397777A251645F8BDD81547B5005B4B'
+ amountCredit: 0.01,
+ invoice: uniqid(),
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Specifications', async () => {
- await method.specification().then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/ApplePay.test.js b/tests/PaymentMethods/ApplePay.test.js
new file mode 100644
index 00000000..20566d83
--- /dev/null
+++ b/tests/PaymentMethods/ApplePay.test.js
@@ -0,0 +1,50 @@
+import { uniqid } from '../../src/Utils/Functions';
+require('../BuckarooClient.test');
+import ApplePay from '../../src/PaymentMethods/ApplePay';
+const method = new ApplePay();
+describe('Applepay methods', () => {
+ test('Pay Simple Payload', async () => {
+ await method
+ .pay({
+ amountDebit: 10,
+ paymentData: 'sad',
+ customerCardName: '87y7y8'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Pay Redirect Payload', async () => {
+ await method
+ .payRedirect({
+ amountDebit: 10,
+ invoice: uniqid(),
+ servicesSelectableByClient: 'applepay',
+ continueOnIncomplete: true
+ })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Specifications', async () => {
+ await method
+ .specification()
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/ApplePay.test.ts b/tests/PaymentMethods/ApplePay.test.ts
index 7e4b201d..aad65bfe 100644
--- a/tests/PaymentMethods/ApplePay.test.ts
+++ b/tests/PaymentMethods/ApplePay.test.ts
@@ -1,34 +1,45 @@
-require('../BuckarooClient.test')
-import ApplePay from '../../src/PaymentMethods/ApplePay/index'
+import { uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
-const method = new ApplePay()
+const method = buckarooClientTest.method('applepay');
describe('Applepay methods', () => {
- test('Pay Simple Payload', async () => {
+ test('Pay', async () => {
await method
.pay({
- amountDebit: 10,
- paymentData: 'sad',
- customerCardName: '87y7y8'
+ amountDebit: 100,
+ invoice: uniqid(),
+ paymentData: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ customerCardName: 'XXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
-
+ expect(data).toBeDefined();
+ });
+ });
+ test('Pay Redirect Payload', async () => {
+ await method
+ .payRedirect({
+ amountDebit: 100,
+ invoice: uniqid(),
+ servicesSelectableByClient: 'applepay',
+ continueOnIncomplete: true,
})
- })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 5,
- originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Specifications', async () => {
- await method.specification().then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Bancontact.test.js b/tests/PaymentMethods/Bancontact.test.js
new file mode 100644
index 00000000..c617fed3
--- /dev/null
+++ b/tests/PaymentMethods/Bancontact.test.js
@@ -0,0 +1,86 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('bancontactmrcash');
+describe('BanContact methods', () => {
+ test('Pay Simple Payload', async () => {
+ await method
+ .pay({
+ amountDebit: 10,
+ saveToken: true
+ })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authenticate', async () => {
+ await method
+ .authenticate({ amountDebit: 10 })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeDefined();
+ });
+ });
+ test('PayOneClick', async () => {
+ await method
+ .payOneClick({
+ originalTransactionKey: 'dsad',
+ amountDebit: 12
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('CompletePayment', async () => {
+ await method
+ .completePayment({
+ originalTransactionKey: 'dsad',
+ encryptedCardData: 'sUIB'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('PayEncrypted', async () => {
+ await method
+ .payEncrypted({
+ amountDebit: 10,
+ encryptedCardData: 'yrtgdd'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('PayRecurring', async () => {
+ await method
+ .payRecurring({
+ amountDebit: 10,
+ originalTransactionKey: 'sadas'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Specifications', () => {
+ method
+ .specification()
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Bancontact.test.ts b/tests/PaymentMethods/Bancontact.test.ts
index f22a546a..f75357ec 100644
--- a/tests/PaymentMethods/Bancontact.test.ts
+++ b/tests/PaymentMethods/Bancontact.test.ts
@@ -1,86 +1,85 @@
-require('../BuckarooClient.test')
-import BanContact from '../../src/PaymentMethods/Bancontact/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new BanContact()
+const method = buckarooClientTest.method('bancontactmrcash');
describe('BanContact methods', () => {
test('Pay Simple Payload', async () => {
await method
.pay({
- amountDebit: 10,
- saveToken: true
+ amountDebit: 100,
+ saveToken: true,
})
+ .request()
.then((data) => {
- expect(data.isWaitingOnUserInput()).toBeTruthy()
- })
- })
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 5,
- originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Authorize', async () => {
- await method.authorize({ amountDebit: 10 }).then((data) => {
- expect(data.isWaitingOnUserInput()).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authenticate', async () => {
+ await method
+ .authenticate({ invoice: uniqid(), amountDebit: 100 })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeDefined();
+ });
+ });
test('PayOneClick', async () => {
await method
.payOneClick({
- originalTransactionKey: 'dsad',
- amountDebit: 12
+ invoice: uniqid(),
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountDebit: 100,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('CompletePayment', async () => {
await method
.completePayment({
- originalTransactionKey: 'dsad',
- encryptedCardData: 'sUIB'
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ encryptedCardData: 'XXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('PayEncrypted', async () => {
await method
.payEncrypted({
- amountDebit: 10,
- encryptedCardData: 'yrtgdd'
+ invoice: uniqid(),
+ amountDebit: 100,
+ encryptedCardData: 'XXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('PayRecurring', async () => {
await method
.payRecurring({
- amountDebit: 10,
- originalTransactionKey: 'sadas'
+ invoice: uniqid(),
+ amountDebit: 100,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Specifications', async () => {
- await method.specification().then((data) => {
- expect(data).toBeDefined()
- })
- })
-
- test('Capture', async () => {
- await method.capture({
- originalTransactionKey: 'sadas',
- amountDebit: 10
- }).then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/BankTransfer.test.js b/tests/PaymentMethods/BankTransfer.test.js
new file mode 100644
index 00000000..599c31d4
--- /dev/null
+++ b/tests/PaymentMethods/BankTransfer.test.js
@@ -0,0 +1,23 @@
+import Gender from '../../src/Constants/Gender';
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('transfer');
+describe('Transfer methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 10,
+ customer: {
+ firstName: 'John',
+ lastName: 'Doe',
+ gender: Gender.MALE
+ },
+ email: 'test@hotmail.com',
+ sendMail: true,
+ dateDue: '2024-10-10'
+ })
+ .request()
+ .then((res) => {
+ expect(res.isAwaitingConsumer()).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/BankTransfer.test.ts b/tests/PaymentMethods/BankTransfer.test.ts
index 02449f3f..cb0c00e4 100644
--- a/tests/PaymentMethods/BankTransfer.test.ts
+++ b/tests/PaymentMethods/BankTransfer.test.ts
@@ -1,31 +1,25 @@
-import BankTransfer from '../../src/PaymentMethods/BankTransfer'
-import Gender from '../../src/Constants/Gender'
+import { Gender } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
-require('../BuckarooClient.test')
-
-const method = new BankTransfer()
+const method = buckarooClientTest.method('transfer');
describe('Transfer methods', () => {
- test('Specification', async () => {
- await method.specification().then((res) => {
- expect(res).toBeDefined()
- })
- })
test('Pay', async () => {
await method
.pay({
- amountDebit: 10,
- customerCountry: 'NL',
- customerEmail: 'test@hotmail.com',
- customerFirstName: 'test',
- customerGender: Gender.FEMALE,
- customerLastName: 'Test',
- description: 'Test without payment method with ServicesSelectableByClient',
- continueOnIncomplete: 1,
- servicesSelectableByClient: 'ideal,creditcard'
+ amountDebit: 100,
+ customer: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ gender: Gender.MALE,
+ },
+ email: 'test@buckaroo.nl',
+ sendMail: true,
+ dateDue: '2024-10-10',
})
+ .request()
.then((res) => {
- expect(res.isAwaitingConsumer()).toBeDefined()
- })
- })
-})
+ expect(res.isAwaitingConsumer()).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Belfius.test.js b/tests/PaymentMethods/Belfius.test.js
new file mode 100644
index 00000000..83ddc881
--- /dev/null
+++ b/tests/PaymentMethods/Belfius.test.js
@@ -0,0 +1,33 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('belfius');
+describe('testing methods', () => {
+ test('Pay Simple Payload', async () => {
+ await method
+ .pay({
+ amountDebit: 10
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: '86CFE2CB5901463EADE061633BDB9EC8'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Specifications', async () => {
+ await method
+ .specification()
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Belfius.test.ts b/tests/PaymentMethods/Belfius.test.ts
index cc70c3a6..ed27185f 100644
--- a/tests/PaymentMethods/Belfius.test.ts
+++ b/tests/PaymentMethods/Belfius.test.ts
@@ -1,31 +1,29 @@
-require('../BuckarooClient.test')
-import Belfius from '../../src/PaymentMethods/Belfius/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new Belfius()
+const method = buckarooClientTest.method('belfius');
describe('testing methods', () => {
test('Pay Simple Payload', async () => {
await method
.pay({
- amountDebit: 10
+ amountDebit: 100,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 5,
- originalTransactionKey: '86CFE2CB5901463EADE061633BDB9EC8'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Specifications', async () => {
- await method.specification().then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Billink.test.js b/tests/PaymentMethods/Billink.test.js
new file mode 100644
index 00000000..4cdeae3d
--- /dev/null
+++ b/tests/PaymentMethods/Billink.test.js
@@ -0,0 +1,127 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+require('../BuckarooClient.test');
+const method = buckarooClientTest.method('billink');
+describe('Billink methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay(payload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 12,
+ originalTransactionKey: 'ytgty'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authorize', async () => {
+ await method
+ .authorize(payload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('CancelAuthorize', async () => {
+ await method
+ .cancelAuthorize({
+ originalTransactionKey: 'ytgty',
+ amountCredit: 10,
+ invoice: 'sdsa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Capture', async () => {
+ await method
+ .capture({
+ originalTransactionKey: 'ytgty',
+ invoice: "'dsa",
+ amountDebit: 123,
+ articles: payload.articles
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
+const payload = {
+ amountDebit: 50.3,
+ order: '',
+ invoice: '',
+ trackAndTrace: 'TR0F123456789',
+ vATNumber: '2',
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'John Smith',
+ title: 'Female',
+ initials: 'JD',
+ firstName: 'John',
+ lastName: 'Do',
+ birthDate: '01-01-1990',
+ chamberOfCommerce: 'TEST'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'a',
+ zipcode: '1234AB',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0698765433',
+ landline: '0109876543'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'John Smith',
+ title: 'Male',
+ initials: 'JD',
+ firstName: 'John',
+ lastName: 'Do',
+ birthDate: '1990-01-01'
+ },
+ address: {
+ street: 'Kalverstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'b',
+ zipcode: '4321EB',
+ city: 'Amsterdam',
+ country: 'NL'
+ }
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1,
+ priceExcl: 5
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1,
+ priceExcl: 5
+ }
+ ]
+};
diff --git a/tests/PaymentMethods/Billink.test.ts b/tests/PaymentMethods/Billink.test.ts
index b1d92cda..5f61a317 100644
--- a/tests/PaymentMethods/Billink.test.ts
+++ b/tests/PaymentMethods/Billink.test.ts
@@ -1,96 +1,131 @@
-import Billink from '../../src/PaymentMethods/Billink/index'
-import { IPay } from '../../src/PaymentMethods/Billink/Models/Pay'
+import { IPay } from '../../src/PaymentMethods/Billink/Models/Pay';
+import buckarooClientTest from '../BuckarooClient.test';
+import { RecipientCategory, uniqid } from '../../src';
-require('../BuckarooClient.test')
-
-const method = new Billink()
+const method = buckarooClientTest.method('billink');
describe('Billink methods', () => {
- test('Specifications', async () => {
- await method.specification().then((data) => {
- data.getActionRequestParameters('Pay')
- expect(data).toBeDefined()
- })
- })
+ const invoiceId = uniqid();
+
test('Pay', async () => {
- await method.pay(payload).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await method
+ .pay(payload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 12,
- originalTransactionKey: 'ytgty'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('Authorize', async () => {
- await method.authorize(payload).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await method
+ .authorize({ ...payload, invoice: invoiceId })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
test('CancelAuthorize', async () => {
await method
.cancelAuthorize({
- originalTransactionKey: 'ytgty',
- amountCredit: 10,
- invoice: 'sdsa'
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: payload.amountDebit,
+ invoice: invoiceId,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('Capture', async () => {
await method
.capture({
- originalTransactionKey: 'ytgty',
- invoice: "'dsa",
- amountDebit: 123
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ invoice: invoiceId,
+ amountDebit: payload.amountDebit,
+ articles: payload.articles,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data).toBeDefined();
+ });
+ });
+});
-let payload: IPay = {
- VATNumber: '',
- additionalParameters: undefined,
- amountDebit: 0,
- article: [],
- billingCustomer: {
- chamberOfCommerce: '',
- city: '',
- firstName: '',
- initials: '',
- lastName: '',
- postalCode: '',
- street: '',
- streetNumber: 0
+const payload: IPay = {
+ amountDebit: 100,
+ trackAndTrace: 'XXXXXXXXXXXXX',
+ vatNumber: 'NLXXXXXXXXXXB01',
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'Test Acceptatie',
+ title: 'Female',
+ initials: 'TA',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '01-01-1990',
+ chamberOfCommerce: 'XXXXXX41',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ landline: '0201234567',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'Test Acceptatie',
+ title: 'Male',
+ initials: 'TA',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
},
- clientIP: undefined,
- continueOnIncomplete: 1,
- culture: '',
- currency: '',
- customParameters: undefined,
- description: '',
- invoice: '',
- order: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- shippingCustomer: undefined,
- startRecurrent: false,
- summaryImageUrl: '',
- trackandtrace: ''
-}
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1,
+ priceExcl: 5,
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1,
+ priceExcl: 5,
+ },
+ ],
+};
diff --git a/tests/PaymentMethods/BuckarooVoucher.test.js b/tests/PaymentMethods/BuckarooVoucher.test.js
new file mode 100644
index 00000000..40986071
--- /dev/null
+++ b/tests/PaymentMethods/BuckarooVoucher.test.js
@@ -0,0 +1,59 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('buckaroovoucher');
+describe('testing methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 12,
+ voucherCode: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 12,
+ originalTransactionKey: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('GetBalance', async () => {
+ await method
+ .getBalance({
+ voucherCode: 'WP6W-XXXX-XXXX-56T7'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('CreateApplication', async () => {
+ await method
+ .create({
+ creationBalance: 12,
+ usageType: 1,
+ validFrom: '2021-01-01',
+ validUntil: '2024-01-01'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('DeactivateVoucher', async () => {
+ await method
+ .deactivate({
+ voucherCode: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/BuckarooVoucher.test.ts b/tests/PaymentMethods/BuckarooVoucher.test.ts
index d7be1ad4..25857c12 100644
--- a/tests/PaymentMethods/BuckarooVoucher.test.ts
+++ b/tests/PaymentMethods/BuckarooVoucher.test.ts
@@ -1,57 +1,63 @@
-require('../BuckarooClient.test')
-import BuckarooVoucher from '../../src/PaymentMethods/BuckarooVoucher/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new BuckarooVoucher()
+const method = buckarooClientTest.method('buckaroovoucher');
describe('testing methods', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 12,
- voucherCode: ''
+ amountDebit: 100,
+ voucherCode: 'XXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 12,
- originalTransactionKey: ''
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('GetBalance', async () => {
await method
.getBalance({
- voucherCode: ''
+ voucherCode: 'XXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
test('CreateApplication', async () => {
await method
- .createApplication({
+ .create({
creationBalance: 12,
usageType: 1,
validFrom: '2021-01-01',
- validUntil: '2024-01-01'
+ validUntil: '2024-01-01',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data).toBeDefined();
+ });
+ });
test('DeactivateVoucher', async () => {
await method
- .deactivateVoucher({
- voucherCode: ''
+ .deactivate({
+ voucherCode: 'XXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/BuckarooWallet.test.js b/tests/PaymentMethods/BuckarooWallet.test.js
new file mode 100644
index 00000000..209621b7
--- /dev/null
+++ b/tests/PaymentMethods/BuckarooWallet.test.js
@@ -0,0 +1,115 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+const method = buckarooClientTest.method('BuckarooWalletCollecting');
+describe('BuckarooWallet methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ invoice: 'string',
+ amountDebit: 12,
+ walletId: '2'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ invoice: 'string',
+ amountCredit: 12,
+ originalTransactionKey: '46FB241693914AA4AE7A8B6DB33DE'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('CancelReservation', async () => {
+ await method
+ .cancel({
+ invoice: 'BuckarooWalletInvoiceId',
+ originalTransactionKey: '46FB241693914AA4AE7A8B6DB33DE',
+ amountDebit: 1,
+ walletMutationGuid: '49B018248ECE4346AC20B902'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('deposit', async () => {
+ await method
+ .deposit({
+ invoice: 'string',
+ walletId: '',
+ amountCredit: 12,
+ originalTransactionKey: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Update', async () => {
+ await method
+ .update({
+ walletId: '10',
+ status: 'Disabled',
+ email: 'test@buckaroo.nl',
+ customer: {
+ firstName: 'John',
+ lastName: 'string'
+ },
+ bankAccount: {
+ iban: 'NL13TEST0123456789'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Withdrawal', async () => {
+ await method
+ .withdrawal({
+ invoice: 'BuckarooWalletInvoiceId',
+ walletId: '10',
+ amountDebit: 10,
+ originalTransactionKey: '46FB241693914AA4AE7A8B6DB33DE'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('Create Wallet', async () => {
+ await method
+ .create({
+ walletId: uniqid(),
+ email: 'test@buckaroo.nl',
+ customer: {
+ firstName: 'John',
+ lastName: 'string'
+ },
+ bankAccount: {
+ iban: 'NL13TEST0123456789'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('GetInfo', async () => {
+ await method
+ .getInfo({
+ walletId: '10'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/BuckarooWallet.test.ts b/tests/PaymentMethods/BuckarooWallet.test.ts
index fff1a12d..2f3bffa7 100644
--- a/tests/PaymentMethods/BuckarooWallet.test.ts
+++ b/tests/PaymentMethods/BuckarooWallet.test.ts
@@ -1,75 +1,117 @@
-require('../BuckarooClient.test')
-import BuckarooWallet from '../../src/PaymentMethods/BuckarooWallet/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new BuckarooWallet()
+const method = buckarooClientTest.method('BuckarooWalletCollecting');
describe('BuckarooWallet methods', () => {
test('Pay', async () => {
await method
.pay({
- invoice: 'string',
- amountDebit: 12,
- walletId: '2'
+ invoice: uniqid(),
+ amountDebit: 100,
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- invoice: 'string',
- walletId: '2',
- amountCredit: 12,
- originalTransactionKey: ''
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
test('CancelReservation', async () => {
await method
.cancel({
- invoice: 'dsadsadsa',
- walletMutationGuid: '2'
+ invoice: uniqid(),
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountDebit: 100,
+ walletMutationGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('deposit', async () => {
await method
.deposit({
- invoice: 'string',
- walletId: '',
- amountCredit: 12,
- originalTransactionKey: ''
+ invoice: uniqid(),
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: 100,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
+ expect(data).toBeDefined();
+ });
+ });
+ test('Update', async () => {
+ await method
+ .update({
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
+ status: 'Disabled',
+ email: 'test@buckaroo.nl',
+ customer: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
+ bankAccount: {
+ iban: 'NLXXTESTXXXXXXXXXX',
+ },
})
- })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
test('Withdrawal', async () => {
await method
.withdrawal({
- invoice: 'dasd',
- walletId: '654dfcvb',
- amountDebit: 10,
- originalTransactionKey: ''
+ invoice: uniqid(),
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
+ amountDebit: 100,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('Create Wallet', async () => {
await method
.create({
- invoice: '',
- pushURL: '',
- walletId: ''
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
+ email: 'test@buckaroo.nl',
+ customer: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
+ bankAccount: {
+ iban: 'NLXXTESTXXXXXXXXXX',
+ },
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('GetInfo', async () => {
+ await method
+ .getInfo({
+ walletId: 'XXXXXXXXXXXXXXXXXXXXX',
})
- })
-})
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Client.test.ts b/tests/PaymentMethods/Client.test.ts
deleted file mode 100644
index a849f32a..00000000
--- a/tests/PaymentMethods/Client.test.ts
+++ /dev/null
@@ -1,52 +0,0 @@
-import { uniqid } from '../../src/Utils/Functions'
-
-require('../BuckarooClient.test')
-import buckarooClient from '../../src/BuckarooClient'
-
-const client = buckarooClient()
-test('PaymentStatus', async () => {
- await client.status('0AA966B997CB4676B55A07E9C3BA4DB4').then((data) => {
- expect(data).toBeDefined()
- })
-})
-test('paymentCancelInfo', async () => {
- await client.cancelInfo('73902D944DC848CBADC49D9B8A8C2F16').then((data) => {
- expect(data).toBeDefined()
- })
-})
-test('paymentRefundInfo', async () => {
- await client.refundInfo('73902D944DC848CBADC49D9B8A8C2F16').then((data) => {
- expect(data).toBeDefined()
- })
-})
-
-test('paymentInvoiceInfo', async () => {
- await client.invoiceInfo('5f5701d44aac88').then((data) => {
- expect(data).toBeDefined()
- })
-})
-
-test('Service specifications', async () => {
- let specifications = await client.specifications([
- {
- paymentName: 'ideal',
- serviceVersion: 1
- }
- ])
- expect(specifications).toBeDefined()
-})
-test('Client Transaction Request', async () => {
- let specifications = await client.transactionRequest({
- invoice: uniqid(''),
- order: uniqid(''),
- currency: 'EUR',
- amountDebit: 0.01,
- pushURL: 'http://testcheckout.buckaroo.nl/push',
- description: 'Test without payment method with ServicesSelectableByClient',
- continueOnIncomplete: 1,
- servicesSelectableByClient: 'ideal,paypal,bancontactmrcash',
- servicesExcludedForClient: 'ideal'
- })
-
- expect(specifications).toBeDefined()
-})
diff --git a/tests/PaymentMethods/CreditCard.test.js b/tests/PaymentMethods/CreditCard.test.js
new file mode 100644
index 00000000..82c261ff
--- /dev/null
+++ b/tests/PaymentMethods/CreditCard.test.js
@@ -0,0 +1,119 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('visa');
+describe('testing methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 10
+ })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authorize', async () => {
+ await method
+ .authorize({
+ amountDebit: 10
+ })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('PayEncrypted', async () => {
+ await method
+ .payEncrypted({
+ amountDebit: 10,
+ name: 'Visa',
+ encryptedCardData: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('PayWithSecurityCode', async () => {
+ await method
+ .payWithSecurityCode({
+ amountDebit: 10,
+ encryptedSecurityCode: 'sad',
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('AuthorizeWithSecurityCode', async () => {
+ await method
+ .authorizeWithSecurityCode({
+ amountDebit: 10,
+ encryptedSecurityCode: 'sad',
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('AuthorizeEncrypted', async () => {
+ await method
+ .authorizeEncrypted({
+ amountDebit: 10,
+ encryptedCardData: 'sad',
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('CancelAuthorize', async () => {
+ await method
+ .cancelAuthorize({
+ originalTransactionKey: 'sad',
+ amountCredit: 10,
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Capture', async () => {
+ await method
+ .capture({
+ originalTransactionKey: 'sad',
+ amountDebit: 10,
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('PayRecurrent', async () => {
+ await method
+ .payRecurrent({
+ originalTransactionKey: 'sad',
+ amountDebit: 10,
+ name: 'Visa'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/CreditCard.test.ts b/tests/PaymentMethods/CreditCard.test.ts
index c38f16cc..848241aa 100644
--- a/tests/PaymentMethods/CreditCard.test.ts
+++ b/tests/PaymentMethods/CreditCard.test.ts
@@ -1,115 +1,123 @@
-require('../BuckarooClient.test')
-import CreditCard from '../../src/PaymentMethods/CreditCard/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new CreditCard()
+const method = buckarooClientTest.method('visa');
describe('testing methods', () => {
- test('Pay', async () => {
- await method
+ test('Pay', async () => {
+ await method
.pay({
- amountDebit: 10,
- name: 'Visa'
+ amountDebit: 100,
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
- })
- test('Refund', async () => {
- await method
- .refund({
- amountCredit: 5,
- name: 'Visa',
- originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Authorize', async () => {
- await method
- .authorize({
- amountDebit: 10,
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('PayEncrypted', async () => {
- await method
- .payEncrypted({
- amountDebit: 10,
- name: 'Visa',
- encryptedCardData: ''
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('PayWithSecurityCode', async () => {
- await method
- .payWithSecurityCode({
- amountDebit: 10,
- encryptedSecurityCode: 'sad',
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('AuthorizeWithSecurityCode', async () => {
- await method
- .authorizeWithSecurityCode({
- amountDebit: 10,
- encryptedSecurityCode: 'sad',
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('AuthorizeEncrypted', async () => {
- await method
- .authorizeEncrypted({
- amountDebit: 10,
- encryptedCardData: 'sad',
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('CancelAuthorize', async () => {
- await method
- .cancelAuthorize({
- originalTransactionKey: 'sad',
- amountCredit: 10,
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Capture', async () => {
- await method
- .capture({
- originalTransactionKey: 'sad',
- amountDebit: 10,
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('PayRecurrent', async () => {
- await method
- .payRecurrent({
- originalTransactionKey: 'sad',
- amountDebit: 10,
- name: 'Visa'
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Authorize', async () => {
+ await method
+ .authorize({
+ amountDebit: 100,
+ })
+ .request()
+ .then((data) => {
+ expect(data.isWaitingOnUserInput()).toBeTruthy();
+ });
+ });
+ test('PayEncrypted', async () => {
+ await method
+ .payEncrypted({
+ amountDebit: 100,
+ name: 'Visa',
+ encryptedCardData: 'XXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('PayWithSecurityCode', async () => {
+ await method
+ .payWithSecurityCode({
+ amountDebit: 100,
+ encryptedSecurityCode: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('AuthorizeWithSecurityCode', async () => {
+ await method
+ .authorizeWithSecurityCode({
+ amountDebit: 100,
+ encryptedSecurityCode: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('AuthorizeEncrypted', async () => {
+ await method
+ .authorizeEncrypted({
+ amountDebit: 100,
+ encryptedCardData: 'XXXXXXXXXXXXXXXXXXXXXXXX',
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('CancelAuthorize', async () => {
+ await method
+ .cancelAuthorize({
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: 100,
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Capture', async () => {
+ await method
+ .capture({
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountDebit: 100,
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('PayRecurrent', async () => {
+ await method
+ .payRecurrent({
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountDebit: 100,
+ name: 'Visa',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/CreditClick.test.js b/tests/PaymentMethods/CreditClick.test.js
new file mode 100644
index 00000000..82994ff4
--- /dev/null
+++ b/tests/PaymentMethods/CreditClick.test.js
@@ -0,0 +1,32 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('creditclick');
+describe('Testing CreditClick methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 31,
+ person: {
+ firstName: 'test',
+ lastName: 'test'
+ },
+ email: 't.tester@test.nl'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 31,
+ originalTransactionKey: 'C85BABFCCA2D4921B9CFBA0EBDF82C70',
+ description: 'test',
+ refundReason: 'Fraudulent'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/CreditClick.test.ts b/tests/PaymentMethods/CreditClick.test.ts
index 5f75fdd4..43711b62 100644
--- a/tests/PaymentMethods/CreditClick.test.ts
+++ b/tests/PaymentMethods/CreditClick.test.ts
@@ -1,28 +1,36 @@
-require('../BuckarooClient.test')
-import CreditClick from '../../src/PaymentMethods/CreditClick/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new CreditClick()
+const method = buckarooClientTest.method('creditclick');
describe('Testing CreditClick methods', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 31
+ amountDebit: 100,
+ person: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
+ email: 'test@buckaroo.nl',
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 31,
- originalTransactionKey: 'C85BABFCCA2D4921B9CFBA0EBDF82C70',
- description: 'test',
- refundReason: 'Fraudulent'
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ invoice: uniqid(),
+ description: 'refund',
+ refundReason: 'Fraudulent',
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
-})
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/CreditManagment.test.js b/tests/PaymentMethods/CreditManagment.test.js
new file mode 100644
index 00000000..86a196ba
--- /dev/null
+++ b/tests/PaymentMethods/CreditManagment.test.js
@@ -0,0 +1,265 @@
+import Gender from '../../src/Constants/Gender';
+import CreditManagementInstallmentInterval from '../../src/Constants/CreditManagementInstallmentInterval';
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+const creditManagement = buckarooClientTest.method('CreditManagement3');
+describe('Testing Credit Management', () => {
+ test('CreateInvoice', async () => {
+ await creditManagement
+ .createInvoice(creditManagementTestInvoice())
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('CreateInvoice With Articles', async () => {
+ await creditManagement
+ .createInvoice(creditManagementTestInvoice({
+ invoice: 'Billingtest101',
+ description: 'buckaroo_schema_test_PDF',
+ invoiceAmount: 217.8,
+ invoiceDate: '2022-01-01',
+ dueDate: '1990-01-01',
+ schemeKey: '2amq34',
+ poNumber: 'PO-12345',
+ debtor: {
+ code: 'johnsmith4'
+ },
+ articles: [
+ {
+ productGroupName: 'Toys',
+ productGroupOrderIndex: 1,
+ productOrderIndex: 1,
+ type: 'Regular',
+ identifier: 'ART12',
+ description: 'Blue Toy Car',
+ quantity: 3,
+ unitOfMeasurement: 'piece(s)',
+ price: 10,
+ discountPercentage: 20,
+ totalDiscount: 6,
+ vatPercentage: 21,
+ totalVat: 0.6,
+ totalAmountExVat: 8.4,
+ totalAmount: 123
+ },
+ {
+ productGroupName: 'Toys',
+ productGroupOrderIndex: 1,
+ productOrderIndex: 2,
+ type: 'Regular',
+ identifier: 'ART12',
+ description: 'Blue Toy Car',
+ quantity: 3,
+ unitOfMeasurement: 'piece(s)',
+ price: 10,
+ discountPercentage: 20,
+ totalDiscount: 6,
+ vatPercentage: 21,
+ totalVat: 0.6,
+ totalAmountExVat: 8.4,
+ totalAmount: 123
+ }
+ ]
+ }))
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('Pause Invoice', async () => {
+ await creditManagement
+ .pauseInvoice({ invoice: 'Testinvoice184915' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('UnPause Invoice', async () => {
+ await creditManagement
+ .unpauseInvoice({ invoice: 'Testinvoice184915' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('Invoice Info', async () => {
+ await creditManagement
+ .invoiceInfo({
+ invoice: 'INV001',
+ invoices: [{ invoiceNumber: 'INV002' }, { invoiceNumber: 'INV003' }]
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('Debtor Info', async () => {
+ await creditManagement
+ .debtorInfo({
+ debtor: {
+ code: 'TestDebtor123123'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('AddOrUpdateProductLines', async () => {
+ await creditManagement
+ .addOrUpdateProductLines({
+ invoiceKey: 'd42',
+ articles: [
+ {
+ type: 'Regular',
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ totalVat: 12,
+ totalAmount: 123,
+ quantity: 2,
+ price: 20.1
+ },
+ {
+ type: 'Regular',
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ totalVat: 12,
+ totalAmount: 123,
+ quantity: 1,
+ price: 10.1
+ }
+ ]
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('resumeDebtorFile', async () => {
+ await creditManagement
+ .resumeDebtorFile({ debtorFileGuid: 'd42' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('pauseDebtorFile', async () => {
+ await creditManagement
+ .pauseDebtorFile({ debtorFileGuid: 'd42' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('addOrUpdateDebtor', async () => {
+ await creditManagement
+ .addOrUpdateDebtor(creditManagementTestInvoice({
+ addressUnreachable: false,
+ emailUnreachable: false,
+ mobileUnreachable: false
+ }))
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('CreateCombinedInvoice', async () => {
+ const combinedInvoice = creditManagement.createCombinedInvoice(creditManagementTestInvoice());
+ buckarooClientTest
+ .method('sepadirectdebit')
+ .combine(combinedInvoice.data)
+ .pay({
+ iban: 'NL39RABO0300065264',
+ bic: 'RABONL2U',
+ mandateReference: 'TestMandateReference',
+ mandateDate: '2020-01-01',
+ collectDate: '2020-07-03',
+ amountDebit: 10.1,
+ customer: {
+ name: 'John Smith'
+ },
+ invoice: uniqid('TestInvoice')
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('CreatePaymentPlan', async () => {
+ await creditManagement
+ .createPaymentPlan({
+ description: 'Payment in two intstallments',
+ includedInvoiceKey: '20D09973FB5C4DBC9A33DB0F4F707xxx',
+ dossierNumber: 'PaymentplanJohnsmith123',
+ installmentCount: 2,
+ initialAmount: 100,
+ startDate: '2030-01-01',
+ interval: CreditManagementInstallmentInterval.MONTH,
+ paymentPlanCostAmount: 3.5,
+ paymentPlanCostAmountVat: 1.2,
+ recipientEmail: 'test@buckaroo.nl'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('pauseInvoice', async () => {
+ await creditManagement
+ .pauseInvoice({
+ invoice: 'd42'
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
+export const creditManagementTestInvoice = (append = {}) => {
+ return {
+ applyStartRecurrent: false,
+ invoiceAmount: 10,
+ invoiceAmountVAT: 1,
+ invoiceDate: '2022-01-01',
+ dueDate: '2030-01-01',
+ schemeKey: '2amq34',
+ maxStepIndex: 1,
+ allowedServices: 'ideal,mastercard',
+ debtor: {
+ code: 'johnsmith4'
+ },
+ email: 'youremail@example.nl',
+ phone: {
+ mobile: '06198765432'
+ },
+ person: {
+ culture: 'nl-NL',
+ title: 'Msc',
+ initials: 'JS',
+ firstName: 'Test',
+ lastNamePrefix: 'Jones',
+ lastName: 'Aflever',
+ gender: Gender.MALE
+ },
+ company: {
+ culture: 'nl-NL',
+ name: 'My Company Corporation',
+ vatApplicable: true,
+ vatNumber: 'NL140619562B01',
+ chamberOfCommerce: '20091741'
+ },
+ address: {
+ street: 'Hoofdtraat',
+ houseNumber: '90',
+ houseNumberAdditional: 'A',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ state: 'Friesland',
+ country: 'NL'
+ },
+ ...append
+ };
+};
diff --git a/tests/PaymentMethods/CreditManagment.test.ts b/tests/PaymentMethods/CreditManagment.test.ts
index 0200b350..fb35a65f 100644
--- a/tests/PaymentMethods/CreditManagment.test.ts
+++ b/tests/PaymentMethods/CreditManagment.test.ts
@@ -1,139 +1,247 @@
-require('../BuckarooClient.test')
+import { IInvoice } from '../../src/PaymentMethods/CreditManagement/Models/Invoice';
+import { CreditManagementInstallmentInterval, Gender, uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
-import CreditManagement from '../../src/PaymentMethods/CreditManagement/index'
-import { IInvoice } from '../../src/PaymentMethods/CreditManagement/Models/Invoice'
-import Gender from '../../src/Constants/Gender'
-import Ideal from '../../src/PaymentMethods/Ideal'
-import CreditManagementInstallmentInterval from '../../src/Constants/CreditManagementInstallmentInterval'
-
-const creditManagement = new CreditManagement()
+const creditManagement = buckarooClientTest.method('CreditManagement3');
describe('Testing Credit Management', () => {
test('CreateInvoice', async () => {
- await creditManagement.createInvoice(invoice()).then((data) => {
- expect(data).toBeDefined()
- })
- })
-
+ await creditManagement
+ .createInvoice(creditManagementTestInvoice())
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('CreateInvoice With Articles', async () => {
+ await creditManagement
+ .createInvoice(
+ creditManagementTestInvoice({
+ invoice: uniqid(),
+ description: 'buckaroo_schema_test_PDF',
+ invoiceAmount: 217.8,
+ invoiceDate: '2022-01-01',
+ dueDate: '2024-01-01',
+ schemeKey: 'XXXXXXX',
+ poNumber: 'XX-XXXXX',
+ debtor: {
+ code: 'XXXXXXXX',
+ },
+ articles: [
+ {
+ productGroupName: 'Toys',
+ productGroupOrderIndex: 1,
+ productOrderIndex: 1,
+ type: 'Regular',
+ identifier: 'ART12',
+ description: 'Blue Toy Car',
+ quantity: 3,
+ unitOfMeasurement: 'piece(s)',
+ price: 10,
+ discountPercentage: 20,
+ totalDiscount: 6,
+ vatPercentage: 21,
+ totalVat: 0.6,
+ totalAmountExVat: 8.4,
+ totalAmount: 123,
+ },
+ {
+ productGroupName: 'Toys',
+ productGroupOrderIndex: 1,
+ productOrderIndex: 2,
+ type: 'Regular',
+ identifier: 'ART12',
+ description: 'Blue Toy Car',
+ quantity: 3,
+ unitOfMeasurement: 'piece(s)',
+ price: 10,
+ discountPercentage: 20,
+ totalDiscount: 6,
+ vatPercentage: 21,
+ totalVat: 0.6,
+ totalAmountExVat: 8.4,
+ totalAmount: 123,
+ },
+ ],
+ })
+ )
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('Pause Invoice', async () => {
- await creditManagement.pauseInvoice({ invoice: 'd42' }).then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Debtor Info', async () => {
await creditManagement
- .debtorInfo({
- debtor: {
- code: 'adsad'
- }
- })
+ .pauseInvoice({ invoice: uniqid() })
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('UnPause Invoice', async () => {
+ await creditManagement
+ .unpauseInvoice({ invoice: uniqid() })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('Invoice Info', async () => {
await creditManagement
.invoiceInfo({
- invoice: 'invoice1',
- invoices: [
- {
- invoiceNumber: 'invoice2'
- },
- {
- invoiceNumber: 'invoice3'
- }
- ]
+ invoice: uniqid(),
+ invoices: [{ invoiceNumber: 'INV002' }, { invoiceNumber: 'INV003' }],
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('Debtor Info', async () => {
+ await creditManagement
+ .debtorInfo({
+ debtor: {
+ code: 'XXXXXXXX',
+ },
})
- })
- test('UnPause Invoice', async () => {
- await creditManagement.unpauseInvoice({ invoice: 'd42' }).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
test('AddOrUpdateProductLines', async () => {
await creditManagement
.addOrUpdateProductLines({
- invoiceKey: 'd42',
- article: []
+ invoiceKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ articles: [
+ {
+ type: 'Regular',
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ totalVat: 12,
+ totalAmount: 123,
+ quantity: 2,
+ price: 20.1,
+ },
+ {
+ type: 'Regular',
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ totalVat: 12,
+ totalAmount: 123,
+ quantity: 1,
+ price: 10.1,
+ },
+ ],
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('resumeDebtorFile', async () => {
- await creditManagement.resumeDebtorFile({ debtorFileGuid: 'd42' }).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await creditManagement
+ .resumeDebtorFile({ debtorFileGuid: 'd42' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('pauseDebtorFile', async () => {
- await creditManagement.pauseDebtorFile({ debtorFileGuid: 'd42' }).then((data) => {
- expect(data).toBeDefined()
- })
- })
+ await creditManagement
+ .pauseDebtorFile({ debtorFileGuid: 'd42' })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('addOrUpdateDebtor', async () => {
+ await creditManagement
+ .addOrUpdateDebtor({
+ debtor: {
+ code: 'XXXXXXXX',
+ },
+ person: {
+ culture: 'nl-NL',
+ lastName: 'Acceptatie',
+ },
+ })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
test('CreateCombinedInvoice', async () => {
- const ideal1 = new Ideal()
- const combined = creditManagement.createCombinedInvoice(invoice())
-
- await ideal1.combine(combined).pay({
- amountDebit: 10.1,
- issuer: 'ABNANL2A'
- })
- })
+ const combinedInvoice = creditManagement.createCombinedInvoice(creditManagementTestInvoice());
+ buckarooClientTest
+ .method('sepadirectdebit')
+ .combine(combinedInvoice.data)
+ .pay({
+ iban: 'NLXXTESTXXXXXXXXXX',
+ bic: 'XXXXXXXXX',
+ mandateReference: 'XXXXXXXXXXXXXXX',
+ mandateDate: '2020-01-01',
+ collectDate: '2020-07-03',
+ amountDebit: 100,
+ customer: {
+ name: 'Test Acceptatie',
+ },
+ invoice: uniqid('TestInvoice'),
+ })
+ .request()
+ .then((data) => {
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
test('CreatePaymentPlan', async () => {
await creditManagement
.createPaymentPlan({
- dossierNumber: '',
- includedInvoiceKey: '',
- initialAmount: 0,
- installmentAmount: 0,
- installmentCount: 0,
+ description: 'Payment in two intstallments',
+ includedInvoiceKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ dossierNumber: 'XXXXXXXXXXXXXXXXXXXXXX',
+ installmentCount: 2,
+ initialAmount: 100,
+ startDate: '2030-01-01',
interval: CreditManagementInstallmentInterval.MONTH,
- paymentPlanCostAmount: 0,
- paymentPlanCostAmountVat: 0,
- recipientEmail: '',
- startDate: ''
+ paymentPlanCostAmount: 3.5,
+ paymentPlanCostAmountVat: 1.2,
+ recipientemail: 'test@buckaroo.nl',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
- test('Specifications', async () => {
- //
+ expect(data.isValidationFailure()).toBeTruthy();
+ });
+ });
+ test('pauseInvoice', async () => {
await creditManagement
.pauseInvoice({
- invoice: 'd42'
+ invoice: uniqid(),
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
-
-const invoice = (append: object = {}): IInvoice => {
+ expect(data).toBeDefined();
+ });
+ });
+});
+export const creditManagementTestInvoice = (append: object = {}): IInvoice => {
return {
- code: 'Billingtest101',
- // invoiceNumber: 'd42',
- description: 'buckaroo_schema_test_PDF',
- currency: 'EUR',
+ invoice: uniqid(),
applyStartRecurrent: false,
invoiceAmount: 10,
invoiceAmountVAT: 1,
invoiceDate: '2022-01-01',
dueDate: '2030-01-01',
- schemeKey: 'ezf7xn',
- // maxStepIndex: 1,
+ schemeKey: 'XXXXXX',
+ maxStepIndex: 1,
allowedServices: 'ideal,mastercard',
debtor: {
- code: 'johnsmith4'
+ code: 'XXXXXXXX',
},
- email: { email: 'youremail@example.nl' },
+ email: 'test@buckaroo.nl',
phone: {
- mobile: '06198765432',
- landline: '06198765432',
- fax: '06198765432'
+ mobile: '0612345678',
},
person: {
culture: 'nl-NL',
@@ -141,46 +249,25 @@ const invoice = (append: object = {}): IInvoice => {
initials: 'JS',
firstName: 'Test',
lastNamePrefix: 'Jones',
- lastName: 'Aflever',
+ lastName: 'Acceptatie',
gender: Gender.MALE,
- birthDate: '',
- placeOfBirth: ''
},
company: {
culture: 'nl-NL',
- name: 'My Company Corporation',
+ name: 'Buckaroo B.V.',
vatApplicable: true,
- vatNumber: 'NL140619562B01',
- chamberOfCommerce: ''
+ vatNumber: 'NLXXXXXXXXXXB01',
+ chamberOfCommerce: 'XXXXXX41',
},
address: {
- street: 'Hoofdtraat',
- houseNumber: '90',
- houseNumberSuffix: 'A',
- postalCode: '8441ER',
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
city: 'Heerenveen',
state: 'Friesland',
- country: 'NL'
+ country: 'NL',
},
- productLine: [
- {
- discountPercentage: 0,
- productGroupName: '',
- productGroupOrderIndex: 0,
- productOrderIndex: 0,
- quantity: 0,
- totalAmount: 0,
- totalAmountExVat: 0,
- totalDiscount: 0,
- totalVat: 0,
- type: 'Regular',
- unitOfMeasurement: '',
- vatPercentage: 0,
- pricePerUnit: 0,
- productName: '324'
-
- }
- ],
- ...append
- }
-}
+ ...append,
+ };
+};
diff --git a/tests/PaymentMethods/EPS.test.js b/tests/PaymentMethods/EPS.test.js
new file mode 100644
index 00000000..b8d1c150
--- /dev/null
+++ b/tests/PaymentMethods/EPS.test.js
@@ -0,0 +1,25 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('eps');
+describe('Testing Eps methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 10.1
+ })
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ method
+ .refund({
+ amountCredit: 10.1,
+ originalTransactionKey: '1234567890'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/EPS.test.ts b/tests/PaymentMethods/EPS.test.ts
new file mode 100644
index 00000000..b24d018a
--- /dev/null
+++ b/tests/PaymentMethods/EPS.test.ts
@@ -0,0 +1,28 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+
+const method = buckarooClientTest.method('eps');
+describe('Testing Eps methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 100,
+ })
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ method
+ .refund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Emandate.test.js b/tests/PaymentMethods/Emandate.test.js
new file mode 100644
index 00000000..019ebebc
--- /dev/null
+++ b/tests/PaymentMethods/Emandate.test.js
@@ -0,0 +1,56 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('emandate');
+describe('Testing Emandates methods', () => {
+ test('GetIssuerList', async () => {
+ await method
+ .issuerList()
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+ test('CreateMandate', async () => {
+ method
+ .createMandate({
+ debtorReference: 'klant1234',
+ language: 'nl',
+ continueOnIncomplete: true,
+ purchaseId: 'purchaseid1234',
+ sequenceType: 0
+ })
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('GetStatus', async () => {
+ method
+ .status({ mandateId: '1DC014098EC5C1F40AD803B83A425153BBC' })
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+ test('ModifyMandate', async () => {
+ method
+ .modifyMandate({
+ originalMandateId: '1DC014098EC5C1F40AD803B83A425153BBC',
+ continueOnIncomplete: true
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+ test('CancelMandate', async () => {
+ method
+ .cancelMandate({
+ mandateId: '1DC014098EC5C1F40AD803B83A425153BBC',
+ purchaseId: 'purchaseid1234'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Emandate.test.ts b/tests/PaymentMethods/Emandate.test.ts
index 5f8cc761..84accb72 100644
--- a/tests/PaymentMethods/Emandate.test.ts
+++ b/tests/PaymentMethods/Emandate.test.ts
@@ -1,51 +1,59 @@
-require('../BuckarooClient.test')
-import Emandates from '../../src/PaymentMethods/Emandates'
+import buckarooClientTest from '../BuckarooClient.test';
+import { ServiceCode } from '../../src';
-const method = new Emandates()
+const method = buckarooClientTest.method('emandate');
describe('Testing Emandates methods', () => {
test('GetIssuerList', async () => {
- method.issuerList().then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ await method
+ .issuerList()
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
test('CreateMandate', async () => {
method
.createMandate({
- debtorReference: 'klant1234',
+ debtorReference: 'XXXXXXXXX',
language: 'nl',
- continueOnIncomplete: 1,
- purchaseId: 'purchaseid1234',
- sequenceType: 0
+ continueOnIncomplete: true,
+ purchaseId: 'XXXXXXXXXXXXXX',
+ sequenceType: 0,
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- }).catch((err)=>{
- console.log(err);
- })
- })
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('GetStatus', async () => {
- method.status({ mandateId: '1DC014098EC5C1F40AD803B83A425153BBC' }).then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ method
+ .status({ mandateId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' })
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
test('ModifyMandate', async () => {
method
.modifyMandate({
- originalMandateId: '1DC014098EC5C1F40AD803B83A425153BBC',
- continueOnIncomplete: 1
+ originalMandateId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ continueOnIncomplete: true,
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
test('CancelMandate', async () => {
method
+ .setServiceCode('emandateb2b' as ServiceCode)
.cancelMandate({
- mandateId: '1DC014098EC5C1F40AD803B83A425153BBC',
- purchaseId: 'purchaseid1234'
+ mandateId: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ purchaseId: 'XXXXXXXXXXXXXX',
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
-})
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Giftcard.test.js b/tests/PaymentMethods/Giftcard.test.js
new file mode 100644
index 00000000..d05c2d33
--- /dev/null
+++ b/tests/PaymentMethods/Giftcard.test.js
@@ -0,0 +1,37 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('boekenbon');
+describe('GiftCard methods', () => {
+ test('Pay', async () => {
+ const responsePay = await method
+ .pay({
+ amountDebit: 10,
+ intersolveCardnumber: '0000000000000000001',
+ intersolvePIN: '500'
+ })
+ .request();
+ expect(responsePay.isSuccess()).toBeTruthy();
+ const responseRemainderPay = await buckarooClientTest
+ .method('ideal')
+ .payRemainder({
+ amountDebit: 10.1,
+ issuer: 'ABNANL2A',
+ invoice: responsePay.data.invoice,
+ originalTransactionKey: responsePay.data.relatedTransactions[0].relatedTransactionKey
+ })
+ .request();
+ expect(responseRemainderPay.isPendingProcessing()).toBeTruthy();
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 5,
+ originalTransactionKey: '9F99B530DA5449EB919D27351D28BDF2',
+ email: '',
+ lastName: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Giftcard.test.ts b/tests/PaymentMethods/Giftcard.test.ts
index a9c0dde1..c720a0da 100644
--- a/tests/PaymentMethods/Giftcard.test.ts
+++ b/tests/PaymentMethods/Giftcard.test.ts
@@ -1,28 +1,41 @@
-require('../BuckarooClient.test')
-import GiftCard from '../../src/PaymentMethods/GiftCard/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new GiftCard()
+const method = buckarooClientTest.method('boekenbon');
describe('GiftCard methods', () => {
test('Pay', async () => {
- await method
+ const responsePay = await method
.pay({
- amountDebit: 10,
- name: 'GiftCard'
+ amountDebit: 100,
+ intersolveCardnumber: '0000000000000000001',
+ intersolvePIN: '1000',
})
- .then((data) => {
- expect(data).toBeDefined()
+ .request();
+ expect(responsePay.isSuccess()).toBeTruthy();
+ const responseRemainderPay = await buckarooClientTest
+ .method('ideal')
+ .payRemainder({
+ amountDebit: 100,
+ issuer: 'ABNANL2A',
+ invoice: responsePay.data.invoice,
+ originalTransactionKey: responsePay.data.relatedTransactions[0].relatedTransactionKey,
})
- })
+ .request();
+ expect(responseRemainderPay.isPendingProcessing()).toBeTruthy();
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 5,
- name: 'GiftCard',
- originalTransactionKey: 'F397DA6A251645F8BDD81547B5005B4B'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ email: 'test@buckaroo.nl',
+ lastName: 'Acceptatie',
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/GiroPay.test.js b/tests/PaymentMethods/GiroPay.test.js
new file mode 100644
index 00000000..8fb80d49
--- /dev/null
+++ b/tests/PaymentMethods/GiroPay.test.js
@@ -0,0 +1,28 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+const method = buckarooClientTest.method('giropay');
+describe('Testing Giropay methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ bic: 'GENODETT488',
+ amountDebit: 10.1
+ })
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 10,
+ invoice: uniqid(),
+ originalTransactionKey: '2D04704995B74D679AACC59F87XXXXXX'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/GiroPay.test.ts b/tests/PaymentMethods/GiroPay.test.ts
index f888f133..acf2ede8 100644
--- a/tests/PaymentMethods/GiroPay.test.ts
+++ b/tests/PaymentMethods/GiroPay.test.ts
@@ -1,28 +1,29 @@
-require('../BuckarooClient.test')
-import GiroPay from '../../src/PaymentMethods/Giropay/index'
-
-const method = new GiroPay()
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+const method = buckarooClientTest.method('giropay');
describe('Testing Giropay methods', () => {
test('Pay', async () => {
await method
.pay({
- bic: '',
- costumerIBAN: '',
- amountDebit: 0
+ bic: 'XXXXXXXXX',
+ amountDebit: 100,
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 0,
- originalTransactionKey: ''
+ amountCredit: 0.01,
+ invoice: uniqid(),
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
-})
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Ideal.test.js b/tests/PaymentMethods/Ideal.test.js
new file mode 100644
index 00000000..4842f589
--- /dev/null
+++ b/tests/PaymentMethods/Ideal.test.js
@@ -0,0 +1,55 @@
+import { getIPAddress, uniqid } from '../../src/Utils/Functions';
+import buckarooClientTest from '../BuckarooClient.test';
+const ideal = buckarooClientTest.method('ideal');
+describe('testing Ideal methods', () => {
+ test('Issuers', () => {
+ return ideal.issuers().then((response) => {
+ expect(Array.isArray(response)).toBeTruthy();
+ });
+ });
+ test('Pay Simple Payload', () => {
+ return ideal
+ .pay({
+ amountDebit: 10.1,
+ issuer: 'ABNANL2A',
+ continueOnIncomplete: false,
+ additionalParameters: {
+ initiated_by_magento: 1,
+ service_action: 'something'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', () => {
+ return ideal
+ .refund({
+ order: uniqid(),
+ invoice: uniqid(),
+ originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
+ amountCredit: 4.23,
+ clientIP: getIPAddress(),
+ additionalParameters: {
+ initiated_by_magento: '1',
+ service_action: 'something'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('InstantRefund', () => {
+ return ideal
+ .instantRefund({
+ amountCredit: 4.23,
+ originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1'
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Ideal.test.ts b/tests/PaymentMethods/Ideal.test.ts
index e2da713e..1b0b512c 100644
--- a/tests/PaymentMethods/Ideal.test.ts
+++ b/tests/PaymentMethods/Ideal.test.ts
@@ -1,58 +1,57 @@
-require('../BuckarooClient.test')
-import { uniqid } from '../../src/Utils/Functions'
-import Ideal from '../../src/PaymentMethods/Ideal/index'
+import { getIPAddress, uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
-const ideal = new Ideal()
+const ideal = buckarooClientTest.method('ideal');
describe('testing Ideal methods', () => {
- test('Issuers', async () => {
- await ideal.issuers().then((response) => {
- expect(Array.isArray(response)).toBeTruthy()
- })
- })
- test('Pay Simple Payload', async () => {
- await ideal
+ test('Issuers', () => {
+ return ideal.issuers().then((response) => {
+ expect(Array.isArray(response)).toBeTruthy();
+ });
+ });
+ test('Pay Simple Payload', () => {
+ return ideal
.pay({
- amountDebit: 10.1,
+ amountDebit: 100,
issuer: 'ABNANL2A',
- clientIP: {
- address: '123.456.789.123',
- type: 0
- },
+ continueOnIncomplete: false,
additionalParameters: {
initiated_by_magento: 1,
- service_action: 'something'
- }
+ service_action: 'something',
+ },
})
+ .request()
.then((data) => {
- expect(data.isPendingProcessing()).toBeTruthy()
- })
- })
- test('Refund', async () => {
- await ideal
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', () => {
+ return ideal
.refund({
order: uniqid(),
invoice: uniqid(),
- originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
- amountCredit: 4.23,
- clientIP: {
- address: '123.456.789.123',
- type: 0
- },
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: 0.01,
+ clientIP: getIPAddress(),
additionalParameters: {
initiated_by_magento: '1',
- service_action: 'something'
- }
+ service_action: 'something',
+ },
})
+ .request()
.then((data) => {
- expect(data).toBeDefined()
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('InstantRefund', () => {
+ return ideal
+ .instantRefund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
- })
- test('InstantRefund', async () => {
- await ideal.instantRefund({
- amountCredit: 4.23,
- originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
- }).then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/IdealQR.test.js b/tests/PaymentMethods/IdealQR.test.js
new file mode 100644
index 00000000..db67b992
--- /dev/null
+++ b/tests/PaymentMethods/IdealQR.test.js
@@ -0,0 +1,31 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('idealqr');
+describe('Testing IdealQR methods', () => {
+ test('Pay', async () => {
+ await method
+ .generate({
+ description: 'Test purchase',
+ returnURL: 'https://buckaroo.dev/return',
+ returnURLCancel: 'https://buckaroo.dev/cancel',
+ returnURLError: 'https://buckaroo.dev/error',
+ returnURLReject: 'https://buckaroo.dev/reject',
+ minAmount: 0.1,
+ maxAmount: 10.0,
+ imageSize: 2000,
+ purchaseId: 'Testpurchase123',
+ isOneOff: false,
+ amount: 1.0,
+ amountIsChangeable: true,
+ expiration: '2030-09-30',
+ isProcessing: false,
+ additionalParameters: {
+ initiated_by_magento: '1',
+ service_action: 'something'
+ }
+ })
+ .request()
+ .then((response) => {
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/IdealQR.test.ts b/tests/PaymentMethods/IdealQR.test.ts
index b997db14..7ffeab00 100644
--- a/tests/PaymentMethods/IdealQR.test.ts
+++ b/tests/PaymentMethods/IdealQR.test.ts
@@ -1,25 +1,32 @@
-require('../BuckarooClient.test')
-import IDealQR from '../../src/PaymentMethods/iDealQR'
+import buckarooClientTest from '../BuckarooClient.test';
-const method = new IDealQR()
-
-describe('Testing iDealQR methods', () => {
+const method = buckarooClientTest.method('idealqr');
+describe('Testing IdealQR methods', () => {
test('Pay', async () => {
- method
+ await method
.generate({
- amount: 0,
- amountDebit: 0,
- amountIsChangeable: false,
- Description: '',
- expiration: '',
- imageSize: 0,
+ description: 'Test purchase',
+ returnURL: 'https://buckaroo.dev/return',
+ returnURLCancel: 'https://buckaroo.dev/cancel',
+ returnURLError: 'https://buckaroo.dev/error',
+ returnURLReject: 'https://buckaroo.dev/reject',
+ minAmount: 0.1,
+ maxAmount: 10.0,
+ imageSize: 2000,
+ purchaseId: 'Testpurchase123',
isOneOff: false,
- maxAmount: 0,
- minAmount: 0,
- purchaseId: ''
+ amount: 1.0,
+ amountIsChangeable: true,
+ expiration: '2030-09-30',
+ isProcessing: false,
+ additionalParameters: {
+ initiated_by_magento: '1',
+ service_action: 'something',
+ },
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
-})
+ expect(response.isSuccess()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Idin.test.ts b/tests/PaymentMethods/Idin.test.ts
new file mode 100644
index 00000000..711a15f1
--- /dev/null
+++ b/tests/PaymentMethods/Idin.test.ts
@@ -0,0 +1,38 @@
+import buckarooClientTest from '../BuckarooClient.test';
+
+const method = buckarooClientTest.method('idin');
+
+describe('Idin methods', () => {
+ test('Verify', async () => {
+ await method
+ .verify({
+ issuer: 'BANKNL2Y',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+
+ test('Identify', async () => {
+ await method
+ .identify({
+ issuer: 'BANKNL2Y',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+
+ test('Login', async () => {
+ await method
+ .login({
+ issuer: 'BANKNL2Y',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
\ No newline at end of file
diff --git a/tests/PaymentMethods/In3.test.js b/tests/PaymentMethods/In3.test.js
new file mode 100644
index 00000000..3c17c00c
--- /dev/null
+++ b/tests/PaymentMethods/In3.test.js
@@ -0,0 +1,105 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+const in3 = buckarooClientTest.method('In3');
+describe('Testing In3 methods', () => {
+ test('Pay', async () => {
+ await in3
+ .pay(payload)
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await in3
+ .refund({
+ amountCredit: 42,
+ originalTransactionKey: '',
+ merchantImageUrl: '',
+ summaryImageUrl: '',
+ articles: []
+ })
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeFalsy();
+ });
+ });
+});
+const payload = {
+ amountDebit: 52.3,
+ description: 'in3 pay',
+ order: uniqid(),
+ invoice: uniqid(),
+ clientIP: '127.0.0.1',
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ initials: 'J',
+ firstName: 'John',
+ lastName: 'Dona',
+ birthDate: '1990-01-01',
+ customerNumber: '12345',
+ companyName: 'Buckaroo',
+ chamberOfCommerce: '123456'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'a',
+ zipcode: '1234AB',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0698765433'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'J',
+ firstName: 'John',
+ lastName: 'Dona',
+ chamberOfCommerce: '123456'
+ },
+ address: {
+ street: 'Kalverstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'b',
+ zipcode: '4321EB',
+ city: 'Amsterdam',
+ country: 'NL'
+ }
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ type: 'Physical',
+ description: 'Blue Toy Car',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1
+ },
+ {
+ identifier: 'Articlenumber2',
+ type: 'Physical',
+ description: 'Red Toy Car',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1
+ },
+ {
+ identifier: 'USPShippingID',
+ type: 'Physical',
+ description: 'UPS',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 2
+ }
+ ]
+};
diff --git a/tests/PaymentMethods/In3.test.ts b/tests/PaymentMethods/In3.test.ts
index 1e1ee3ac..a80c10cb 100644
--- a/tests/PaymentMethods/In3.test.ts
+++ b/tests/PaymentMethods/In3.test.ts
@@ -1,57 +1,106 @@
-import In3 from '../../src/PaymentMethods/In3'
-import Gender from '../../src/Constants/Gender'
-import RecipientCategory from '../../src/Constants/RecipientCategory'
+import buckarooClientTest from '../BuckarooClient.test';
+import { getIPAddress, RecipientCategory, uniqid } from '../../src';
+import { IPay } from '../../src/PaymentMethods/In3/Models/Pay';
-require('../BuckarooClient.test')
-
-const in3 = new In3()
+const in3 = buckarooClientTest.method('In3');
describe('Testing In3 methods', () => {
test('Pay', async () => {
await in3
- .payInInstallments({
- clientIP: '127.0.0.0',
- description: 'fdsfsdfdsf',
- subtotalLine: [],
- amountDebit: 32,
- customerType: RecipientCategory.COMPANY,
- invoiceDate: '22-01-2018',
- person: {
- gender: Gender.FEMALE,
- culture: 'nl-NL',
- initials: 'J.S.',
- lastName: 'Aflever',
- birthDate: '1990-01-01'
- },
- company: {
- name: 'My Company B.V.',
- chamberOfCommerce: '123456'
- },
- address: {
- street: 'Hoofdstraat',
- houseNumber: 2,
- houseNumberSuffix: 'a',
- zipCode: '8441EE',
- city: 'Heerenveen',
- country: 'NL'
- },
- email: {
- email: 'test@buckaroo.nl'
- },
- phone: {
- phone: '0612345678'
- },
- productLine: [
- {
- code: '64381664f2f8b',
- price: 10,
- quantity: 1,
- name: 'Blue Toy Car'
- }
- ],
- })
- .then((response) => {
- expect(response.data).toBeDefined()
+ .pay(payload)
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await in3
+ .refund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
- })
-})
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeFalsy();
+ });
+ });
+});
+
+const payload: IPay = {
+ amountDebit: 100,
+ description: 'in3 pay',
+ order: uniqid(),
+ invoice: uniqid(),
+ clientIP: getIPAddress(),
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ initials: 'TA',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ customerNumber: 'XXXXX',
+ companyName: 'Buckaroo B.V.',
+ chamberOfCommerce: 'XXXXXX41',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ careOf: 'J',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ chamberOfCommerce: 'XXXXXX41',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ type: 'Physical',
+ description: 'Blue Toy Car',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 25,
+ },
+ {
+ identifier: 'Articlenumber2',
+ type: 'Physical',
+ description: 'Red Toy Car',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 25,
+ },
+ {
+ identifier: 'USPShippingID',
+ type: 'Physical',
+ description: 'UPS',
+ category: 'test product',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 25,
+ },
+ ],
+};
diff --git a/tests/PaymentMethods/In3Old.test.js b/tests/PaymentMethods/In3Old.test.js
new file mode 100644
index 00000000..2100e257
--- /dev/null
+++ b/tests/PaymentMethods/In3Old.test.js
@@ -0,0 +1,77 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import Gender from '../../src/Constants/Gender';
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+const capayable = buckarooClientTest.method('capayable');
+describe('Testing capayable methods', () => {
+ test('Pay', async () => {
+ await capayable
+ .pay(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await capayable
+ .refund({
+ amountCredit: 42,
+ originalTransactionKey: ''
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('PayInInstallments', async () => {
+ await capayable
+ .payInInstallments(paymentPayload)
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
+const paymentPayload = {
+ clientIP: '127.0.0.0',
+ description: 'fdsfsdfdsf',
+ amountDebit: 32,
+ customerType: RecipientCategory.COMPANY,
+ invoiceDate: '22-01-2018',
+ customer: {
+ gender: Gender.FEMALE,
+ culture: 'nl-NL',
+ initials: 'J.S.',
+ lastName: 'Aflever',
+ birthDate: '1990-01-01'
+ },
+ company: {
+ companyName: 'My Company B.V.',
+ chamberOfCommerce: '123456'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '2',
+ houseNumberSuffix: 'a',
+ zipcode: '8441EE',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ email: 'test@buckaroo.nl',
+ phone: {
+ mobile: '0612345678'
+ },
+ articles: [
+ {
+ identifier: '64381664f2f8b',
+ price: 10,
+ quantity: 1,
+ description: 'Blue Toy Car'
+ }
+ ],
+ subtotals: [
+ {
+ name: 'Verzendkosten',
+ value: 2
+ }
+ ]
+};
diff --git a/tests/PaymentMethods/In3Old.test.ts b/tests/PaymentMethods/In3Old.test.ts
new file mode 100644
index 00000000..b8d03976
--- /dev/null
+++ b/tests/PaymentMethods/In3Old.test.ts
@@ -0,0 +1,80 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { Gender, getIPAddress, RecipientCategory, uniqid } from '../../src';
+
+const capayable = buckarooClientTest.method('capayable');
+
+describe('Testing capayable methods', () => {
+ test('Pay', async () => {
+ await capayable
+ .pay(paymentPayload)
+ .request()
+ .then((data) => {
+ expect(data.isSuccess()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await capayable
+ .refund({
+ invoice: uniqid(),
+ amountCredit: paymentPayload.amountDebit,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isFailed()).toBeTruthy();
+ });
+ });
+ test('PayInInstallments', async () => {
+ await capayable
+ .payInInstallments(paymentPayload)
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
+
+const paymentPayload = {
+ clientIP: getIPAddress(),
+ description: 'Test',
+ amountDebit: 100,
+ customerType: RecipientCategory.COMPANY,
+ invoiceDate: '22-01-2018',
+ customer: {
+ gender: Gender.FEMALE,
+ culture: 'nl-NL',
+ initials: 'TA',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ },
+ company: {
+ companyName: 'Buckaroo B.V.',
+ chamberOfCommerce: 'XXXXXX41',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberSuffix: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ email: 'test@buckaroo.nl',
+ phone: {
+ mobile: '0612345678',
+ },
+ articles: [
+ {
+ identifier: '64381664f2f8b',
+ price: 10,
+ quantity: 1,
+ description: 'Blue Toy Car',
+ },
+ ],
+ subtotals: [
+ {
+ name: 'Verzendkosten',
+ value: 2,
+ },
+ ],
+};
diff --git a/tests/PaymentMethods/KBC.test.js b/tests/PaymentMethods/KBC.test.js
new file mode 100644
index 00000000..dac67ae6
--- /dev/null
+++ b/tests/PaymentMethods/KBC.test.js
@@ -0,0 +1,25 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('KBCPaymentButton');
+describe('Testing KBC methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 10
+ })
+ .request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ method
+ .refund({
+ amountCredit: 10,
+ originalTransactionKey: 'B5675356904444F3965C33D280591C74'
+ })
+ .request()
+ .then((response) => {
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/KBC.test.ts b/tests/PaymentMethods/KBC.test.ts
index ff393cb4..f25e6e4b 100644
--- a/tests/PaymentMethods/KBC.test.ts
+++ b/tests/PaymentMethods/KBC.test.ts
@@ -1,26 +1,29 @@
-require('../BuckarooClient.test')
-import KBC from '../../src/PaymentMethods/KBC'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new KBC()
+const method = buckarooClientTest.method('KBCPaymentButton');
describe('Testing KBC methods', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 10
+ amountDebit: 100,
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
method
.refund({
- amountCredit: 0,
- originalTransactionKey: 'B5675356904444F3965C33D280591C74'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
-})
+ expect(response.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Klarna.test.js b/tests/PaymentMethods/Klarna.test.js
new file mode 100644
index 00000000..45e9bd2c
--- /dev/null
+++ b/tests/PaymentMethods/Klarna.test.js
@@ -0,0 +1,82 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src/Utils/Functions';
+import RecipientCategory from '../../src/Constants/RecipientCategory';
+const klarna = buckarooClientTest.method('klarna');
+describe('Testing Klarna methods', () => {
+ test('Pay', async () => {
+ await klarna
+ .pay(payload)
+ .request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('PayInInstallments', async () => {
+ await klarna
+ .payInInstallments(payload)
+ .request()
+ .then((res) => {
+ expect(res).toBeDefined();
+ });
+ });
+});
+let payload = {
+ amountDebit: 50.3,
+ invoice: uniqid(),
+ order: uniqid(),
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ gender: 'female',
+ firstName: 'John',
+ lastName: 'Do',
+ birthDate: '1990-01-01'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'a',
+ zipcode: '1234AB',
+ city: 'Heerenveen',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0698765433'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.COMPANY,
+ gender: 'male',
+ firstName: 'John',
+ lastName: 'Do',
+ birthDate: '1990-01-01'
+ },
+ address: {
+ street: 'Kalverstraat',
+ houseNumber: '13',
+ houseNumberAdditional: 'b',
+ zipcode: '4321EB',
+ city: 'Amsterdam',
+ country: 'NL'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1
+ }
+ ]
+};
diff --git a/tests/PaymentMethods/Klarna.test.ts b/tests/PaymentMethods/Klarna.test.ts
index c49b500c..4d453789 100644
--- a/tests/PaymentMethods/Klarna.test.ts
+++ b/tests/PaymentMethods/Klarna.test.ts
@@ -1,62 +1,87 @@
-import { IPay } from '../../src/PaymentMethods/Klarna/Models/Pay'
-
-require('../BuckarooClient.test')
-import Klarna from '../../src/PaymentMethods/Klarna/index'
-import { uniqid } from '../../src/Utils/Functions'
-
-const klarna = new Klarna()
+import buckarooClientTest from '../BuckarooClient.test';
+import { IPay } from '../../src/PaymentMethods/Klarna/Models/Pay';
+import { RecipientCategory, uniqid } from '../../src';
+const klarna = buckarooClientTest.method('klarna');
describe('Testing Klarna methods', () => {
test('Pay', async () => {
- await klarna.pay(payload).then((res) => {
- expect(res).toBeDefined()
- })
- })
- test('Refund', async () => {
await klarna
- .refund({
- amountCredit: 21,
- originalTransactionKey: ''
- })
+ .pay(payload)
+ .request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('PayInInstallments', async () => {
+ const clonedPayload = JSON.parse(JSON.stringify(payload));
+ clonedPayload.currency = 'GBP';
+ clonedPayload.billing.address.country = 'GB';
+ await klarna
+ .payInInstallments(clonedPayload)
+ .request()
.then((res) => {
- expect(res).toBeDefined()
- })
- })
-})
+ expect(res).toBeDefined();
+ });
+ });
+});
let payload: IPay = {
- order: uniqid(),
- amountDebit: 50.3,
+ amountDebit: 100,
invoice: uniqid(),
- additionalParameters: undefined,
- article: [],
- billingCustomer: {
- city: '',
- country: '',
- email: '',
- firstName: '',
- lastName: '',
- phone: '',
- postalCode: '',
- street: '',
- streetNumber: '',
- streetNumberAdditional: ''
+ order: uniqid(),
+ billing: {
+ recipient: {
+ category: RecipientCategory.PERSON,
+ gender: 'female',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ shipping: {
+ recipient: {
+ category: RecipientCategory.COMPANY,
+ gender: 'male',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '1990-01-01',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ email: 'test@buckaroo.nl',
},
- clientIP: undefined,
- culture: '',
- currency: '',
- customParameters: undefined,
- description: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- shippingCustomer: undefined,
- startRecurrent: false
-}
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 50,
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 50,
+ },
+ ],
+};
diff --git a/tests/PaymentMethods/KlarnaKp.test.js b/tests/PaymentMethods/KlarnaKp.test.js
new file mode 100644
index 00000000..30022eae
--- /dev/null
+++ b/tests/PaymentMethods/KlarnaKp.test.js
@@ -0,0 +1,87 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import gender from '../../src/Constants/Gender';
+const klarnaKp = buckarooClientTest.method('klarnakp');
+describe('KlarnaKp', () => {
+ test('Pay', async () => {
+ await klarnaKp
+ .pay({
+ amountDebit: 50.3,
+ reservationNumber: '2377577452'
+ })
+ .request()
+ .then((info) => {
+ expect(info.isFailed()).toBeTruthy();
+ });
+ });
+ test('Reserve', async () => {
+ await klarnaKp
+ .reserve({
+ gender: gender.MALE,
+ operatingCountry: 'NL',
+ pno: '01011990',
+ billing: {
+ recipient: {
+ firstName: 'John',
+ lastName: 'Do'
+ },
+ address: {
+ street: 'Neherkade',
+ houseNumber: '1',
+ zipcode: '2521VA',
+ city: 'Gravenhage',
+ country: 'NL'
+ },
+ phone: {
+ mobile: '0612345678'
+ },
+ email: 'youremail@example.nl'
+ },
+ shipping: {
+ recipient: {
+ firstName: 'John',
+ lastName: 'Do'
+ },
+ address: {
+ street: 'Rosenburglaan',
+ houseNumber: '216',
+ zipcode: '4385 JM',
+ city: 'Vlissingen',
+ country: 'NL'
+ },
+ email: 'test@buckaroo.nl'
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1
+ }
+ ],
+ additionalParameters: {
+ initiated_by_magento: '1',
+ service_action: 'something'
+ }
+ })
+ .request()
+ .then((info) => {
+ expect(info.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Cancel', async () => {
+ await klarnaKp
+ .cancel({})
+ .request()
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/KlarnaKp.test.ts b/tests/PaymentMethods/KlarnaKp.test.ts
index b23a20dc..e8735dab 100644
--- a/tests/PaymentMethods/KlarnaKp.test.ts
+++ b/tests/PaymentMethods/KlarnaKp.test.ts
@@ -1,11 +1,72 @@
-require('../BuckarooClient.test')
-import KlarnaKp from '../../src/PaymentMethods/KlarnaKP'
-const klarnaKp = new KlarnaKp()
-describe('KlarnaKp', () => {
- test('reserve', async () => {
+import buckarooClientTest from '../BuckarooClient.test';
+import { Gender } from '../../src';
- await klarnaKp.reserve({}).then((info) => {
- expect(info).toBeDefined()
- })
- })
-})
+const klarnaKp = buckarooClientTest.method('klarnakp');
+
+describe('KlarnaKp', () => {
+ test('Pay', async () => {
+ await klarnaKp
+ .pay({
+ amountDebit: 100,
+ reservationNumber: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((info) => {
+ expect(info.isFailed()).toBeTruthy();
+ });
+ });
+ test('Reserve', async () => {
+ await klarnaKp
+ .reserve({
+ gender: Gender.MALE,
+ operatingCountry: 'NL',
+ pno: '01011990',
+ billing: {
+ recipient: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ phone: {
+ mobile: '0612345678',
+ },
+ email: 'test@buckaroo.nl',
+ },
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Blue Toy Car',
+ vatPercentage: 21,
+ quantity: 2,
+ price: 20.1,
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Red Toy Car',
+ vatPercentage: 21,
+ quantity: 1,
+ price: 10.1,
+ },
+ ],
+ })
+ .request()
+ .then((info) => {
+ expect(info.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Cancel', async () => {
+ await klarnaKp
+ .cancel({
+ reservationNumber: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Marketplaces.test.js b/tests/PaymentMethods/Marketplaces.test.js
new file mode 100644
index 00000000..16d27038
--- /dev/null
+++ b/tests/PaymentMethods/Marketplaces.test.js
@@ -0,0 +1,51 @@
+require('../BuckarooClient.test');
+import Marketplaces from '../../src/PaymentMethods/Marketplaces';
+import Ideal from '../../src/PaymentMethods/Ideal';
+const marketplaces = new Marketplaces();
+const ideal = new Ideal();
+describe('Testing Marketplaces methods', () => {
+ test('Split', async () => {
+ marketplaces.split({
+ daysUntilTransfer: 2,
+ marketplace: {
+ amount: 10,
+ description: ''
+ },
+ seller: [
+ {
+ accountId: '789C60F316D24B088ACD471',
+ amount: 50,
+ description: ''
+ },
+ {
+ accountId: '369C60F316D24B088ACD238',
+ amount: 35,
+ description: ''
+ }
+ ]
+ });
+ ideal
+ .combine(marketplaces)
+ .pay({
+ issuer: 'ABNANL2A',
+ amountDebit: 95.0
+ })
+ .then((response) => {
+ expect(response.data).toBeDefined();
+ });
+ });
+ test('transfer', async () => {
+ marketplaces.transfer({ originalTransactionKey: 'fwcafgdhgf' }).then((response) => {
+ expect(response.data).toBeDefined();
+ });
+ });
+ test('refundSupplementary', async () => {
+ const market = marketplaces.refundSupplementary();
+ ideal
+ .combine(market)
+ .refund({ originalTransactionKey: 'dasda', amountCredit: 10 })
+ .then((response) => {
+ expect(response.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Marketplaces.test.ts b/tests/PaymentMethods/Marketplaces.test.ts
index c2e79a66..a4a9170f 100644
--- a/tests/PaymentMethods/Marketplaces.test.ts
+++ b/tests/PaymentMethods/Marketplaces.test.ts
@@ -1,52 +1,82 @@
-require('../BuckarooClient.test')
-import Marketplaces from '../../src/PaymentMethods/Marketplaces/index'
-import Ideal from '../../src/PaymentMethods/Ideal/index'
-const marketplaces = new Marketplaces()
-const ideal = new Ideal()
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+
+const marketplaces = buckarooClientTest.method('marketplaces');
+const ideal = buckarooClientTest.method('ideal');
describe('Testing Marketplaces methods', () => {
test('Split', async () => {
- marketplaces.split({
+ const marketplacesResponse = marketplaces.split({
+ description: 'INV0001',
daysUntilTransfer: 2,
marketplace: {
amount: 10,
- description: ''
+ description: '',
},
- seller: [
+ sellers: [
{
- accountId: '789C60F316D24B088ACD471',
+ accountId: 'XXXXXXXXXXXXXXXXXXXXXXXX',
amount: 50,
- description: ''
+ description: '',
},
{
- accountId: '369C60F316D24B088ACD238',
- amount: 35,
- description: ''
- }
- ]
- })
- ideal
- .combine(marketplaces)
+ accountId: 'XXXXXXXXXXXXXXXXXXXXXXXX',
+ amount: 45,
+ description: '',
+ },
+ ],
+ });
+ return ideal
+ .combine(marketplacesResponse.data)
.pay({
issuer: 'ABNANL2A',
- amountDebit: 95.0
+ amountDebit: 100,
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
test('transfer', async () => {
- marketplaces.transfer({ originalTransactionKey: 'fwcafgdhgf' }).then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ marketplaces
+ .transfer({
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ marketplace: {
+ amount: 10,
+ description: 'INV0001 Commission Marketplace',
+ },
+ sellers: [
+ {
+ accountId: 'XXXXXXXXXXXXXXXXXXXXXXXX',
+ amount: 50,
+ description: 'INV001 Payout Make-Up Products BV',
+ },
+ ],
+ })
+ .request()
+ .then((response) => {
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
test('refundSupplementary', async () => {
- const market = marketplaces.refundSupplementary()
+ const marketplacesResponse = marketplaces.refundSupplementary({
+ sellers: [
+ {
+ accountId: 'XXXXXXXXXXXXXXXXXXXXXXXX',
+ description: 'INV001 Payout Make-Up Products BV',
+ },
+ ],
+ });
ideal
- .combine(market)
- .refund({ originalTransactionKey: 'dasda', amountCredit: 10 })
- .then((response) => {
- expect(response.data).toBeDefined()
+ .combine(marketplacesResponse.data)
+ .refund({
+ invoice: uniqid(),
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ amountCredit: 0.01,
})
- })
-})
+ .request()
+ .then((response) => {
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Mbway.test.ts b/tests/PaymentMethods/Mbway.test.ts
new file mode 100644
index 00000000..65f0de6e
--- /dev/null
+++ b/tests/PaymentMethods/Mbway.test.ts
@@ -0,0 +1,15 @@
+import buckarooClientTest from '../BuckarooClient.test';
+
+const method = buckarooClientTest.method('MBWay');
+describe('Mbway methods', () => {
+ test('Pay', () => {
+ return method
+ .pay({
+ amountDebit: 100,
+ })
+ .request()
+ .then((response) => {
+ expect(response.isValidationFailure()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Multibanco.test.ts b/tests/PaymentMethods/Multibanco.test.ts
new file mode 100644
index 00000000..3d7dd2c8
--- /dev/null
+++ b/tests/PaymentMethods/Multibanco.test.ts
@@ -0,0 +1,15 @@
+import buckarooClientTest from '../BuckarooClient.test';
+
+describe('Multibanco methods', () => {
+ test('Pay', async () => {
+ await buckarooClientTest
+ .method('multibanco')
+ .pay({
+ amountDebit: 100,
+ })
+ .request()
+ .then((info) => {
+ expect(info.isValidationFailure()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/NoService.test.ts b/tests/PaymentMethods/NoService.test.ts
new file mode 100644
index 00000000..e4110748
--- /dev/null
+++ b/tests/PaymentMethods/NoService.test.ts
@@ -0,0 +1,21 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+
+const method = buckarooClientTest.method('noservice');
+
+describe('NoService methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 100,
+ invoice: uniqid(),
+ servicesSelectableByClient: 'ideal,bancontactmrcash,paypal',
+ servicesExcludedForClient: 'ideal',
+ continueOnIncomplete: true,
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
\ No newline at end of file
diff --git a/tests/PaymentMethods/PayPerEmail.test.js b/tests/PaymentMethods/PayPerEmail.test.js
new file mode 100644
index 00000000..829588c6
--- /dev/null
+++ b/tests/PaymentMethods/PayPerEmail.test.js
@@ -0,0 +1,44 @@
+import Gender from '../../src/Constants/Gender';
+import PayPerEmail from '../../src/PaymentMethods/PayPerEmail';
+require('../BuckarooClient.test');
+const method = new PayPerEmail();
+describe('PayPerEmail methods', () => {
+ test('paymentInvitation', async () => {
+ await method
+ .paymentInvitation({
+ invoice: '123456',
+ amountDebit: 10,
+ currency: 'EUR',
+ attachment: '',
+ additionalParameters: undefined,
+ clientIP: undefined,
+ continueOnIncomplete: 1,
+ culture: '',
+ customParameters: undefined,
+ customerEmail: '',
+ customerFirstName: '',
+ customerGender: Gender.NOT_APPLICABLE,
+ customerLastName: '',
+ description: '',
+ order: '',
+ originalTransactionKey: '',
+ originalTransactionReference: '',
+ pushURL: '',
+ pushURLFailure: '',
+ returnURL: '',
+ returnURLCancel: '',
+ returnURLError: '',
+ returnURLReject: '',
+ servicesExcludedForClient: '',
+ servicesSelectableByClient: '',
+ startRecurrent: false,
+ email: 's',
+ expirationDate: '',
+ merchantSendsEmail: false,
+ paymentMethodsAllowed: 'ideal'
+ })
+ .then((response) => {
+ expect(response).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/PayPerEmail.test.ts b/tests/PaymentMethods/PayPerEmail.test.ts
index 3da31577..49bde930 100644
--- a/tests/PaymentMethods/PayPerEmail.test.ts
+++ b/tests/PaymentMethods/PayPerEmail.test.ts
@@ -1,47 +1,30 @@
-import Gender from "../../src/Constants/Gender";
-import PayPerEmail from '../../src/PaymentMethods/PayPerEmail/index'
+import { Gender, uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
-require('../BuckarooClient.test')
-
-const method = new PayPerEmail()
+const method = buckarooClientTest.method('payperemail');
describe('PayPerEmail methods', () => {
test('paymentInvitation', async () => {
await method
.paymentInvitation({
- invoice: '123456',
- amountDebit: 10,
currency: 'EUR',
- attachment: '',
- additionalParameters: undefined,
- clientIP: undefined,
- continueOnIncomplete: 1,
- culture: '',
- customParameters: undefined,
- customerEmail: '',
- customerFirstName: '',
- customerGender: Gender.NOT_APPLICABLE,
- customerLastName: '',
- description: '',
- order: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- startRecurrent: false,
- email: 's',
- expirationDate: '',
+ amountDebit: 100,
+ order: uniqid(),
+ invoice: uniqid(),
merchantSendsEmail: false,
- paymentMethodsAllowed: 'ideal'
+ email: 'test@buckaroo.nl',
+ expirationDate: '2030-01-01',
+ paymentMethodsAllowed: 'ideal,mastercard,paypal',
+ attachment: '',
+ customer: {
+ gender: Gender.FEMALE,
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
-})
+ expect(response).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Payconiq.test.js b/tests/PaymentMethods/Payconiq.test.js
new file mode 100644
index 00000000..8f12e1ef
--- /dev/null
+++ b/tests/PaymentMethods/Payconiq.test.js
@@ -0,0 +1,34 @@
+import buckarooClientTest from "../BuckarooClient.test";
+const payconiq = buckarooClientTest.method("payconiq");
+describe('Payconiq', () => {
+ test('Pay', async () => {
+ await payconiq
+ .pay({
+ amountDebit: 50.3,
+ order: '123456'
+ }).request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await payconiq
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: '123456'
+ }).request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+ test('InstantRefund', async () => {
+ await payconiq
+ .instantRefund({
+ amountCredit: 4.23,
+ originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1'
+ }).request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Payconiq.test.ts b/tests/PaymentMethods/Payconiq.test.ts
index d4e5b48a..38feedbb 100644
--- a/tests/PaymentMethods/Payconiq.test.ts
+++ b/tests/PaymentMethods/Payconiq.test.ts
@@ -1,35 +1,41 @@
-require('../BuckarooClient.test')
-import Payconiq from '../../src/PaymentMethods/Payconiq/index'
-
-const payconiq = new Payconiq()
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+const payconiq = buckarooClientTest.method('payconiq');
describe('Payconiq', () => {
test('Pay', async () => {
await payconiq
.pay({
- amountDebit: 50.3,
- order: '123456'
+ amountDebit: 100,
+ order: uniqid(),
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
+ expect(info.data).toBeDefined();
+ });
+ });
test('Refund', async () => {
await payconiq
.refund({
- amountCredit: 50.3,
- originalTransactionKey: '123456'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
+ expect(info.data).toBeDefined();
+ });
+ });
test('InstantRefund', async () => {
- await payconiq.instantRefund({
- amountCredit: 4.23,
- originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
- }).then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ await payconiq
+ .instantRefund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/PaymentInitiation.test.js b/tests/PaymentMethods/PaymentInitiation.test.js
new file mode 100644
index 00000000..0bdae1d6
--- /dev/null
+++ b/tests/PaymentMethods/PaymentInitiation.test.js
@@ -0,0 +1,29 @@
+require('../BuckarooClient.test');
+import PayByBank from '../../src/PaymentMethods/PayByBank';
+const paymentInitiation = new PayByBank('PayByBank');
+describe('PayByBank methods', () => {
+ test('Pay', async () => {
+ await paymentInitiation
+ .pay({
+ amountDebit: 50.3,
+ order: '123456',
+ issuer: 'INGBNL2A',
+ countryCode: 'NL'
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await paymentInitiation
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: '123456'
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/PaymentInitiation.test.ts b/tests/PaymentMethods/PaymentInitiation.test.ts
index 6f4b2450..1c719e4b 100644
--- a/tests/PaymentMethods/PaymentInitiation.test.ts
+++ b/tests/PaymentMethods/PaymentInitiation.test.ts
@@ -1,29 +1,40 @@
-require('../BuckarooClient.test')
-import PaymentInitiation from '../../src/PaymentMethods/PaymentInitiation'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const payByBank = new PaymentInitiation()
+const method = buckarooClientTest.method('PayByBank');
describe('PaymentInitiation methods', () => {
+ test('Issuers', async () => {
+ await method
+ .issuers()
+ .then((response) => {
+ expect(Array.isArray(response)).toBeTruthy();
+ });
+ });
test('Pay', async () => {
- await payByBank
+ await method
.pay({
- amountDebit: 50.3,
- order: '123456',
- issuer: 'INGBNL2A',
- countryCode: 'NL'
- })
- .then((response) => {
- expect(response).toBeTruthy()
+ issuer: 'RABONL2U',
+ amountDebit: 100,
+ order: uniqid(),
+ invoice: uniqid(),
+ countryCode: 'NL',
})
- })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
test('Refund', async () => {
- await payByBank
+ await method
.refund({
- amountCredit: 50.3,
- originalTransactionKey: '123456'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
-})
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Paypal.test.js b/tests/PaymentMethods/Paypal.test.js
new file mode 100644
index 00000000..d548718a
--- /dev/null
+++ b/tests/PaymentMethods/Paypal.test.js
@@ -0,0 +1,50 @@
+import buckarooClientTest from '../BuckarooClient.test';
+require('../BuckarooClient.test');
+import Paypal from '../../src/PaymentMethods/Paypal';
+const method = new Paypal('paypal');
+describe('Paypal', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 50.3
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: '123456'
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+ test('ExtraInfo', async () => {
+ buckarooClientTest.method('subscriptions').createCombined({});
+ await method
+ .extraInfo({
+ amountDebit: 50.3,
+ address: {
+ street: 'Hoofstraat 90',
+ street2: 'Street 2',
+ city: 'Heerenveen',
+ state: 'Friesland',
+ zipcode: '8441AB',
+ country: 'NL'
+ },
+ addressOverride: false,
+ costumer: { name: 'John' },
+ noShipping: '0',
+ phone: { mobile: '0612345678' }
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Paypal.test.ts b/tests/PaymentMethods/Paypal.test.ts
index 3ac78130..e3828369 100644
--- a/tests/PaymentMethods/Paypal.test.ts
+++ b/tests/PaymentMethods/Paypal.test.ts
@@ -1,47 +1,52 @@
-require('../BuckarooClient.test')
-import Paypal from '../../src/PaymentMethods/Paypal/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new Paypal()
+const method = buckarooClientTest.method('paypal');
describe('Paypal', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 50.3
+ amountDebit: 100,
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
+ expect(info.data).toBeDefined();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 50.3,
- originalTransactionKey: '123456'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
+ expect(info.data).toBeDefined();
+ });
+ });
test('ExtraInfo', async () => {
+ buckarooClientTest.method('subscriptions').createCombined({});
await method
.extraInfo({
- amountDebit: 50.3,
+ amountDebit: 100,
address: {
- city: 're',
- country: 'rw',
- state: 'fsd',
- street: 'dsf',
- street2: 'dsf',
- zipcode: 'sdf'
+ street: 'Hoofdstraat',
+ street2: 'Street 2',
+ city: 'Heerenveen',
+ state: 'Friesland',
+ zipcode: '8441ER',
+ country: 'NL',
},
addressOverride: false,
- costumer: { name: 'ers' },
- noShipping: 0,
- phone: { mobile: '534' }
+ customer: { name: 'Test Acceptatie' },
+ noShipping: '0',
+ phone: { mobile: '0612345678' },
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
-})
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/PiM.test.js b/tests/PaymentMethods/PiM.test.js
new file mode 100644
index 00000000..ddf1750c
--- /dev/null
+++ b/tests/PaymentMethods/PiM.test.js
@@ -0,0 +1,10 @@
+require('../BuckarooClient.test');
+import PiM from '../../src/PaymentMethods/PiM';
+const pim = new PiM();
+describe('PiM', () => {
+ test('generate', async () => {
+ await pim.generate().then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/PiM.test.ts b/tests/PaymentMethods/PiM.test.ts
index 113ff994..b1d90ced 100644
--- a/tests/PaymentMethods/PiM.test.ts
+++ b/tests/PaymentMethods/PiM.test.ts
@@ -1,13 +1,32 @@
-require("../BuckarooClient.test");
-import PiM from "../../src/PaymentMethods/PiM";
+import buckarooClientTest from '../BuckarooClient.test';
+import { Gender } from '../../src';
-const pim = new PiM();
+const method = buckarooClientTest.method('pim');
-describe("PiM", () => {
-
- test("generate", async () => {
- await pim.generate().then((info) => {
- expect(info).toBeDefined();
+describe('PiM', () => {
+ test('generate', async () => {
+ await method
+ .generate({
+ amountDebit: 100,
+ description: 'Omschrijving',
+ title: 'Titel',
+ return: {
+ nickname: 'test',
+ initials: 'TA',
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ birthDate: '01-01-1990',
+ gender: Gender.MALE,
+ email: 'test@buckaroo.nl',
+ },
+ result: {
+ title: 'success',
+ text: 'bedankt',
+ },
+ })
+ .request()
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
});
- });
-})
\ No newline at end of file
+});
diff --git a/tests/PaymentMethods/Pos.test.ts b/tests/PaymentMethods/Pos.test.ts
new file mode 100644
index 00000000..87d48462
--- /dev/null
+++ b/tests/PaymentMethods/Pos.test.ts
@@ -0,0 +1,19 @@
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+
+const method = buckarooClientTest.method('pospayment');
+
+describe('POS methods', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 100,
+ invoice: uniqid(),
+ terminalId: '50000001',
+ })
+ .request()
+ .then((data) => {
+ expect(data.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
\ No newline at end of file
diff --git a/tests/PaymentMethods/Przelewy24.test.js b/tests/PaymentMethods/Przelewy24.test.js
new file mode 100644
index 00000000..bebf63b3
--- /dev/null
+++ b/tests/PaymentMethods/Przelewy24.test.js
@@ -0,0 +1,31 @@
+require('../BuckarooClient.test');
+import Przelewy24 from '../../src/PaymentMethods/Przelewy24';
+const method = new Przelewy24('Przelewy24');
+describe('Przelewy24', () => {
+ test('Pay', async () => {
+ method
+ .pay({
+ amountDebit: 50.3,
+ customer: {
+ firstName: 'test',
+ lastName: 'test'
+ },
+ email: 'test@hotmail.com'
+ })
+ .request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: '123456'
+ })
+ .request()
+ .then((info) => {
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Przelewy24.test.ts b/tests/PaymentMethods/Przelewy24.test.ts
index 8ccbb97e..4b477a59 100644
--- a/tests/PaymentMethods/Przelewy24.test.ts
+++ b/tests/PaymentMethods/Przelewy24.test.ts
@@ -1,31 +1,34 @@
-require('../BuckarooClient.test')
-import Przelewy24 from '../../src/PaymentMethods/Przelewy24/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-const method = new Przelewy24()
+const method = buckarooClientTest.method('przelewy24');
describe('Przelewy24', () => {
test('Pay', async () => {
- await method
+ method
.pay({
- customerLastName: "",
- additionalParameters: undefined,
- amountDebit: 0,
- customerEmail: "",
- customerFirstName: "",
- email: "",
- })
- .then((info) => {
- expect(info).toBeDefined()
+ amountDebit: 100,
+ customer: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ },
+ email: 'test@buckaroo.nl',
})
- })
+ .request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 50.3,
- originalTransactionKey: '123456'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info.data).toBeDefined()
- })
- })
-})
+ expect(info.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/SEPA.test.js b/tests/PaymentMethods/SEPA.test.js
new file mode 100644
index 00000000..4d5e74de
--- /dev/null
+++ b/tests/PaymentMethods/SEPA.test.js
@@ -0,0 +1,128 @@
+require('../BuckarooClient.test');
+import SEPA from '../../src/PaymentMethods/SEPA';
+const method = new SEPA();
+describe('SEPA', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ additionalParameters: undefined,
+ amountDebit: 0,
+ clientIP: undefined,
+ collectDate: '',
+ continueOnIncomplete: 0,
+ culture: '',
+ currency: '',
+ customParameters: undefined,
+ customerBIC: '',
+ customerIBAN: '',
+ customeraccountname: '',
+ description: '',
+ invoice: '',
+ mandateDate: '',
+ mandateReference: '',
+ order: '',
+ originalTransactionKey: '',
+ originalTransactionReference: '',
+ pushURL: '',
+ pushURLFailure: '',
+ returnURL: '',
+ returnURLCancel: '',
+ returnURLError: '',
+ returnURLReject: '',
+ servicesExcludedForClient: '',
+ servicesSelectableByClient: '',
+ startRecurrent: false
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: ''
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('Authorize', async () => {
+ await method
+ .authorize({
+ amountDebit: 0,
+ collectDate: '',
+ customerIBAN: '',
+ customeraccountname: ''
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('PayRecurrent', async () => {
+ await method
+ .payRecurrent({
+ collectDate: '',
+ amountDebit: 50.3,
+ originalTransactionKey: ''
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('ExtraInfo', async () => {
+ await method
+ .extraInfo({
+ additionalParameters: undefined,
+ amountDebit: 0,
+ city: '',
+ clientIP: undefined,
+ collectDate: '',
+ contractID: '',
+ country: '',
+ culture: '',
+ currency: '',
+ customParameters: undefined,
+ customerBIC: '',
+ customerCode: '',
+ customerIBAN: '',
+ customerName: '',
+ customerReferencePartyCode: '',
+ customerReferencePartyName: '',
+ customeraccountname: '',
+ description: '',
+ houseNumber: '',
+ houseNumberSuffix: '',
+ invoice: '',
+ mandateDate: '',
+ mandateReference: '',
+ order: '',
+ originalTransactionKey: '',
+ originalTransactionReference: '',
+ pushURL: '',
+ pushURLFailure: '',
+ returnURL: '',
+ returnURLCancel: '',
+ returnURLError: '',
+ returnURLReject: '',
+ servicesExcludedForClient: '',
+ servicesSelectableByClient: '',
+ startRecurrent: false,
+ street: '',
+ zipcode: ''
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('Emandates', async () => {
+ await method
+ .payWithEmandate({
+ mandateReference: '',
+ amountDebit: 50.3
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/SEPA.test.ts b/tests/PaymentMethods/SEPA.test.ts
index 9652e532..58ba5e25 100644
--- a/tests/PaymentMethods/SEPA.test.ts
+++ b/tests/PaymentMethods/SEPA.test.ts
@@ -1,130 +1,101 @@
-require('../BuckarooClient.test')
-import SEPA from '../../src/PaymentMethods/SEPA/index'
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+import { IPay } from '../../src/PaymentMethods/SEPA/Models/Pay';
-const method = new SEPA()
+const method = buckarooClientTest.method('sepadirectdebit');
-describe('SEPA', () => {
+const paymentPayload: IPay = {
+ invoice: uniqid(),
+ amountDebit: 100,
+ iban: 'NLXXTESTXXXXXXXXXX',
+ bic: 'XXXXXXXXX',
+ collectdate: '2022-12-01',
+ mandateReference: 'XXXXXXXXXXXXXXX',
+ mandateDate: '2022-07-03',
+ customer: {
+ name: 'Test Acceptatie',
+ },
+};
+
+describe('SEPA methods', () => {
test('Pay', async () => {
await method
- .pay({
- additionalParameters: undefined,
- amountDebit: 0,
- clientIP: undefined,
- collectDate: '',
- continueOnIncomplete: 0,
- culture: '',
- currency: '',
- customParameters: undefined,
- customerBIC: '',
- customerIBAN: '',
- customeraccountname: '',
- description: '',
- invoice: '',
- mandateDate: '',
- mandateReference: '',
- order: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- startRecurrent: false
- })
+ .pay(paymentPayload)
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 50.3,
- originalTransactionKey: ''
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('Authorize', async () => {
await method
- .authorize({
- amountDebit: 0,
- collectDate: '',
- customerIBAN: '',
- customeraccountname: ''
- })
+ .authorize(paymentPayload)
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('PayRecurrent', async () => {
await method
.payRecurrent({
- collectDate: '',
- amountDebit: 50.3,
- originalTransactionKey: ''
+ invoice: uniqid(),
+ collectDate: '2030-07-03',
+ amountDebit: 100,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('ExtraInfo', async () => {
await method
.extraInfo({
- additionalParameters: undefined,
- amountDebit: 0,
- city: '',
- clientIP: undefined,
- collectDate: '',
- contractID: '',
- country: '',
- culture: '',
- currency: '',
- customParameters: undefined,
- customerBIC: '',
- customerCode: '',
- customerIBAN: '',
- customerName: '',
- customerReferencePartyCode: '',
- customerReferencePartyName: '',
- customeraccountname: '',
- description: '',
- houseNumber: '',
- houseNumberSuffix: '',
- invoice: '',
- mandateDate: '',
- mandateReference: '',
- order: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- startRecurrent: false,
- street: '',
- zipcode: ''
+ amountDebit: 100,
+ invoice: uniqid(),
+ iban: 'NLXXTESTXXXXXXXXXX',
+ bic: 'XXXXXXXXX',
+ contractID: 'Test',
+ mandateDate: '2022-07-03',
+ customerReferencePartyName: 'Test',
+ customer: {
+ name: 'Test Acceptatie',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('Emandates', async () => {
await method
.payWithEmandate({
- mandateReference: '',
- amountDebit: 50.3
+ order: uniqid(),
+ invoice: uniqid(),
+ mandateReference: 'XXXXXXXXXXXXXXX',
+ amountDebit: 100,
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
-})
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/SEPAB2B.test.ts b/tests/PaymentMethods/SEPAB2B.test.ts
deleted file mode 100644
index b8f23fd9..00000000
--- a/tests/PaymentMethods/SEPAB2B.test.ts
+++ /dev/null
@@ -1,102 +0,0 @@
-require('../BuckarooClient.test')
-import SEPA from '../../src/PaymentMethods/SEPA'
-
-const sepab2b = new SEPA('B2B')
-describe('SEPA', () => {
- test('Pay', async () => {
- await sepab2b
- .pay({
- additionalParameters: undefined,
- amountDebit: 0,
- clientIP: undefined,
- collectDate: '',
- continueOnIncomplete: 0,
- culture: '',
- currency: '',
- customParameters: undefined,
- customerBIC: '',
- customerIBAN: '',
- customeraccountname: '',
- description: '',
- invoice: '',
- mandateDate: '',
- mandateReference: '',
- order: '',
- originalTransactionKey: '',
- originalTransactionReference: '',
- pushURL: '',
- pushURLFailure: '',
- returnURL: '',
- returnURLCancel: '',
- returnURLError: '',
- returnURLReject: '',
- servicesExcludedForClient: '',
- servicesSelectableByClient: '',
- startRecurrent: false
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
- test('Refund', async () => {
- await sepab2b
- .refund({
- amountCredit: 50.3,
- originalTransactionKey: ''
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
- test('Authorize', async () => {
- await sepab2b
- .authorize({
- amountDebit: 0,
- collectDate: '',
- customerIBAN: '',
- customeraccountname: ''
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
- test('PayRecurrent', async () => {
- await sepab2b
- .payRecurrent({
- collectDate: '',
- amountDebit: 50.3,
- originalTransactionKey: ''
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
- test('ExtraInfo', async () => {
- await sepab2b
- .extraInfo({
- amountDebit: 0,
- city: "",
- collectDate: "",
- contractID: "",
- country: "",
- customerIBAN: "",
- customeraccountname: "",
- houseNumberSuffix: "",
- street: "",
- zipcode: ""
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
- test('Emandates', async () => {
- await sepab2b
- .payWithEmandate({
- mandateReference: '',
- amountDebit: 50.3
- })
- .then((info) => {
- expect(info).toBeDefined()
- })
- })
-})
diff --git a/tests/PaymentMethods/Sofort.test.js b/tests/PaymentMethods/Sofort.test.js
new file mode 100644
index 00000000..8663717a
--- /dev/null
+++ b/tests/PaymentMethods/Sofort.test.js
@@ -0,0 +1,35 @@
+require('../BuckarooClient.test');
+import Sofort from '../../src/PaymentMethods/Sofort';
+const method = new Sofort();
+describe('Sofort', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 50.3,
+ order: '123456'
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 50.3,
+ originalTransactionKey: '123456'
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+ test('InstantRefund', async () => {
+ await method
+ .instantRefund({
+ amountCredit: 4.23,
+ originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1'
+ })
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Sofort.test.ts b/tests/PaymentMethods/Sofort.test.ts
index 9d039f9a..1d3a1741 100644
--- a/tests/PaymentMethods/Sofort.test.ts
+++ b/tests/PaymentMethods/Sofort.test.ts
@@ -1,35 +1,43 @@
-require('../BuckarooClient.test')
-import Sofort from '../../src/PaymentMethods/Sofort'
-const method = new Sofort()
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+
+const method = buckarooClientTest.method('sofortueberweisung');
describe('Sofort', () => {
test('Pay', async () => {
- await method
+ return await method
.pay({
- amountDebit: 50.3,
- order: '123456'
+ amountDebit: 100,
+ order: uniqid(),
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 50.3,
- originalTransactionKey: '123456'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
+ expect(info).toBeDefined();
+ });
+ });
test('InstantRefund', async () => {
- await method.instantRefund({
- amountCredit: 4.23,
- originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
- }).then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
+ await method
+ .instantRefund({
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Subscriptions.test.js b/tests/PaymentMethods/Subscriptions.test.js
new file mode 100644
index 00000000..c4baa95f
--- /dev/null
+++ b/tests/PaymentMethods/Subscriptions.test.js
@@ -0,0 +1,154 @@
+import buckarooClientTest from '../BuckarooClient.test';
+const subscription = buckarooClientTest.method('subscriptions');
+test('Create', async () => {
+ subscription
+ .create({
+ additionalParameters: {
+ signature: '123213'
+ },
+ ratePlans: {
+ add: {
+ startDate: '2024-07-23',
+ ratePlanCode: 'zfv59mmy'
+ }
+ },
+ ratePlanCharges: {
+ add: {
+ ratePlanChargeCode: 'test'
+ }
+ },
+ configurationCode: 'gfyh9fe4',
+ configuration: {
+ name: 'owiejr'
+ },
+ debtor: {
+ code: 'johnsmith4'
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data.hasError()).toBeTruthy();
+ })
+ .catch((e) => {
+ expect(e).toBeDefined();
+ })
+ .catch((e) => {
+ expect(e).toBeDefined();
+ });
+});
+test('Update', async () => {
+ subscription
+ .update({
+ email: 'test@buckaroo.nl',
+ subscriptionGuid: 'FC512FC9CC3A485D8CF3D1804FF6xxxx',
+ configurationCode: '9wqe32ew',
+ ratePlan: {
+ update: {
+ ratePlanGuid: 'F075470B1BB24B9291943A888A2Fxxxx',
+ startDate: '2022-01-01',
+ endDate: '2030-01-01'
+ }
+ }
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+});
+test('Combined Subscription', async () => {
+ const combinable = subscription
+ .createCombined({
+ pushURL: 'https://buckaroo.dev/push',
+ includeTransaction: false,
+ transactionVatPercentage: 5,
+ configurationCode: 'gfyh9fe4',
+ email: 'test@buckaroo.nl',
+ ratePlans: {
+ add: {
+ startDate: '2033-01-01',
+ ratePlanCode: '9863hdcj'
+ }
+ },
+ phone: {
+ mobile: '0612345678'
+ },
+ debtor: {
+ code: 'johnsmith4'
+ },
+ company: {
+ culture: 'nl-NL',
+ companyName: 'My Company Coporation',
+ vatApplicable: true,
+ vatNumber: 'NL140619562B01',
+ chamberOfCommerce: '20091741'
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '90',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL'
+ }
+ })
+ .combine('ideal')
+ .pay({
+ issuer: 'ABNANL2A',
+ amountDebit: 10,
+ startRecurrent: true
+ })
+ .request()
+ .then((res) => {
+ expect(res).toBeDefined();
+ });
+});
+test('Update Combined Subscription', async () => {
+ const combinable = subscription
+ .updateCombined({
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D'
+ })
+ .combine('ideal')
+ .pay({
+ issuer: 'ABNANL2A',
+ amountDebit: 10
+ })
+ .request()
+ .then((res) => {
+ expect(res).toBeDefined();
+ });
+});
+test('Stop Subscription', async () => {
+ const stop = await subscription.stop({
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D'
+ });
+ expect(stop).toBeDefined();
+});
+test('Subscription Info', async () => {
+ const info = await subscription.info({
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D'
+ });
+ expect(info).toBeDefined();
+});
+test('Delete Subscription Config', async () => {
+ await subscription
+ .deletePaymentConfig({
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D'
+ })
+ .request()
+ .then((res) => {
+ expect(res.httpResponse.statusCode === 200).toBeTruthy();
+ });
+});
+test('Subscription Pause', async () => {
+ const pause = await subscription.pause({
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D',
+ resumeDate: '2030-01-01'
+ });
+ expect(pause).toBeDefined();
+});
+test('Subscription Resume', async () => {
+ const resume = await subscription.resume({
+ resumeDate: '2030-01-01',
+ subscriptionGuid: '515461997AD34C50881D74157E38A64D'
+ });
+ expect(resume).toBeDefined();
+});
diff --git a/tests/PaymentMethods/Subscriptions.test.ts b/tests/PaymentMethods/Subscriptions.test.ts
index 4193aad2..c78e1157 100644
--- a/tests/PaymentMethods/Subscriptions.test.ts
+++ b/tests/PaymentMethods/Subscriptions.test.ts
@@ -1,145 +1,154 @@
-import Subscriptions from '../../src/PaymentMethods/Subscriptions/index'
-import Ideal from '../../src/PaymentMethods/Ideal/index'
+import buckarooClientTest from '../BuckarooClient.test';
-require('../BuckarooClient.test')
+const subscription = buckarooClientTest.method('subscriptions');
-const subscription = new Subscriptions()
-const ideal = new Ideal()
-
-test('Create', async () => {
- subscription
- .create({
- ratePlan: {
- update: {
- startDate: '2024-07-23',
- ratePlanGuid: ''
- }
- },
- ratePlanCharge: {
+describe('Subscription methods', () => {
+ test('Create', () => {
+ return subscription
+ .create({
+ additionalParameters: {
+ signature: 'XXXXXXXX',
+ },
+ ratePlans: {
+ add: {
+ startDate: '2024-07-23',
+ ratePlanCode: 'XXXXXXXX',
+ },
+ },
+ ratePlanCharges: {
+ add: {
+ ratePlanChargeCode: 'XXXXXXXX',
+ },
+ },
+ configurationCode: 'XXXXXXXX',
+ configuration: {
+ name: 'XXXXXXXX',
+ },
+ debtor: {
+ code: 'XXXXXXXX',
+ },
+ })
+ .request()
+ .then((data) => {
+ expect(data.hasError()).toBeTruthy();
+ });
+ });
+ test('Update', async () => {
+ subscription
+ .update({
+ email: 'test@buckaroo.nl',
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ configurationCode: 'XXXXXXXX',
+ ratePlan: {
+ update: {
+ ratePlanGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ startDate: '2022-01-01',
+ endDate: '2030-01-01',
+ },
+ },
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
+ test('Combined Subscription', async () => {
+ subscription.createCombined({
+ pushURL: 'https://buckaroo.dev/push',
+ includeTransaction: false,
+ transactionVatPercentage: 5,
+ configurationCode: 'XXXXXXXX',
+ email: 'test@buckaroo.nl',
+ ratePlans: {
add: {
- ratePlanChargeCode: 'test'
- }
+ startDate: '2033-01-01',
+ ratePlanCode: 'XXXXXXXX',
+ },
},
- configurationCode: 'gfyh9fe4',
- addConfiguration: {
- name: 'owiejr'
+ phone: {
+ mobile: '0612345678',
},
debtor: {
- code: 'johnsmith4'
- }
- })
- .catch((e) => {
- expect(e.response.data).toBeDefined()
- })
- .catch((e) => {
- expect(e.response.data).toBeDefined()
- })
-})
-test('Update', async () => {
- subscription
- .update({
- email: { email: 'test@buckaroo.nl' },
- subscriptionGuid: 'FC512FC9CC3A485D8CF3D1804FF6xxxx',
- configurationCode: '9wqe32ew',
- ratePlan: {
- update: {
- ratePlanGuid: 'F075470B1BB24B9291943A888A2Fxxxx',
- startDate: '2022-01-01',
- endDate: '2030-01-01'
- }
- }
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
-})
-
-test('Combined Subscription', async () => {
- const combinable = subscription.createCombined({
- address: undefined,
- allowedServices: '',
- b2b: '',
- bankAccount: { accountName: '', bic: '', iban: '' },
- billingTiming: 0,
- // company: undefined,
- configuration: undefined,
- configurationCode: '',
- customerAccountName: '',
- customerBIC: '',
- customerIBAN: '',
- debtor: { code: '' },
- email: { email: '' },
- includeTransaction: false,
- mandateReference: '',
- person: undefined,
- phone: undefined,
- ratePlan: undefined,
- ratePlanCharge: undefined,
- subscriptionGuid: '',
- termStartDay: 0,
- termStartMonth: 0,
- termStartWeek: '',
- transactionVatPercentage: 0
- })
- ideal
- .combine(combinable)
- .pay({
- issuer: 'ABNANL2A',
- amountDebit: 10,
- startRecurrent: true
- })
- .then((res) => {
- expect(res).toBeDefined()
- })
-})
+ code: 'XXXXXXXX',
+ },
+ company: {
+ culture: 'nl-NL',
+ companyName: 'Buckaroo B.V.',
+ vatApplicable: true,
+ vatNumber: 'NLXXXXXXXXXXB01',
+ chamberOfCommerce: 'XXXXXX41',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ });
+ subscription
+ .combine('ideal')
+ .pay({
+ issuer: 'ABNANL2A',
+ amountDebit: 100,
+ startRecurrent: true,
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
-test('Update Combined Subscription', async () => {
- const combinable = subscription.updateCombined({
- subscriptionGuid: '515461997AD34C50881D74157E38A64D'
- })
- ideal
- .combine(combinable)
- .pay({
- issuer: 'ABNANL2A',
- amountDebit: 10
- })
- .then((res) => {
- expect(res).toBeDefined()
- })
-})
+ test('Update Combined Subscription', async () => {
+ subscription.updateCombined({
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ });
+ subscription
+ .combine('ideal')
+ .pay({
+ issuer: 'ABNANL2A',
+ amountDebit: 100,
+ })
+ .request()
+ .then((data) => {
+ expect(data).toBeDefined();
+ });
+ });
-test('Stop Subscription', async () => {
- const stop = await subscription.stop({
- subscriptionGuid: '515461997AD34C50881D74157E38A64D'
- })
- expect(stop).toBeDefined()
-})
-test('Subscription Info', async () => {
- const info = await subscription.info({
- subscriptionGuid: '515461997AD34C50881D74157E38A64D'
- })
- expect(info).toBeDefined()
-})
-test('Delete Subscription Config', async () => {
- await subscription
- .deletePaymentConfig({
- subscriptionGuid: '515461997AD34C50881D74157E38A64D'
- })
- .then((res) => {
- expect(res.status === 200).toBeTruthy()
- })
-})
-test('Subscription Pause', async () => {
- const pause = await subscription.pause({
- subscriptionGuid: '515461997AD34C50881D74157E38A64D',
- resumeDate: '2030-01-01'
- })
- expect(pause).toBeDefined()
-})
-test('Subscription Resume', async () => {
- const resume = await subscription.resume({
- resumeDate: '2030-01-01',
- subscriptionGuid: '515461997AD34C50881D74157E38A64D'
- })
- expect(resume).toBeDefined()
-})
+ test('Stop Subscription', async () => {
+ const stop = await subscription.stop({
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ });
+ expect(stop).toBeDefined();
+ });
+ test('Subscription Info', async () => {
+ const info = await subscription.info({
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ });
+ expect(info).toBeDefined();
+ });
+ test('Delete Subscription Config', async () => {
+ await subscription
+ .deletePaymentConfig({
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ })
+ .request()
+ .then((res) => {
+ expect(res.httpResponse.status === 200).toBeTruthy();
+ });
+ });
+ test('Subscription Pause', async () => {
+ const pause = await subscription.pause({
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ resumeDate: '2030-01-01',
+ });
+ expect(pause).toBeDefined();
+ });
+ test('Subscription Resume', async () => {
+ const resume = await subscription.resume({
+ resumeDate: '2030-01-01',
+ subscriptionGuid: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
+ });
+ expect(resume).toBeDefined();
+ });
+});
diff --git a/tests/PaymentMethods/SurePay.test.js b/tests/PaymentMethods/SurePay.test.js
new file mode 100644
index 00000000..01319efb
--- /dev/null
+++ b/tests/PaymentMethods/SurePay.test.js
@@ -0,0 +1,14 @@
+require('../BuckarooClient.test');
+import SurePay from '../../src/PaymentMethods/Surepay';
+const method = new SurePay();
+describe('Sofort', () => {
+ test('Verify', async () => {
+ await method
+ .verify({
+ customeraccountname: 'string'
+ })
+ .then((info) => {
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/SurePay.test.ts b/tests/PaymentMethods/SurePay.test.ts
index 0efad202..8a29968b 100644
--- a/tests/PaymentMethods/SurePay.test.ts
+++ b/tests/PaymentMethods/SurePay.test.ts
@@ -1,16 +1,20 @@
-require('../BuckarooClient.test')
-import SurePay from '../../src/PaymentMethods/Surepay/index'
+import buckarooClientTest from '../BuckarooClient.test';
-const method = new SurePay()
+const method = buckarooClientTest.method('surepay');
-describe('Sofort', () => {
+describe('SurePay methods', () => {
test('Verify', async () => {
await method
.verify({
- customeraccountname: "string"
+ amountDebit: 100,
+ bankAccount: {
+ iban: 'NLXXTESTXXXXXXXXXX',
+ accountName: 'Test Acceptatie',
+ },
})
+ .request()
.then((info) => {
- expect(info).toBeDefined()
- })
- })
-})
+ expect(info).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Thunes.test.js b/tests/PaymentMethods/Thunes.test.js
new file mode 100644
index 00000000..d02b5a7f
--- /dev/null
+++ b/tests/PaymentMethods/Thunes.test.js
@@ -0,0 +1,25 @@
+require('../BuckarooClient.test');
+import Thunes from '../../src/PaymentMethods/Thunes';
+const thunes = new Thunes();
+describe('Thunes methods', () => {
+ test('authorize', async () => {
+ thunes.authorize({ amountDebit: 0 }).then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('capture', async () => {
+ thunes.capture({ amountDebit: 0, originalTransactionKey: '1' }).then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('getStatus', async () => {
+ thunes.getStatus({ originalTransactionKey: '111111111111' }).then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('cancel', async () => {
+ thunes.cancel({ originalTransactionKey: '111111111111' }).then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Thunes.test.ts b/tests/PaymentMethods/Thunes.test.ts
index e3f329eb..4f660f69 100644
--- a/tests/PaymentMethods/Thunes.test.ts
+++ b/tests/PaymentMethods/Thunes.test.ts
@@ -1,28 +1,56 @@
-require('../BuckarooClient.test')
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
-import Thunes from "../../src/PaymentMethods/Thunes";
-
-const thunes = new Thunes()
+const method = buckarooClientTest.method('thunes');
describe('Thunes methods', () => {
- test('authorize', async () => {
- thunes.authorize({ amountDebit: 0 }).then((res)=>{
- expect(res.data).toBeDefined()
- })
- })
- test('capture', async () => {
- thunes.capture({ amountDebit: 0 ,originalTransactionKey:'1'}).then((res)=>{
- expect(res.data).toBeDefined()
- })
- })
- test('getStatus', async () => {
- thunes.getStatus({originalTransactionKey:'111111111111'}).then((res)=>{
- expect(res.data).toBeDefined()
- })
- })
- test('cancel', async () => {
- thunes.cancel({originalTransactionKey:'111111111111'}).then((res)=>{
- expect(res.data).toBeDefined()
- })
- })
-})
\ No newline at end of file
+ test('authorize', async () => {
+ await method
+ .authorize({
+ amountDebit: 100,
+ order: uniqid(),
+ invoice: uniqid(),
+ name: 'monizzeecovoucher',
+ articles: [
+ {
+ identifier: 'Articlenumber1',
+ description: 'Articledesciption1',
+ price: '1',
+ },
+ {
+ identifier: 'Articlenumber2',
+ description: 'Articledesciption2',
+ price: '2',
+ },
+ ],
+ })
+ .request()
+ .then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('capture', async () => {
+ await method
+ .capture({ amountDebit: 100, originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' })
+ .request()
+ .then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('getStatus', async () => {
+ await method
+ .getStatus({ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' })
+ .request()
+ .then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+ test('cancel', async () => {
+ await method
+ .cancel({ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' })
+ .request()
+ .then((res) => {
+ expect(res.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Tinka.test.js b/tests/PaymentMethods/Tinka.test.js
new file mode 100644
index 00000000..e939962a
--- /dev/null
+++ b/tests/PaymentMethods/Tinka.test.js
@@ -0,0 +1,64 @@
+import Gender from "../../src/Constants/Gender";
+import buckarooClientTest from "../BuckarooClient.test";
+const method = buckarooClientTest.method('tinka');
+describe('Tinka', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ billing: {
+ recipient: {
+ lastNamePrefix: "the"
+ },
+ email: "billingcustomer@buckaroo.nl",
+ phone: {
+ mobile: "0109876543"
+ },
+ address: {
+ street: "Hoofdstraat",
+ houseNumber: "80",
+ houseNumberAdditional: "A",
+ zipcode: "8441EE",
+ city: "Heerenveen",
+ country: "NL"
+ }
+ },
+ customer: {
+ gender: Gender.MALE,
+ firstName: 'Buck',
+ lastName: 'Aroo',
+ initials: 'BA',
+ birthDate: '1990-01-01',
+ },
+ amountDebit: 3.5,
+ articles: [
+ {
+ type: '1',
+ description: "Blue Toy Car",
+ brand: "Ford Focus",
+ manufacturer: "Ford",
+ color: "Red",
+ size: "Small",
+ quantity: 1,
+ price: 3.5,
+ unitCode: "test"
+ }
+ ],
+ deliveryDate: '09-07-2020',
+ deliveryMethod: 'CompanyStore',
+ paymentMethod: 'Credit'
+ }).request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 3.5,
+ originalTransactionKey: '1234567890'
+ }).request()
+ .then((res) => {
+ expect(res.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Tinka.test.ts b/tests/PaymentMethods/Tinka.test.ts
index 3613a782..43c9b0dd 100644
--- a/tests/PaymentMethods/Tinka.test.ts
+++ b/tests/PaymentMethods/Tinka.test.ts
@@ -1,58 +1,65 @@
-require('../BuckarooClient.test')
-import Tinka from '../../src/PaymentMethods/Tinka/index'
-
-const method = new Tinka()
+import { Gender, uniqid } from '../../src';
+import buckarooClientTest from '../BuckarooClient.test';
+const method = buckarooClientTest.method('tinka');
describe('Tinka', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 3.5,
- article: [
+ billing: {
+ email: 'test@buckaroo.nl',
+ phone: {
+ mobile: '0612345678',
+ },
+ address: {
+ street: 'Hoofdstraat',
+ houseNumber: '80',
+ houseNumberAdditional: 'a',
+ zipcode: '8441ER',
+ city: 'Heerenveen',
+ country: 'NL',
+ },
+ },
+ customer: {
+ gender: Gender.MALE,
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ initials: 'BA',
+ birthDate: '1990-01-01',
+ },
+ amountDebit: 100,
+ articles: [
{
- description: 'ewf',
+ type: '1',
+ description: 'Blue Toy Car',
+ brand: 'Ford Focus',
+ manufacturer: 'Ford',
+ color: 'Red',
+ size: 'Small',
quantity: 1,
- unitCode: '',
- unitGrossPrice: 3.5
- }
+ price: 100,
+ unitCode: 'test',
+ },
],
- billingCustomer: {
- city: 'wef',
- country: 'rfew',
- email: 'few@hotmail.com',
- phone: '3161234567',
- postalCode: '345445',
- prefixLastName: 'fsd',
- street: 'ds',
- streetNumber: '32',
- streetNumberAdditional: 'descs'
- },
- dateOfBirth: '',
- deliveryDate: '',
+ deliveryDate: '09-07-2020',
deliveryMethod: 'CompanyStore',
- firstName: '323',
- initials: '',
- lastName: '54',
- paymentMethod: 'Credit'
+ paymentMethod: 'Credit',
})
- .then((info) => {
- expect(info.data).toBeDefined()
- })
- })
+ .request()
+ .then((res) => {
+ expect(res.isPendingProcessing()).toBeTruthy();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 3.5,
- originalTransactionKey: '1234567890'
- })
- .then((info) => {
- expect(info).toBeDefined()
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
- })
-
- test('Specifications', async () => {
- await method.specification().then((info) => {
- expect(info).toBeDefined()
- })
- })
-})
+ .request()
+ .then((res) => {
+ expect(res.isFailed()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Trustly.test.js b/tests/PaymentMethods/Trustly.test.js
new file mode 100644
index 00000000..a226eca6
--- /dev/null
+++ b/tests/PaymentMethods/Trustly.test.js
@@ -0,0 +1,17 @@
+require('../BuckarooClient.test');
+import Trustly from '../../src/PaymentMethods/Trustly';
+const method = new Trustly();
+describe('Trustly', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 12,
+ customerCountryCode: 'DE',
+ customerFirstName: 'da',
+ customerLastName: '34'
+ })
+ .then((response) => {
+ expect(response).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/Trustly.test.ts b/tests/PaymentMethods/Trustly.test.ts
index cd57104b..90ef3466 100644
--- a/tests/PaymentMethods/Trustly.test.ts
+++ b/tests/PaymentMethods/Trustly.test.ts
@@ -1,19 +1,21 @@
-require('../BuckarooClient.test')
-import Trustly from '../../src/PaymentMethods/Trustly/index'
+import buckarooClientTest from '../BuckarooClient.test';
-const method = new Trustly()
+const method = buckarooClientTest.method('trustly');
describe('Trustly', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 12,
- customerCountryCode: 'DE',
- customerFirstName: 'da',
- customerLastName: '34'
+ amountDebit: 100,
+ customer: {
+ firstName: 'Test',
+ lastName: 'Acceptatie',
+ countryCode: 'NL',
+ },
})
+ .request()
.then((response) => {
- expect(response).toBeDefined()
- })
- })
-})
+ expect(response.isPendingProcessing()).toBeTruthy();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/WechatPay.test.js b/tests/PaymentMethods/WechatPay.test.js
new file mode 100644
index 00000000..10c0f9a6
--- /dev/null
+++ b/tests/PaymentMethods/WechatPay.test.js
@@ -0,0 +1,24 @@
+import buckarooClientTest from "../BuckarooClient.test";
+const method = buckarooClientTest.method('wechatpay');
+describe('WechatPay', () => {
+ test('Pay', async () => {
+ await method
+ .pay({
+ amountDebit: 3.5,
+ locale: 'en-US'
+ }).request()
+ .then((response) => {
+ expect(response.isPendingProcessing()).toBeDefined();
+ });
+ });
+ test('Refund', async () => {
+ await method
+ .refund({
+ amountCredit: 3.5,
+ originalTransactionKey: '1234567890'
+ }).request()
+ .then((response) => {
+ expect(response.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/WechatPay.test.ts b/tests/PaymentMethods/WechatPay.test.ts
index b80a7020..187cd06c 100644
--- a/tests/PaymentMethods/WechatPay.test.ts
+++ b/tests/PaymentMethods/WechatPay.test.ts
@@ -1,27 +1,29 @@
-require('../BuckarooClient.test')
-import WechatPay from '../../src/PaymentMethods/WeChatPay/index'
-
-const method = new WechatPay()
+import buckarooClientTest from '../BuckarooClient.test';
+import { uniqid } from '../../src';
+const method = buckarooClientTest.method('wechatpay');
describe('WechatPay', () => {
test('Pay', async () => {
await method
.pay({
- amountDebit: 3.5,
- locale: 'en-US'
+ amountDebit: 100,
+ locale: 'en-US',
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
+ expect(response.isPendingProcessing()).toBeDefined();
+ });
+ });
test('Refund', async () => {
await method
.refund({
- amountCredit: 3.5,
- originalTransactionKey: '1234567890'
+ invoice: uniqid(),
+ amountCredit: 0.01,
+ originalTransactionKey: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
})
+ .request()
.then((response) => {
- expect(response.data).toBeDefined()
- })
- })
-})
+ expect(response.data).toBeDefined();
+ });
+ });
+});
diff --git a/tests/PaymentMethods/idealProcessing.test.ts b/tests/PaymentMethods/idealProcessing.test.ts
deleted file mode 100644
index 8678c2b6..00000000
--- a/tests/PaymentMethods/idealProcessing.test.ts
+++ /dev/null
@@ -1,50 +0,0 @@
-require('../BuckarooClient.test')
-import { uniqid } from '../../src/Utils/Functions'
-import Ideal from '../../src/PaymentMethods/Ideal'
-
-const ideal = new Ideal('idealProcessing')
-describe('testing Ideal processing methods', () => {
- test('Issuers', async () => {
- await ideal.issuers().then((response) => {
- expect(Array.isArray(response)).toBeTruthy()
- })
- })
- test('Pay Simple Payload', async () => {
- await ideal
- .pay({
- amountDebit: 10.1,
- issuer: 'ABNANL2A',
- clientIP: {
- address: '123.456.789.123',
- type: 0
- },
- additionalParameters: {
- initiated_by_magento: 1,
- service_action: 'something'
- }
- })
- .then((data) => {
- expect(data.isPendingProcessing()).toBeTruthy()
- })
- })
- test('Refund', async () => {
- await ideal
- .refund({
- order: uniqid(),
- invoice: uniqid(),
- originalTransactionKey: '97DC0A03BBDF4DAAAC694D7FEC8785E1',
- amountCredit: 4.23,
- clientIP: {
- address: '123.456.789.123',
- type: 0
- },
- additionalParameters: {
- initiated_by_magento: '1',
- service_action: 'something'
- }
- })
- .then((data) => {
- expect(data).toBeDefined()
- })
- })
-})
diff --git a/tsconfig-declarations.json b/tsconfig-declarations.json
new file mode 100644
index 00000000..616f8e18
--- /dev/null
+++ b/tsconfig-declarations.json
@@ -0,0 +1,9 @@
+{
+ "extends": "./tsconfig.json",
+ "files": [],
+ "compilerOptions": {
+ "emitDeclarationOnly": true,
+ "declaration": true,
+ "declarationDir": "dist/types"
+ }
+}
diff --git a/tsconfig.json b/tsconfig.json
index f3c0dec6..a7f1282e 100644
--- a/tsconfig.json
+++ b/tsconfig.json
@@ -2,19 +2,25 @@
"compilerOptions": {
"target": "es5",
"module": "commonjs",
- "lib": ["ES2021", "dom"],
+ "lib": [
+ "ES2021",
+ "dom"
+ ],
"strict": true,
+ "noEmitOnError": true,
"esModuleInterop": true,
- "skipLibCheck": false /* Skip type checking of declaration files. */,
- "forceConsistentCasingInFileNames": true /* Disallow inconsistently-cased references to the same file. */,
+ "skipLibCheck": true
+ /* Skip type checking of declaration files. */,
+ "forceConsistentCasingInFileNames": true
+ /* Disallow inconsistently-cased references to the same file. */,
"declaration": true,
- "outDir": "./dist",
- "rootDir": "./src",
- "experimentalDecorators": true,
+ "sourceMap": true,
"moduleResolution": "node",
- "noImplicitAny": false,
- "typeRoots": ["./node_modules/@types"],
- "resolveJsonModule": true,
+ "noImplicitAny": true,
+ "outDir": "dist",
+ "resolveJsonModule": true
},
- "include": ["src/**/*.ts"],
+ "include": [
+ "src/**/*.ts"
+ ]
}
diff --git a/tsconfig.spec.json b/tsconfig.spec.json
new file mode 100644
index 00000000..0d6da8d0
--- /dev/null
+++ b/tsconfig.spec.json
@@ -0,0 +1,8 @@
+{
+ "compilerOptions": {
+ "types": [
+ "jest",
+ "node"
+ ]
+ }
+}