Order Status


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

Parameter NameData TypeMandatoryDescription
merchant_order_idStringYesThe unique order ID generated by the merchant.
Code Reference
from phonepe.sdk.pg.subscription.v2.subscription_client import SubscriptionClient
 
client_id = "<client_id>"
client_secret = "<client_secret>"
client_version = 1          # insert your client version here
env = Env.SANDBOX           # change to Env.PRODUCTION when you go live
 
subscription_client = SubscriptionClient.get_instance(client_id,client_secret,client_version,env)
 
merchant_order_id = "<merchant_order_id>"
 
order_status_response = subscription_client.get_order_status(merchant_order_id)
state = order_status_response.state

The function returns a OrderStatusResponse object with the following properties:

Parameter NameData TypeDescription
order_idStringUnique order ID generated by PhonePe.
stateStringOrder status:
PENDING
FAILED
COMPLETED
amountIntOrder amount in paise
expire_atIntOrder expire date in epoch.
payment_detailsList<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).
transaction_idStringUnique transaction ID generated by PhonePe
stateStringTransaction state:
PENDING
COMPLETED
FAILED
error_codeStringPresent only if transaction failed
detailed_error_codeStringAdditional failure details.
payment_flowPaymentFlowResponseShows the flow type:
SETUP
REDEMPTION.
split_instrumentsList<InstrumentCombo>Details of instruments used during split transactions.
PaymentFlow Response for Subscription Setup
AttributeData TypeDescription
merchant_subscription_idStringUnique subscription ID from the merchant.
auth_workflow_typeAuthWorkflowTypeType of setup workflow
TRANSACTION
PENNY_DROP
amount_typeAmountTypeType of redemption amount
FIXED
VARIABLE
max_amountLongMaximum redemption limit.
frequencyFrequencySubscription Frequency:
DAILY
WEEKLY
MONTHLY
YEARLY
FORTNIGHTLY
BIMONTHLY
ON_DEMAND
QUATERLY
HALFYEARLY
expire_atLongSubscription cycle expiry. No operation allowed after subscription expires.
subscription_idStringSubscription ID generated by PhonePe.
PaymentFlow Response for Subscription Redemption
AttributeData TypeDescription
merchant_subscription_idStringUnique subscription ID from the merchant.
redemption_retry_strategyRedemptionRetryStrategyRedemption retry strategy if a payment attempt fails:
STANDARD – PhonePe will automatically retry.
CUSTOM – Merchant is responsible for retrying manually.
auto_debitBooleanWith 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.
valid_afterIntegerEpoch time after which redemption is valid.
valid_uptoIntegerEpoch time until which redemption is valid.
notified_atIntegerEpoch 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?