NodeJs SDK – Order Status

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

Parameters:

Parameter NameData TypeMandatoryDescription
merchantOrderIdStringyesThe 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:

import {
CustomCheckoutClient, 
Env, 
OrderStatusResponse} 
from 'pg-sdk-node'
 

const clientId:string = "<clientId>";

const clientSecret:string = "<clientSecret>";

const clientVersion:number = 1;  //insert your client version here

const env = 
Env.SANDBOX;      //change to Env.PRODUCTION when you go live
 

const client = 
CustomCheckoutClient.
getInstance(clientId, clientSecret, clientVersion, env);
 

String merchantOrderId = "<MERCHANT_ORDER_ID>";  //Order Id used for creating new order
 
client.
getOrderStatus(merchantOrderId).
then((response)=>{
    
const state = response.state
})

Returns :

The function returns a OrderStatusResponse object with the following properties:

OrderStatusResponse Properties:

PropertyData TypeDescription
orderIdstringOrder ID created by PhonePe.
statestringState of order, Expected Values = 
1.PENDING,
2.FAILED,
3.COMPLETED.
amountlongOrder amount in paisa.
expireAtlongorder expiry time in epoch.
paymentDetailsList<PaymentDetail>Contain list of details of each transaction attempt made corresponding to this particular order

paymentDetail object has the following properties:

AttributeData TypeDescription
paymentModeStringMode 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.
transactionIdintinternal transaction id for given payment attempt.
stateStringTransaction attempt state. Expected Values = 
PENDING, COMPLETED, FAILED
errorCodeStringError code (Only present when transaction state is failed)
detailedErrorCodeStringDetailed Error Code (Only present when transaction state is failed)
splitInstrumentslistContains split instrument details of all the transactions made.

Instrument Combo

PropertyTypeDescription
instrumentPaymentInstrumentV2Instrument used for the payment
railsPaymentRailRail used for the payment
amountlongAmount transferred using the above instrument and rail
Is this article helpful?