Check Order Status with Node.js SDK
It is used to check the status of an order.
Request
The request parameters are as follows:
| Parameter Name | Data Type | Mandatory (Yes/No) | Description |
merchantOrderId | String | Yes | The merchant order ID for which the status is fetched. |
details | String | No | • true → Returns all payment attempt details under the paymentDetails list. • false → Returns only the latest payment attempt details. |
Sample Request
import { StandardCheckoutClient, Env } from 'pg-sdk-node';
const clientId:string = "<clientId>";
const clientSecret:string = "<clientSecret>";
const clientVersion:string = <clientVersion>; //insert your client version here
const env:Env = Env.SANDBOX; //change to Env.PRODUCTION when you go live
const client = StandardCheckoutClient.getInstance(clientId, clientSecret, clientVersion, env);
const merchantOrderId = '<MERCHANT_ORDER_ID>'; //Order Id used for creating new order
client.getOrderStatus(merchantOrderId).then((response) => {
const state = response.state;
});Response
The function returns an OrderStatusResponse object with the following properties:
| Property | Data Type | Description |
order_id | String | Order ID generated by PhonePe PG. |
state | String | Current state of the order: Expected values: • PENDING • FAILED • COMPLETED |
amount | Integer | Order amount in paisa. |
expire_at | Integer | Expiry time of the order in epoch. |
metaInfo | MetaInfo | Meta information provided by you during order creation. |
payment_details | List<PaymentDetail> | List of payment attempt details corresponding to the 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.
| Property | Data Type | Description |
transactionId | Integer | The transaction ID generated by PhonePe PG. |
paymentMode | String | The payment method used • UPI_INTENT • UPI_COLLECT • UPI_QR • CARD • TOKEN • NET_BANKING |
| timestamp | Long | Timestamp of the attempted transaction in epoch. |
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) |
splitInstruments | list<InstrumentCombo> | Contains split instrument details of all the transactions made. |
splitInstruments provides a list of InstrumentCombo objects. Details of each InstrumentCombo object are explained in the table below.
list
| Property | Data Type | Type |
| PaymentInstrumentV2 | Instrument used for the payment. |
| PaymentRail | Rail used for the payment. |
| Integer | Amount transferred using the above instrument and rail. |
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.