-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7fc5ffb
commit 325b1d3
Showing
2 changed files
with
60 additions
and
2 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { NotFoundError, ValidationError } from "../../src/services/errors.js"; | ||
Check notice Code scanning / CodeQL Unused variable, import, function or class Note test
Unused import NotFoundError.
|
||
|
||
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); | ||
} | ||
}); | ||
}); | ||
}); |