|
| 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