Python SDK – Order Status

It is used to retrieve the status of an order using getOrderStatus() function.

Parameters:

Parameter NameData TypeMandatoryDescription
merchant_order_idstryesThe merchant order ID for which the status is fetched.
detailsbooleanno1. 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 = "&lt;YOUR_CLIENT_ID&gt;"
client_secret = "&lt;YOUR_CLIENT_SECRET&gt;"
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 = "&lt;YOUR_MERCHANT_ORDER_ID&gt;"
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:

PropertyData TypeDescription
order_idstringOrder ID created by PhonePe.
statestringState of order, Expected Values = 
1.PENDING,
2.FAILED,
3.COMPLETED.
amountlongOrder amount in paisa.
expire_atlongorder expiry time in epoch.
payment_detailslistPaymentDetialContain list of details of each transaction attempt made corresponding to this particular order

paymentDetail object has the following properties:

AttributeData TypeDescription
payment_modestrMode of Payment. It can be anyone of the following modes:
UPI_INTENT
UPI_COLLECT
UPI_QR
CARD
TOKEN
NET_BANKING
timestamplongTimestamp of the attempted transaction in epoch
amountintOrder amount in paisa.
transaction_idintinternal transaction id for given payment attempt.
statestrTransaction attempt state. Expected Values = 
PENDING, COMPLETED, FAILED
error_codestrError code (Only present when transaction state is failed)
detailed_error_codestrDetailed Error Code (Only present when transaction state is failed)
splitInstrumentslistContains split instrument details of all the transactions made.
Is this article helpful?