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.
Parameters
| Parameter Name | Data Type | Mandatory | Description |
| String | Yes | The unique order ID generated by the merchant. |
Example code
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();Return Values
The function returns a OrderStatusResponse object with the following properties:
| Parameter Name | Data Type | Description |
orderid | String | Unique order ID generated by PhonePe. |
| String | Order status: • PENDING • FAILED • COMPLETED |
amount | Long | Order amount in paise |
| expireAt | Long | Order expire date in epoch. |
paymentDetails | List<PaymentDetail> | Contains information about each payment attempt. |
PaymentDetail Properties:
| Parameter Name | Data Type | Description |
| String | Mode of Payment. It can be anyone of the following modes: • UPI_INTENT• UPI_COLLECT• UPI_QR• CARD• TOKEN• NET_BANKING |
| Long | Timestamp of the transaction (epoch). |
amount | Long | Amount involved in the transaction (paise). |
transactionId | String | Unique transaction ID generated by PhonePe |
| String | Transaction state: • PENDING • COMPLETED• FAILED |
errorCode | String | Present only if transaction failed |
detailedErrorCode | String | Additional failure details. |
paymentFlow | PaymentFlowResponse | Shows the flow type: SETUP, REDEMPTION. |
splitInstruments | List<InstrumentCombo> | Details of instruments used during split transactions. |
PaymentFlow Response
Subscription Setup
| Attribute | Data Type | Description |
| String | Unique subscription ID from the merchant. |
| AuthWorkflowType | Type of setup workflow • TRANSACTION • PENNY_DROP |
| AmountType | Type of redemption amount • FIXED • VARIABLE |
maxAmount | Long | Maximum redemption limit. |
| Frequency | Subscription Frequency: • DAILY • WEEKLY • MONTHLY • YEARLY • FORTNIGHTLY • BIMONTHLY • ON_DEMAND • QUATERLY • HALFYEARLY |
| Long | Subscription cycle expiry. No operation allowed after subscription expires. |
| String | Subscription ID generated by PhonePe. |
Subscription Redemption
| Attribute | Data Type | Description |
| String | Unique subscription ID from the merchant. |
| RedemptionRetryStrategy | Redemption retry strategy if a payment attempt fails: • STANDARD – PhonePe will automatically retry. • CUSTOM – Merchant is responsible for retrying manually. |
| Boolean | With 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. |
| Long | Epoch time after which redemption is valid. |
| Long | Epoch time until which redemption is valid. |
| Long | Epoch time when notify was triggered. |
InstrumentCombo
| Attribute | Data Type | Description |
instrument | PaymentInstrumentV2 | Payment instrument used. |
rails | PaymentRail | Payment rail used. |
amount | Long | Amount transferred using the specified rail/instrument. |
What’s Next?
Now that you know how to check the status of an order that was created, let’s move on to checking the subscription status.