Skip to content

Commit bb50bd9

Browse files
committed
feat: Added expire_payment_link
1 parent dc21e37 commit bb50bd9

3 files changed

Lines changed: 63 additions & 0 deletions

File tree

README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ except SetuAPIException as e:
9292
assert False
9393
```
9494

95+
### Expire bill payment
96+
97+
```python
98+
try:
99+
dl.expire_payment_link(link.platform_bill_id)
100+
except SetuAPIException as e:
101+
assert False
102+
```
103+
95104
### Initiate Refund
96105

97106
```python

setu/deeplink.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,15 @@ def trigger_mock_payment(self, amount_value: float, upi_id: str, platform_bill_i
187187
mock_credit_response_data_schema = MockCreditResponseDataSchema()
188188
return mock_credit_response_data_schema.load(api_response.json()['data'])
189189

190+
@Decorators.auth_handler
191+
def expire_payment_link(self, platform_bill_id: str):
192+
"""Expire payment link."""
193+
self.session.post(
194+
get_url_path(API.EXPIRE_BILL, self.auth_type, self.mode).format(platform_bill_id),
195+
headers=self.headers,
196+
)
197+
return
198+
190199
@Decorators.auth_handler
191200
def trigger_mock_settlement(self, utrs: List[str]):
192201
"""Trigger mock settlement."""

tests/test_deeplink_expire.py

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
"""Tests for `setu` package."""
2+
import logging
3+
from datetime import datetime, timedelta
4+
5+
from setu import Deeplink, SetuAPIException
6+
7+
LOGGER = logging.getLogger(__name__)
8+
9+
10+
def test_deeplink_expire(v2_creds):
11+
"""Test creation of deeplink with minimal parameters."""
12+
dl = Deeplink(
13+
scheme_id=v2_creds.scheme_id,
14+
secret=v2_creds.secret,
15+
product_instance_id="861023031961584801",
16+
auth_type="OAUTH",
17+
mode="SANDBOX",
18+
)
19+
20+
try:
21+
# Create Payment Link
22+
link = dl.create_payment_link(
23+
amount_value=1000,
24+
biller_bill_id="test_transaction_1234",
25+
amount_exactness="EXACT",
26+
payee_name="Python SDK unittest",
27+
transaction_note="unittest transaction",
28+
expiry_date=datetime.now() + timedelta(days=3),
29+
)
30+
LOGGER.info(link)
31+
assert link.platform_bill_id
32+
33+
# Get Payment Link Status
34+
link_status = dl.check_payment_status(link.platform_bill_id)
35+
LOGGER.info(link_status)
36+
assert link_status.status == "BILL_CREATED"
37+
38+
dl.expire_payment_link(link.platform_bill_id)
39+
link_status = dl.check_payment_status(link.platform_bill_id)
40+
LOGGER.info(link_status)
41+
assert link_status.status == "BILL_EXPIRED"
42+
43+
except SetuAPIException as e:
44+
LOGGER.error(e.error)
45+
assert True

0 commit comments

Comments
 (0)