Check Order Status with Python SDK
The Order Status API allows you to check the current status of a payment order by using the getOrderStatus() function.
Request
| Parameter Name | Data Type | Mandatory (Yes/No) | Description |
merchant_order_id | String | Yes | The order ID for which the status needs to be fetched |
details | Boolean | no | • true → Returns all payment attempt details under the paymentDetails list. • false → Returns only the latest payment attempt details. |
Sample Request
from phonepe.sdk.pg.payments.v2.standard_checkout_client import StandardCheckoutClient
from phonepe.sdk.pg.env import Env
client_id = "<YOUR_CLIENT_ID>"
client_secret = "<YOUR_CLIENT_SECRET>"
client_version = <CLIENT_VERSION> # Insert your client version here
env = Env.SANDBOX # Change to Env.PRODUCTION when you go live
should_publish_events = False
client = StandardCheckoutClient.get_instance(client_id=client_id,
client_secret=client_secret,
client_version=client_version,
env=env,
should_publish_events=should_publish_events)
merchant_order_id = "YOUR_MERCHANT_ORDER_ID"
response = client.get_order_status(merchant_order_id, details=False)
state = response.stateResponse
The function returns a OrderStatusResponse object with the following properties:
The function returns a OrderStatusResponse object with the following properties:
| Property | Data Type | Description |
orderId | String | Order ID generated by PhonePe PG. |
state | String | Current state of the order: Expected values: • PENDING • FAILED • COMPLETED |
expireAt | Number | Expiry time in epoch. |
amount | Long | Order amount in paisa. |
metaInfo | Object | A MetaInfo object containing additional metadata about the order. |
errorCode | String | Error code (only present when the transaction state is FAILED). |
detailedErrorCode | String | Detailed error code (only present when the transaction state is FAILED). |
paymentDetails | List<PaymentDetail> | Contain list of details of each payment attempt made corresponding to this order. |
The paymentDetails property contains a list of payment details for each payment attempt made against an order. The details of each payment are explained in the table below.
List
| Property | Data Type | Description |
transactionId | String | The transaction ID generated by PhonePe PG. |
paymentMode | String | The payment method used • UPI_INTENT • UPI_COLLECT • UPI_QR • CARD • TOKEN • NET_BANKING |
amount | Integer | Order amount in paisa. |
state | String | Attempted transaction state. It can be any one of the following states: • PENDING • COMPLETED • FAILED |
errorCode | String | Error code (only if the transaction failed) |
detailedErrorCode | String | A more detailed error code (only if the transaction failed) |
| String | Type of payment instrument. Expected values: • ACCOUNT • CREDIT_CARD • DEBIT_CARD • NET_BANKING |
What’s Next?
You’ve understood how to retrieve the status of an order using the getOrderStatus() function. Now, let’s move on to learn how to process refunds, which allows you to return funds to the customer for eligible transactions.