diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index de5afd4..bd27136 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -27,7 +27,7 @@ jobs:
python -m twine check dist/*
- name: 'Upload Artifact'
- uses: actions/upload-artifact@v2
+ uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
@@ -61,7 +61,7 @@ jobs:
steps:
- uses: actions/checkout@v2
- name: Download all workflow run artifacts
- uses: actions/download-artifact@v2
+ uses: actions/download-artifact@v4
with:
name: dist
path: dist
diff --git a/documents/token.md b/documents/token.md
index 349a6d8..bf2c885 100644
--- a/documents/token.md
+++ b/documents/token.md
@@ -398,6 +398,27 @@ client.token.processPaymentOnAlternatePAorPG({"id":"spt_4lsdksD31GaZ09"})
}
```
-------------------------------------------------------------------------------------------------------
+
+### Cancel Token
+
+```py
+client.token.cancel(customerId, tokenId)
+```
+
+**Parameters:**
+
+| Name | Type | Description |
+|---------------|-------------|--------------------------------------|
+| customerId* | string | The id of the customer to be fetched |
+| tokenId* | string | The id of the token to be fetched |
+
+**Response:**
+```json
+{
+ "status": "cancellation_initiated"
+}
+```
+-------------------------------------------------------------------------------------------------------
**PN: * indicates mandatory fields**
diff --git a/razorpay/resources/token.py b/razorpay/resources/token.py
index 61bf9ea..a52ed9d 100644
--- a/razorpay/resources/token.py
+++ b/razorpay/resources/token.py
@@ -87,3 +87,16 @@ def processPaymentOnAlternatePAorPG(self, data={}, **kwargs):
"""
url = '{}{}/{}'.format(URL.V1, URL.TOKEN, "service_provider_tokens/token_transactional_data")
return self.post_url(url, data, **kwargs)
+
+ def cancel(self, customer_id, token_id, data={}, **kwargs):
+ """
+ Cancel Given Token
+
+ Args:
+ customer_id : Customer Id for which token have to be cancelled
+ token_id : Id for which Token object has to be cancelled
+ Returns:
+ Dict for cancel token
+ """
+ url = f"{self.base_url}/{customer_id}/tokens/{token_id}/cancel"
+ return self.put_url(url, data, **kwargs)
diff --git a/tests/test_client_token.py b/tests/test_client_token.py
index 6780278..7215a23 100644
--- a/tests/test_client_token.py
+++ b/tests/test_client_token.py
@@ -103,3 +103,15 @@ def test_token_processPaymentOnAlternatePAorPG(self):
self.assertEqual(
self.client.token.processPaymentOnAlternatePAorPG(init),
result)
+
+ @responses.activate
+ def test_canel_token(self):
+ url = f"{self.base_url}/{self.customer_id}/tokens/{self.token_id}/cancel"
+ responses.add(responses.PUT,
+ url,
+ status=200,
+ body=json.dumps({'status': 'cancellation_initiated'}),
+ match_querystring=True)
+ self.assertEqual(
+ self.client.token.cancel(self.customer_id, self.token_id),
+ {'status': 'cancellation_initiated'})