Check Order Status with Node.js SDK


It is used to check the status of an order.

The request parameters are as follows:

Parameter NameData TypeMandatory
(Yes/No)
Description
merchantOrderIdStringYesThe merchant order ID for which the status is fetched.
detailsStringNotrue → 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;
});

The function returns an OrderStatusResponse object with the following properties:

PropertyData TypeDescription
order_idStringOrder ID generated by PhonePe PG.
stateStringCurrent state of the order: Expected values:
PENDING
FAILED
COMPLETED
amountIntegerOrder amount in paisa.
expire_atIntegerExpiry time of the order in epoch.
metaInfoMetaInfoMeta information provided by you during order creation.
payment_detailsList<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.

PropertyData TypeDescription
transactionIdIntegerThe transaction ID generated by PhonePe PG.
paymentModeStringThe payment method used
UPI_INTENT
UPI_COLLECT
UPI_QR
CARD
TOKEN
NET_BANKING
timestampLongTimestamp of the attempted transaction in epoch.
amountIntegerOrder amount in paisa.
stateStringAttempted transaction state. It can be any one of the following states:
PENDING
COMPLETED
FAILED
errorCodeStringError code (only if the transaction failed)
detailedErrorCodeStringA more detailed error code (only if the transaction failed)
splitInstrumentslist<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
PropertyData TypeType
instrumentPaymentInstrumentV2Instrument used for the payment.
railsPaymentRailRail used for the payment.
amountIntegerAmount transferred using the above instrument and rail.

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.

Is this article helpful?