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..995beb4 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<{ 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
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()
+ })
+ })
+
})