Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 53 additions & 43 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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 <client-libraries@gocardless.com>",
"repository": {
Expand Down
52 changes: 52 additions & 0 deletions src/codeSamples/billing_requestsCodeSamples.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
});
});
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
2 changes: 1 addition & 1 deletion src/services/mandateService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 3 additions & 2 deletions src/services/paymentService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
23 changes: 17 additions & 6 deletions src/types/Types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2222,8 +2222,8 @@ export type BillingRequestWithActionPaymentRequest = {
// class="notice"><strong>Important</strong>: To be able to use intelligent
// retries, Success+ needs to be enabled in [GoCardless
// dashboard](https://manage.gocardless.com/success-plus). </p> <p
// class="notice"><strong>Important</strong>: This is not applicable to IBP
// and VRP payments. </p>
// class="notice"><strong>Important</strong>: This is not applicable to Pay by
// Bank and VRP payments. </p>
retry_if_possible?: boolean;

// (Optional) A scheme used for Open Banking payments. Currently
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 };
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading