Python SDK – Order Status
It is used to retrieve the status of an order using getOrderStatus() function.
Parameters:
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
merchant_order_id | str | yes | The merchant order ID for which the status is fetched. |
details | boolean | no | 1. true → return all attempt details under paymentDetails 2. false → return only latest attempt details under paymentDetails list |
Example:
<!-- wp:code -->
<pre class="wp-block-code"><code><strong>from</strong> phonepe.sdk.pg.payments.v2.custom_checkout_client <strong>import</strong> CustomCheckoutClient
<strong>from</strong> phonepe.sdk.pg.env <strong>import</strong> Env
client_id = "<YOUR_CLIENT_ID>"
client_secret = "<YOUR_CLIENT_SECRET>"
client_version = 1 # Insert your client version here
env = Env.SANDBOX # Change to Env.PRODUCTION when you go live
custom_checkout_client = CustomCheckoutClient.get_instance(client_id=client_id,
client_secret=client_secret,
client_version=client_version,
env=env)
merchant_order_id = "<YOUR_MERCHANT_ORDER_ID>"
response = custom_checkout_client.get_order_status(merchant_order_id, details=False)
state = response.state</code></pre>
<!-- /wp:code -->Returns :
The function returns a OrderStatusResponse object with the following properties:
OrderStatusResponse Properties:
| Property | Data Type | Description |
|---|---|---|
order_id | string | Order ID created by PhonePe. |
state | string | State of order, Expected Values = 1.PENDING, 2.FAILED, 3.COMPLETED. |
amount | long | Order amount in paisa. |
expire_at | long | order expiry time in epoch. |
payment_details | listPaymentDetial | Contain list of details of each transaction attempt made corresponding to this particular order |
paymentDetail object has the following properties:
| Attribute | Data Type | Description |
|---|---|---|
payment_mode | str | Mode of Payment. It can be anyone of the following modes: UPI_INTENT UPI_COLLECT UPI_QR CARD TOKEN NET_BANKING |
timestamp | long | Timestamp of the attempted transaction in epoch |
amount | int | Order amount in paisa. |
transaction_id | int | internal transaction id for given payment attempt. |
state | str | Transaction attempt state. Expected Values = PENDING, COMPLETED, FAILED |
error_code | str | Error code (Only present when transaction state is failed) |
detailed_error_code | str | Detailed Error Code (Only present when transaction state is failed) |
splitInstruments | list | Contains split instrument details of all the transactions made. |