From c640e9ebfcd30f3052483d43bff5e70903998066 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Armando=20Rodr=C3=ADguez?= <127134616+armando-rodriguez-cko@users.noreply.github.com> Date: Fri, 26 Apr 2024 15:19:10 +0200 Subject: [PATCH] Add SEPA Direct Debit Core Support (#382) --- package-lock.json | 4 +-- test/instruments/instruments-it.js | 58 ++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 test/instruments/instruments-it.js diff --git a/package-lock.json b/package-lock.json index 335dc63..fa16c6f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "checkout-sdk-node", - "version": "2.3.4", + "version": "2.3.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "checkout-sdk-node", - "version": "2.3.4", + "version": "2.3.5", "license": "MIT", "dependencies": { "axios": "^0.27.2", diff --git a/test/instruments/instruments-it.js b/test/instruments/instruments-it.js new file mode 100644 index 0000000..14ec9f5 --- /dev/null +++ b/test/instruments/instruments-it.js @@ -0,0 +1,58 @@ +import { expect } from "chai"; +import nock from "nock"; +import Checkout from '../../src/Checkout.js' +import { ValidationError } from "../../src/services/errors.js"; + +afterEach(() => { + nock.cleanAll(); + nock.enableNetConnect(); +}); + +const cko = new Checkout(process.env.CHECKOUT_DEFAULT_SECRET_KEY, { + pk: process.env.CHECKOUT_PREVIOUS_PUBLIC_KEY, + environment: 'sandbox', +}); + +const sepaRequest = { + "type": "sepa", + "instrument_data": { + "account_number": "FR2810096000509685512959O86", + "country": "FR", + "currency": "EUR", + "payment_type": "recurring", + "mandate_id": "1234567890", + "date_of_signature": "2020-01-01" + }, + "account_holder": { + "first_name": "John", + "last_name": "Smith", + "billing_address": { + "address_line1": "Cloverfield St.", + "address_line2": "23A", + "city": "London", + "zip": "SW1A 1AA", + "country": "GB" + } + } +} + +describe('Instruments::Create', () => { + describe('Sepa', () => { + + it('Should create a Sepa Instrument', async () => { + const response = await cko.instruments.create(sepaRequest); + + expect(response).to.not.be.null; + expect(response.id).to.not.be.null; + expect(response.fingerprint).to.not.be.null; + }); + + it('Should return a ValidationError with invalid Sepa Instrument Request', async () => { + try { + await cko.instruments.create({}); + } catch (error) { + expect(error).to.be.instanceOf(ValidationError); + } + }); + }); +}); \ No newline at end of file