Skip to content

Commit

Permalink
Add SEPA Direct Debit Core Support (#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
armando-rodriguez-cko authored Apr 26, 2024
1 parent 581fea6 commit c640e9e
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 c640e9e

Please sign in to comment.