NodeJs SDK – Order Status
Order Status
It is used to retrieve the status of an order using getOrderStatus() function.
Parameters:
| Parameter Name | Data Type | Mandatory | Description |
|---|---|---|---|
merchantOrderId | String | yes | The merchant order ID for which the status is fetched. |
details | boolean | no | 1. 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:
| Property | Data Type | Description |
|---|---|---|
orderId | string | Order ID created by PhonePe. |
state | string | State of order, Expected Values = 1.PENDING, 2.FAILED, 3.COMPLETED. |
amount | long | Order amount in paisa. |
expireAt | long | order expiry time in epoch. |
paymentDetails | List<PaymentDetail> | Contain list of details of each transaction attempt made corresponding to this particular order |
paymentDetail object has the following properties:
| Attribute | Data Type | Description |
|---|---|---|
paymentMode | String | Mode of Payment. It can be anyone of the following modes: UPI_INTENT UPI_COLLECT UPI_QR CARD TOKEN NET_BANKING |
timestamp | long | Timestamp of the attempted transaction in epoch |
amount | int | Order amount in paisa. |
transactionId | int | internal transaction id for given payment attempt. |
state | String | Transaction attempt state. Expected Values = PENDING, COMPLETED, FAILED |
errorCode | String | Error code (Only present when transaction state is failed) |
detailedErrorCode | String | Detailed Error Code (Only present when transaction state is failed) |
splitInstruments | list | Contains split instrument details of all the transactions made. |
Instrument Combo
| Property | Type | Description |
|---|---|---|
instrument | PaymentInstrumentV2 | Instrument used for the payment |
rails | PaymentRail | Rail used for the payment |
amount | long | Amount transferred using the above instrument and rail |