diff --git a/package-lock.json b/package-lock.json index 042ff66f..022e806b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "gocardless-nodejs", - "version": "8.3.0", + "version": "8.4.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "gocardless-nodejs", - "version": "8.3.0", + "version": "8.4.0", "license": "MIT", "dependencies": { "got": "^11.8.6", @@ -1289,14 +1289,14 @@ } }, "node_modules/@napi-rs/wasm-runtime": { - "version": "1.1.4", - "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.4.tgz", - "integrity": "sha512-3NQNNgA1YSlJb/kMH1ildASP9HW7/7kYnRI2szWJaofaS1hWmbGI4H+d3+22aGzXXN9IJ+n+GiFVcGipJP18ow==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/@napi-rs/wasm-runtime/-/wasm-runtime-1.1.5.tgz", + "integrity": "sha512-AWPoBRJ9tsnVhor4sjO7rkni+7p+2IAEFj6cx06UgP10jkQHqay/36uRV/bFkgrh18D9vb4cr8Q0Pthskgzy+Q==", "dev": true, "license": "MIT", "optional": true, "dependencies": { - "@tybys/wasm-util": "^0.10.1" + "@tybys/wasm-util": "^0.10.2" }, "funding": { "type": "github", @@ -1357,13 +1357,13 @@ } }, "node_modules/@pkgr/core": { - "version": "0.2.9", - "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.2.9.tgz", - "integrity": "sha512-QNqXyfVS2wm9hweSYD2O7F0G06uurj9kZ96TRQE5Y9hU7+tgdZwIkbAKc5Ocy1HxEY2kuDQa6cQ1WRs/O5LFKA==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/@pkgr/core/-/core-0.3.6.tgz", + "integrity": "sha512-SEeaJLb3qBNF/OaXnaR1NmmBbFYk1zC0ZH/52fATcRPLFg/p791YrcyFFy44Bo9sLaGuSuLp5Q6axbb/O+v/RA==", "dev": true, "license": "MIT", "engines": { - "node": "^12.20.0 || ^14.18.0 || >=16.0.0" + "node": "^14.18.0 || >=16.0.0" }, "funding": { "url": "https://opencollective.com/pkgr" @@ -2486,9 +2486,9 @@ "license": "MIT" }, "node_modules/baseline-browser-mapping": { - "version": "2.10.32", - "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.32.tgz", - "integrity": "sha512-wbPvpyjJPC0zdfdKXxqEL3Ea+bOMD/87X4lftiJkkaBiuG6ALQy1SLmEd7BSmVCuwCQsBrCamgBoLyfFDD1EPg==", + "version": "2.10.35", + "resolved": "https://registry.npmjs.org/baseline-browser-mapping/-/baseline-browser-mapping-2.10.35.tgz", + "integrity": "sha512-honAfLBde0HAFLdNyBEfuuENkF6zR+ozxqxa/2zJKHBe1qzLqyTSeRKpdPEHAP03rlDGyQOPnCSxnVpVqQo9Mg==", "dev": true, "license": "Apache-2.0", "bin": { @@ -2715,9 +2715,9 @@ } }, "node_modules/caniuse-lite": { - "version": "1.0.30001793", - "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001793.tgz", - "integrity": "sha512-iwSsYWaCOoh26cV8NwNRViHlrfUvYsHDfRVcbtmw0Kg6PJIZZXwMkj1442FYLBGkeUf1juAsU3DTfxW579mrPA==", + "version": "1.0.30001797", + "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001797.tgz", + "integrity": "sha512-l8xKG+gwAIExZGl9FrF7KUwuOmk6wbEPC9Xoy/RtnWv1XG0Q4LFlagaLpUv3Kiza3W/wm27zy0yWJEieYKAP6w==", "dev": true, "funding": [ { @@ -3102,9 +3102,9 @@ "license": "MIT" }, "node_modules/electron-to-chromium": { - "version": "1.5.362", - "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.362.tgz", - "integrity": "sha512-PUY2DrLvkjkUuWqq+KPL2iWshrJsZOcIojzRQ7eXFacc9dWga7MGMJAa15VbiejSZB1PAXaRLAiKgruHP8LB1w==", + "version": "1.5.371", + "resolved": "https://registry.npmjs.org/electron-to-chromium/-/electron-to-chromium-1.5.371.tgz", + "integrity": "sha512-e9htk9mAYL6AzmkEhSvVVw7IWGSBJ/Bqdn2eRyRLrj1g6sncN4WbFt5qnILYoCktktr45pyjIrOiRvBThQ808w==", "dev": true, "license": "ISC" }, @@ -4019,9 +4019,9 @@ } }, "node_modules/hasown": { - "version": "2.0.3", - "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.3.tgz", - "integrity": "sha512-ej4AhfhfL2Q2zpMmLo7U1Uv9+PyhIZpgQLGT1F9miIGmiCJIoCgSmczFdrc97mWT4kVY72KA+WnnhJ5pghSvSg==", + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/hasown/-/hasown-2.0.4.tgz", + "integrity": "sha512-T2UbfbBEF32wiepXIsMlTW9+dDYC6wMh/t/vYA4tuOMKqWz/n3vr1NFSxQiyP+zk2mXsoMA/i/7qV6LKut1t1A==", "license": "MIT", "dependencies": { "function-bind": "^1.1.2" @@ -4917,10 +4917,20 @@ "license": "MIT" }, "node_modules/js-yaml": { - "version": "4.1.1", - "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.1.tgz", - "integrity": "sha512-qQKT4zQxXl8lLwBtHMWwaTcGfFOZviOJet3Oy/xmGk2gZH677CJM9EvtfdSkgWcATZhj/55JZ0rmy3myCT5lsA==", + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.2.0.tgz", + "integrity": "sha512-ePWsvanv0DWuDRsW8dnt+R4jQ31SCRCQ7hhNcPXZPsoBZiemuZNYGf7adZdqX2D86j6rvKp3RpCxVTSb8WQlOw==", "dev": true, + "funding": [ + { + "type": "github", + "url": "https://github.com/sponsors/puzrin" + }, + { + "type": "github", + "url": "https://github.com/sponsors/nodeca" + } + ], "license": "MIT", "dependencies": { "argparse": "^2.0.1" @@ -5412,9 +5422,9 @@ "license": "MIT" }, "node_modules/node-releases": { - "version": "2.0.46", - "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.46.tgz", - "integrity": "sha512-GYVXHE2KnrzAfsAjl4uP++evGFCrAU1jta4ubEjIG7YWt/64Gqv66a30yKwWczVjA6j3bM4nBwH7Pk1JmDHaxQ==", + "version": "2.0.47", + "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-2.0.47.tgz", + "integrity": "sha512-Uzmd6LXpouKo8EUK68IjH4+E01w/hXyV3R3g/geCJo+rXLNfh1xucB+LOzYEOQPSiUK3h/xZf0cQGcSsmyL2Og==", "dev": true, "license": "MIT", "engines": { @@ -6306,9 +6316,9 @@ }, "node_modules/react-is-19": { "name": "react-is", - "version": "19.2.6", - "resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.6.tgz", - "integrity": "sha512-XjBR15BhXuylgWGuslhDKqlSayuqvqBX91BP8pauG8kd1zY8kotkNWbXksTCNRarse4kuGbe2kIY05ARtwNIvw==", + "version": "19.2.7", + "resolved": "https://registry.npmjs.org/react-is/-/react-is-19.2.7.tgz", + "integrity": "sha512-kZFnouyVv7eP/Phmrlo9FK+zcAdriZJvzxXHF1Sl1P377WSGe2G/JxVolhTrB/jeV47lKImhNUsijjHAAbcl/A==", "dev": true, "license": "MIT" }, @@ -6479,9 +6489,9 @@ "license": "ISC" }, "node_modules/semver": { - "version": "7.8.1", - "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.1.tgz", - "integrity": "sha512-rkVq3IXh+4FDGch+KwzX3aV9W3kO54GyEgpvBzSyctDA6Xtd7RJQV1xmXbeQp5v7+VzLOfVqiutSE6GICgPFvg==", + "version": "7.8.4", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.8.4.tgz", + "integrity": "sha512-rUCObTnP32Q08R2uuIrt7r9PlEonuTmtuXYcW6s5kjdlj3xbnwe+21yXptAUYcMAABLkYYTtnmzb3w3EDZfueA==", "dev": true, "license": "ISC", "bin": { @@ -6522,14 +6532,14 @@ } }, "node_modules/side-channel": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", - "integrity": "sha512-ZX99e6tRweoUXqR+VBrslhda51Nh5MTQwou5tnUDgbtyM0dBgmhEDtWGP/xbKn6hqfPRHujUNwz5fy/wbbhnpw==", + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.1.tgz", + "integrity": "sha512-6x6dK6zJdpTzF4sQeNYxwtvBzf6Eg4GtlesS94HOvTudUeyK2WXAaIfmDgsyslYrRBeFIlsi54AYsFGUuhmvrQ==", "license": "MIT", "dependencies": { "es-errors": "^1.3.0", - "object-inspect": "^1.13.3", - "side-channel-list": "^1.0.0", + "object-inspect": "^1.13.4", + "side-channel-list": "^1.0.1", "side-channel-map": "^1.0.1", "side-channel-weakmap": "^1.0.2" }, @@ -6825,13 +6835,13 @@ } }, "node_modules/synckit": { - "version": "0.11.12", - "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.12.tgz", - "integrity": "sha512-Bh7QjT8/SuKUIfObSXNHNSK6WHo6J1tHCqJsuaFDP7gP0fkzSfTxI8y85JrppZ0h8l0maIgc2tfuZQ6/t3GtnQ==", + "version": "0.11.13", + "resolved": "https://registry.npmjs.org/synckit/-/synckit-0.11.13.tgz", + "integrity": "sha512-eNRKgb3z66Yp3D2CixVujOUvXLFUTij/zVnV8KRyvFdQwpz7I5DS8UfRkTeLzb64u+dkzDSdelE24izu+zSSUg==", "dev": true, "license": "MIT", "dependencies": { - "@pkgr/core": "^0.2.9" + "@pkgr/core": "^0.3.6" }, "engines": { "node": "^14.18.0 || >=16.0.0" diff --git a/package.json b/package.json index c4267022..245dbf25 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "gocardless-nodejs", - "version": "8.3.0", + "version": "8.4.0", "description": "Node.js client for the GoCardless API - a powerful, simple solution for the collection of recurring bank-to-bank payments", "author": "GoCardless Ltd ", "repository": { diff --git a/src/codeSamples/billing_requestsCodeSamples.test.ts b/src/codeSamples/billing_requestsCodeSamples.test.ts index 77c074d5..fedb2572 100644 --- a/src/codeSamples/billing_requestsCodeSamples.test.ts +++ b/src/codeSamples/billing_requestsCodeSamples.test.ts @@ -282,4 +282,56 @@ describe('BillingRequests Code Samples', () => { console.log = originalLog; } }); + + test('fallback code sample executes without error', async () => { + // Convert :param placeholders to regex wildcards for flexible matching + const stubUrl = '/billing_requests/:identity/actions/fallback'; + const pathPattern = new RegExp('^' + stubUrl.replace(/:[\w]+/g, '[^/?]+') + '(?:\\?.*)?$'); + + // Mock response - repeat multiple times to handle code samples with multiple API calls + const responseBody = { billing_requests: {} }; + for (let i = 0; i < 5; i++) { + nock('https://api.gocardless.com').post(pathPattern).query(true).reply(200, responseBody); + } + + // Suppress console.log from code samples + const originalLog = console.log; + // eslint-disable-next-line @typescript-eslint/no-empty-function + console.log = () => {}; + + try { + /* eslint-disable @typescript-eslint/no-unused-vars */ + const resp = await client.billingRequests.fallback('BR123'); + /* eslint-enable @typescript-eslint/no-unused-vars */ + } finally { + console.log = originalLog; + } + }); + + test('choose_currency code sample executes without error', async () => { + // Convert :param placeholders to regex wildcards for flexible matching + const stubUrl = '/billing_requests/:identity/actions/choose_currency'; + const pathPattern = new RegExp('^' + stubUrl.replace(/:[\w]+/g, '[^/?]+') + '(?:\\?.*)?$'); + + // Mock response - repeat multiple times to handle code samples with multiple API calls + const responseBody = { billing_requests: {} }; + for (let i = 0; i < 5; i++) { + nock('https://api.gocardless.com').post(pathPattern).query(true).reply(200, responseBody); + } + + // Suppress console.log from code samples + const originalLog = console.log; + // eslint-disable-next-line @typescript-eslint/no-empty-function + console.log = () => {}; + + try { + /* eslint-disable @typescript-eslint/no-unused-vars */ + const resp = await client.billingRequests.chooseCurrency('BR123', { + currency: 'GBP', + }); + /* eslint-enable @typescript-eslint/no-unused-vars */ + } finally { + console.log = originalLog; + } + }); }); diff --git a/src/constants.ts b/src/constants.ts index e49695f6..027b99f5 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -3,7 +3,7 @@ enum Environments { Sandbox = 'SANDBOX', } -const CLIENT_VERSION = '8.3.0'; +const CLIENT_VERSION = '8.4.0'; const API_VERSION = '2015-07-06'; export { Environments, CLIENT_VERSION, API_VERSION }; diff --git a/src/services/mandateService.ts b/src/services/mandateService.ts index 8bd3c51b..22e2d95a 100644 --- a/src/services/mandateService.ts +++ b/src/services/mandateService.ts @@ -91,7 +91,7 @@ interface MandateListRequest { // Mandate type - mandate_type?: string; + mandate_type?: `${Types.MandateMandateType}`; // Unique reference. Different schemes have different length and [character // set](#appendix-character-sets) requirements. GoCardless will generate a diff --git a/src/services/paymentService.ts b/src/services/paymentService.ts index 34799c46..bbd3408d 100644 --- a/src/services/paymentService.ts +++ b/src/services/paymentService.ts @@ -136,8 +136,9 @@ interface PaymentListRequest { mandate?: string; // A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", - // "becs_nz", "betalingsservice", "faster_payments", "pad", "pay_to" and - // "sepa_core" are supported. + // "becs_nz", "betalingsservice", "faster_payments", "pad", "pay_to", + // "sepa_core", "sepa_credit_transfer" and "sepa_instant_credit_transfer" are + // supported. scheme?: string; diff --git a/src/types/Types.ts b/src/types/Types.ts index 65911ef1..6bd0d737 100644 --- a/src/types/Types.ts +++ b/src/types/Types.ts @@ -2222,8 +2222,8 @@ export type BillingRequestWithActionPaymentRequest = { // class="notice">Important: To be able to use intelligent // retries, Success+ needs to be enabled in [GoCardless // dashboard](https://manage.gocardless.com/success-plus).

Important: This is not applicable to IBP - // and VRP payments.

+ // class="notice">Important: This is not applicable to Pay by + // Bank and VRP payments.

retry_if_possible?: boolean; // (Optional) A scheme used for Open Banking payments. Currently @@ -4468,8 +4468,7 @@ export type EventLinks = { payment_account_transaction?: string; // If `resource_type` is `billing_requests`, this is the ID of the - // [payment](#core-endpoints-payments) which has been created for Instant Bank - // Payment. + // [payment](#core-endpoints-payments) which has been created for Pay by Bank. payment_request_payment?: string; // If `resource_type` is `payouts`, this is the ID of the @@ -4857,6 +4856,9 @@ export type Mandate = { // Resources linked to this Mandate. links?: MandateLinks; + // Mandate type + mandate_type?: `${MandateMandateType}` | null; + // Key-value store of custom data. Up to 3 keys are permitted, with key names // up to 50 characters and values up to 500 characters. metadata?: { [key: string]: string }; @@ -4931,6 +4933,14 @@ export type MandateCreateRequestLinks = { customer_bank_account: string; }; +export enum MandateMandateType { + BankDebit = 'bank_debit', + Instant = 'instant', + Recurring = 'recurring', + VrpCommercial = 'vrp_commercial', + VrpSweeping = 'vrp_sweeping', +} + /** Type for a mandateconsentparameters resource. */ export type MandateConsentParameters = { // The latest date at which payments can be taken, must occur after start_date @@ -6092,8 +6102,9 @@ export type Payment = { retry_if_possible?: boolean; // A bank payment scheme. Currently "ach", "autogiro", "bacs", "becs", - // "becs_nz", "betalingsservice", "faster_payments", "pad", "pay_to" and - // "sepa_core" are supported. + // "becs_nz", "betalingsservice", "faster_payments", "pad", "pay_to", + // "sepa_core", "sepa_credit_transfer" and "sepa_instant_credit_transfer" are + // supported. scheme?: string | null; // One of: