From dad4ace7204dea041e52cb90d96d84ceb83527b0 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 9 Mar 2026 12:33:22 +0530 Subject: [PATCH 1/2] added cancel token --- documents/token.md | 21 +++++++++++++++++++++ lib/resources/customers.js | 8 +++++++- lib/types/customers.d.ts | 8 ++++++++ test/resources/customers.spec.js | 20 ++++++++++++++++++++ 4 files changed, 56 insertions(+), 1 deletion(-) diff --git a/documents/token.md b/documents/token.md index 34ba1f0..f575270 100644 --- a/documents/token.md +++ b/documents/token.md @@ -384,6 +384,27 @@ instance.tokens.processPaymentOnAlternatePAorPG({"id":"spt_4lsdksD31GaZ09"}); } ``` ------------------------------------------------------------------------------------------------------- + +### Cancel Token + +```js +instance.customers.cancelToken('cust_1Aa00000000001','token_1Aa00000000001') +``` + +**Parameters:** + +| Name | Type | Description | +| ------------ | ------ | --------------------------------------------------------------------------- | +| customerId* | string | The unique identifier of the customer with whom the token is linked. | +| tokenId* | string | The unique identifier of the token that is to be cancelled. | + +**Response:** +```json +{ + "status": "cancellation_initiated" +} +``` +------------------------------------------------------------------------------------------------------- **PN: * indicates mandatory fields**

diff --git a/lib/resources/customers.js b/lib/resources/customers.js index 4642cfe..e9cf475 100644 --- a/lib/resources/customers.js +++ b/lib/resources/customers.js @@ -79,6 +79,12 @@ module.exports = function (api) { return api.get({ url: `/customers/eligibility/${eligibilityId}`, }, callback) - } + }, + + cancelToken(customerId, tokenId, callback) { + return api.put({ + url: `/customers/${customerId}/tokens/${tokenId}/cancel`, + }, callback); + }, } } diff --git a/lib/types/customers.d.ts b/lib/types/customers.d.ts index c18d5c6..2972d44 100644 --- a/lib/types/customers.d.ts +++ b/lib/types/customers.d.ts @@ -243,6 +243,14 @@ declare function customers(api: any): { * @param eligibilityId - The unique identifier of the eligibility request to be retrieved. */ fetchEligibility(eligibilityId: string): Promise> + /** + * Cancel a token + * + * @param customerId - The unique identifier of the customer with whom the token is linked. + * @param tokenId - The unique identifier of the token that is to be cancelled. + */ + cancelToken(customerId: string, tokenId: string): Promise<{ success: boolean }> + cancelToken(customerId: string, tokenId: string, callback: (err: INormalizeError | null, data: { success: boolean }) => void): void; } export default customers \ No newline at end of file diff --git a/test/resources/customers.spec.js b/test/resources/customers.spec.js index 97cc2c9..1379bf0 100644 --- a/test/resources/customers.spec.js +++ b/test/resources/customers.spec.js @@ -284,4 +284,24 @@ describe('CUSTOMERS', () => { done() }) }) + + it('Cancel token', (done) => { + const TEST_CUSTOMER_ID = 'cust_PNSQEApWqQgwux' + const TEST_TOKEN_ID = 'token_RBBG4pD0oBpZ64' + + mocker.mock({ + url: `/customers/${TEST_CUSTOMER_ID}/tokens/${TEST_TOKEN_ID}/cancel`, + method: 'PUT' + }) + + rzpInstance.customers.cancelToken(TEST_CUSTOMER_ID, TEST_TOKEN_ID).then((response) => { + assert.equal( + response.__JUST_FOR_TESTS__.url, + `/v1/customers/${TEST_CUSTOMER_ID}/tokens/${TEST_TOKEN_ID}/cancel`, + 'Cancel token url formed correctly' + ) + done() + }) + }) + }) From 2a21624d2eaaab74807e3e5a4376098005d5ff84 Mon Sep 17 00:00:00 2001 From: ankitdas13 Date: Mon, 9 Mar 2026 14:35:32 +0530 Subject: [PATCH 2/2] update response type --- lib/types/customers.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/types/customers.d.ts b/lib/types/customers.d.ts index 2972d44..995beb4 100644 --- a/lib/types/customers.d.ts +++ b/lib/types/customers.d.ts @@ -249,8 +249,8 @@ declare function customers(api: any): { * @param customerId - The unique identifier of the customer with whom the token is linked. * @param tokenId - The unique identifier of the token that is to be cancelled. */ - cancelToken(customerId: string, tokenId: string): Promise<{ success: boolean }> - cancelToken(customerId: string, tokenId: string, callback: (err: INormalizeError | null, data: { success: boolean }) => void): void; + cancelToken(customerId: string, tokenId: string): Promise<{ status: string }> + cancelToken(customerId: string, tokenId: string, callback: (err: INormalizeError | null, data: { status: string }) => void): void; } export default customers \ No newline at end of file