Skip to content

Commit 6606666

Browse files
authored
Added cancel token (#325)
1 parent 24f0797 commit 6606666

File tree

4 files changed

+48
-2
lines changed

4 files changed

+48
-2
lines changed

.github/workflows/ci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
python -m twine check dist/*
2828
2929
- name: 'Upload Artifact'
30-
uses: actions/upload-artifact@v2
30+
uses: actions/upload-artifact@v4
3131
with:
3232
name: dist
3333
path: dist/
@@ -61,7 +61,7 @@ jobs:
6161
steps:
6262
- uses: actions/checkout@v2
6363
- name: Download all workflow run artifacts
64-
uses: actions/download-artifact@v2
64+
uses: actions/download-artifact@v4
6565
with:
6666
name: dist
6767
path: dist

documents/token.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,27 @@ client.token.processPaymentOnAlternatePAorPG({"id":"spt_4lsdksD31GaZ09"})
398398
}
399399
```
400400
-------------------------------------------------------------------------------------------------------
401+
402+
### Cancel Token
403+
404+
```py
405+
client.token.cancel(customerId, tokenId)
406+
```
407+
408+
**Parameters:**
409+
410+
| Name | Type | Description |
411+
|---------------|-------------|--------------------------------------|
412+
| customerId* | string | The id of the customer to be fetched |
413+
| tokenId* | string | The id of the token to be fetched |
414+
415+
**Response:**
416+
```json
417+
{
418+
"status": "cancellation_initiated"
419+
}
420+
```
421+
-------------------------------------------------------------------------------------------------------
401422
**PN: * indicates mandatory fields**
402423
<br>
403424
<br>

razorpay/resources/token.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,3 +87,16 @@ def processPaymentOnAlternatePAorPG(self, data={}, **kwargs):
8787
"""
8888
url = '{}{}/{}'.format(URL.V1, URL.TOKEN, "service_provider_tokens/token_transactional_data")
8989
return self.post_url(url, data, **kwargs)
90+
91+
def cancel(self, customer_id, token_id, data={}, **kwargs):
92+
"""
93+
Cancel Given Token
94+
95+
Args:
96+
customer_id : Customer Id for which token have to be cancelled
97+
token_id : Id for which Token object has to be cancelled
98+
Returns:
99+
Dict for cancel token
100+
"""
101+
url = f"{self.base_url}/{customer_id}/tokens/{token_id}/cancel"
102+
return self.put_url(url, data, **kwargs)

tests/test_client_token.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,3 +103,15 @@ def test_token_processPaymentOnAlternatePAorPG(self):
103103
self.assertEqual(
104104
self.client.token.processPaymentOnAlternatePAorPG(init),
105105
result)
106+
107+
@responses.activate
108+
def test_canel_token(self):
109+
url = f"{self.base_url}/{self.customer_id}/tokens/{self.token_id}/cancel"
110+
responses.add(responses.PUT,
111+
url,
112+
status=200,
113+
body=json.dumps({'status': 'cancellation_initiated'}),
114+
match_querystring=True)
115+
self.assertEqual(
116+
self.client.token.cancel(self.customer_id, self.token_id),
117+
{'status': 'cancellation_initiated'})

0 commit comments

Comments
 (0)