Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions documents/token.md
Original file line number Diff line number Diff line change
Expand Up @@ -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**
<br>
<br>
Expand Down
13 changes: 13 additions & 0 deletions razorpay/resources/token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 12 additions & 0 deletions tests/test_client_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'})