Skip to content

Commit

Permalink
Add SEPA Direct Debit Core Support
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko committed Apr 23, 2024
1 parent 7fc5ffb commit 802f6af
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 2 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

58 changes: 58 additions & 0 deletions test/instruments/instruments-it.js
Original file line number Diff line number Diff line change
@@ -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);
}
});
});
});

0 comments on commit 802f6af

Please sign in to comment.