Order Status


Once a subscription setup is initiated, it’s essential to track the state of the associated order. The getOrderStatus() method allows you to fetch the current status of an order using the merchantOrderId.

Parameter NameData TypeMandatoryDescription
merchantOrderIdStringYesThe unique order ID generated by the merchant.
Code Reference
import com.phonepe.sdk.pg.Env;
import com.phonepe.sdk.pg.common.models.response.OrderStatusResponse;
import com.phonepe.sdk.pg.subscription.v2.SubscriptionClient;
 
String clientId = "<clientId>";
String clientSecret = "<clientSecret>";
Integer clientVersion = "<clientVersion>";  //insert your client version here
Env env = Env.SANDBOX;      //change to Env.PRODUCTION when you go live
 
SubscriptionClient subscriptionClient = SubscriptionClient.getInstance(clientId, clientSecret, clientVersion, env);
 
String merchantOrderId = "";
 
OrderStatusResponse orderStatusResponse = subscriptionClient.getOrderStatus(merchantOrderId);
String state = orderStatusResponse.getState();

The function returns a OrderStatusResponse object with the following properties:

Parameter NameData TypeDescription
orderidStringUnique order ID generated by PhonePe.
stateStringOrder status:
• PENDING
• FAILED
• COMPLETED
amountLongOrder amount in paise
expireAtLongOrder expire date in epoch.
paymentDetailsList<PaymentDetail>Contains information about each payment attempt.

PaymentDetail Properties:

Parameter NameData 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 transaction (epoch).
amountLongAmount involved in the transaction (paise).
transactionIdStringUnique transaction ID generated by PhonePe
stateStringTransaction state:
PENDING
COMPLETED
FAILED
errorCodeStringPresent only if transaction failed
detailedErrorCodeStringAdditional failure details.
paymentFlowPaymentFlowResponseShows the flow type: SETUP, REDEMPTION.
splitInstrumentsList<InstrumentCombo>Details of instruments used during split transactions.
Subscription Setup
AttributeData TypeDescription
merchantSubscriptionIdStringUnique subscription ID from the merchant.
authWorkflowTypeAuthWorkflowTypeType of setup workflow
TRANSACTION
PENNY_DROP
amountTypeAmountTypeType of redemption amount
FIXED
VARIABLE
maxAmountLongMaximum redemption limit.
frequencyFrequencySubscription Frequency:
DAILY
WEEKLY
MONTHLY
YEARLY
FORTNIGHTLY
BIMONTHLY
ON_DEMAND
QUATERLY
HALFYEARLY
expireAtLongSubscription cycle expiry. No operation allowed after subscription expires.
subscriptionIdStringSubscription ID generated by PhonePe.
Subscription Redemption
AttributeData TypeDescription
merchantSubscriptionIdStringUnique subscription ID from the merchant.
redemptionRetryStrategyRedemptionRetryStrategyRedemption retry strategy if a payment attempt fails:
STANDARD – PhonePe will automatically retry.
CUSTOM – Merchant is responsible for retrying manually.
autoDebitBooleanWith auto-debit enabled, the amount will be deducted automatically 24 hours after a successful notify. This won’t work if you’re using the CUSTOM retry option.
validAfterLongEpoch time after which redemption is valid.
validUptoLongEpoch time until which redemption is valid.
notifiedAtLongEpoch time when notify was triggered.
AttributeData TypeDescription
instrumentPaymentInstrumentV2Payment instrument used.
railsPaymentRailPayment rail used.
amountLongAmount transferred using the specified rail/instrument.

Now that you know how to check the status of an order that was created, let’s move on to checking the subscription status.

Is this article helpful?