Skip to content

Commit

Permalink
Merge pull request #96 from gocardless/template-changes
Browse files Browse the repository at this point in the history
Changes from gocardless-nodejs-template
  • Loading branch information
vdandugc committed Aug 16, 2021
2 parents 69df83e + d9e408c commit 9d7401e
Show file tree
Hide file tree
Showing 14 changed files with 998 additions and 336 deletions.
22 changes: 22 additions & 0 deletions LICENSE.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Copyright (c) 2021 GoCardless

MIT License

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
501 changes: 255 additions & 246 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "gocardless-nodejs",
"version": "2.1.0",
"version": "2.2.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 <[email protected]>",
"repository": {
Expand Down Expand Up @@ -39,7 +39,7 @@
"nock": "^13.0.11",
"typescript": "^4.2.4"
},
"main": "src/index.js",
"main": "index.js",
"types": "types/Types.d.ts",
"engines": {
"node": ">=10.0"
Expand Down
13 changes: 13 additions & 0 deletions src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { BankAuthorisationService } from './services/bankAuthorisationService';
import { BankDetailsLookupService } from './services/bankDetailsLookupService';
import { BillingRequestService } from './services/billingRequestService';
import { BillingRequestFlowService } from './services/billingRequestFlowService';
import { BillingRequestTemplateService } from './services/billingRequestTemplateService';
import { CreditorService } from './services/creditorService';
import { CreditorBankAccountService } from './services/creditorBankAccountService';
import { CurrencyExchangeRateService } from './services/currencyExchangeRateService';
Expand Down Expand Up @@ -37,6 +38,7 @@ export class GoCardlessClient {
private _bankDetailsLookups: BankDetailsLookupService;
private _billingRequests: BillingRequestService;
private _billingRequestFlows: BillingRequestFlowService;
private _billingRequestTemplates: BillingRequestTemplateService;
private _creditors: CreditorService;
private _creditorBankAccounts: CreditorBankAccountService;
private _currencyExchangeRates: CurrencyExchangeRateService;
Expand Down Expand Up @@ -68,6 +70,7 @@ export class GoCardlessClient {
this._bankDetailsLookups = undefined;
this._billingRequests = undefined;
this._billingRequestFlows = undefined;
this._billingRequestTemplates = undefined;
this._creditors = undefined;
this._creditorBankAccounts = undefined;
this._currencyExchangeRates = undefined;
Expand Down Expand Up @@ -125,6 +128,16 @@ export class GoCardlessClient {
return this._billingRequestFlows;
}

get billingRequestTemplates(): BillingRequestTemplateService {
if (!this._billingRequestTemplates) {
this._billingRequestTemplates = new BillingRequestTemplateService(
this._api
);
}

return this._billingRequestTemplates;
}

get creditors(): CreditorService {
if (!this._creditors) {
this._creditors = new CreditorService(this._api);
Expand Down
2 changes: 1 addition & 1 deletion src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ enum Environments {
Sandbox = 'SANDBOX',
}

const CLIENT_VERSION = '2.1.0';
const CLIENT_VERSION = '2.2.0';
const API_VERSION = '2015-07-06';

export { Environments, CLIENT_VERSION, API_VERSION };
35 changes: 32 additions & 3 deletions src/services/billingRequestFlowService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,22 @@ interface BillingRequestFlowListResponse extends Types.APIResponse {
}

interface BillingRequestFlowCreateRequest {
// Fulfil the Billing Request on completion of the flow (true by default)

auto_fulfil?: boolean;

// Resources linked to this BillingRequestFlow.
links: Types.BillingRequestFlowCreateRequestLinks;

// If true, the payer will not be able to edit their existing details (e.g.
// customer and bank account) within the billing request flow.
// If true, the payer will not be able to change their bank account within the
// flow

lock_bank_account?: boolean;

lock_existing_details?: boolean;
// If true, the payer will not be able to edit their customer details within the
// flow

lock_customer_details?: boolean;

// URL that the payer can be redirected to after completing the request flow.

Expand Down Expand Up @@ -58,4 +67,24 @@ export class BillingRequestFlowService {

return formattedResponse;
}

async initialise(identity: string): Promise<BillingRequestFlowResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_request_flows/:identity/actions/initialise',
method: 'post',
urlParameters,

payloadKey: null,
fetch: null,
};

const response = await this.api.request(requestParams);
const formattedResponse: BillingRequestFlowResponse = {
...response.body['billing_request_flows'],
__response__: response.__response__,
};

return formattedResponse;
}
}
47 changes: 39 additions & 8 deletions src/services/billingRequestService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,6 @@ interface BillingRequestListRequest {
}

interface BillingRequestCreateRequest {
// Should the billing request be fulfilled as soon as it's ready

auto_fulfil?: boolean;

// Resources linked to this BillingRequest.
links?: Types.BillingRequestCreateRequestLinks;

Expand All @@ -74,7 +70,7 @@ interface BillingRequestCollectCustomerDetailsRequest {
customer_billing_detail?: Types.BillingRequestCustomerBillingDetail;
}

interface BillingRequestCollectBankAccountDetailsRequest {
interface BillingRequestCollectBankAccountRequest {
// Name of the account holder, as known by the bank. Usually this is the same as
// the name stored with the linked [creditor](#core-endpoints-creditors). This
// field will be transliterated, upcased and truncated to 18 characters. This
Expand All @@ -88,6 +84,11 @@ interface BillingRequestCollectBankAccountDetailsRequest {

account_number?: string;

// Account number suffix (only for bank accounts denominated in NZD) - see
// [local details](#local-bank-details-new-zealand) for more information.

account_number_suffix?: string;

// Bank account type. Required for USD-denominated bank accounts. Must not be
// provided for bank accounts in other currencies. See [local
// details](#local-bank-details-united-states) for more information.
Expand Down Expand Up @@ -137,6 +138,13 @@ interface BillingRequestFulfilRequest {
metadata?: Types.JsonMap;
}

interface BillingRequestConfirmPayerDetailsRequest {
// 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?: Types.JsonMap;
}

interface BillingRequestCancelRequest {
// 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.
Expand Down Expand Up @@ -267,13 +275,13 @@ export class BillingRequestService {
return formattedResponse;
}

async collect_bank_account_details(
async collect_bank_account(
identity: string,
requestParameters: BillingRequestCollectBankAccountDetailsRequest
requestParameters: BillingRequestCollectBankAccountRequest
): Promise<BillingRequestResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_requests/:identity/actions/collect_bank_account_details',
path: '/billing_requests/:identity/actions/collect_bank_account',
method: 'post',
urlParameters,
requestParameters,
Expand Down Expand Up @@ -313,6 +321,29 @@ export class BillingRequestService {
return formattedResponse;
}

async confirm_payer_details(
identity: string,
requestParameters: BillingRequestConfirmPayerDetailsRequest
): Promise<BillingRequestResponse> {
const urlParameters = [{ key: 'identity', value: identity }];
const requestParams = {
path: '/billing_requests/:identity/actions/confirm_payer_details',
method: 'post',
urlParameters,
requestParameters,
payloadKey: null,
fetch: null,
};

const response = await this.api.request(requestParams);
const formattedResponse: BillingRequestResponse = {
...response.body['billing_requests'],
__response__: response.__response__,
};

return formattedResponse;
}

async cancel(
identity: string,
requestParameters: BillingRequestCancelRequest
Expand Down
Loading

0 comments on commit 9d7401e

Please sign in to comment.