Creating Order Token

You need to call this API from your backend to get an Order Token. Then, pass this token to your app, which will send it to the PhonePe SDK.

EnvironmentHTTP MethodAPI
SandboxPOSThttps://api-preprod.phonepe.com/apis/pg-sandbox/payments/v2/sdk/order
ProductionPOSThttps://api.phonepe.com/apis/pg/payments/v2/sdk/order
Request Headers
Header NameHeader Value
Content-Typeapplication/json
AuthorizationO-Bearer <merchant-auth-token>
Request Parameters
Parameter NameData TypeDescriptionMandatory (Yes/No)Constraints
merchantOrderIdStringUnique merchant order ID generated by youYesMax Length = 63 characters
No Special characters are allowed except underscore “_” and hyphen “-“
amountLongThe total amount for the order, in paisa (e.g., ₹10 = 1000 paisa)YesMinimum value = 100
expireAfterLongThe time (in seconds) after which the order will expire. If not provided, the default value will be usedNo
Minimum value = 300, maximum value = 3600 (in seconds)
metaInfoObjectMeta information is defined by you to store additional information. The same data will be returned in status and callback response.No
metaInfo.udf1-5StringAdditional details you can add for more informationNo
Maximum length = 256 characters 
paymentFlowObjectAdditional details required by this flowYes
paymentFlow.typeStringType of payment flowYes
Valued allowed = [PG_CHECKOUT]
Sample Request
{
  "merchantOrderId": "TX123456",
  "amount": 100,
  "expireAfter": 1200,
  "metaInfo": {
    "udf1": "<additional-information-1>",
    "udf2": "<additional-information-2>",
    "udf3": "<additional-information-3>",
    "udf4": "<additional-information-4>",
    "udf5": "<additional-information-5>"
  },
  "paymentFlow": {
    "type": "PG"
  }
}
Sample Response
{
  "orderId": "OMO123456789",
  "state": "PENDING",
  "expireAt": 1703756259307,
  "token": "<order-token>"
}
Response Parameters
Parameter NameData TypeDescription
orderIdStringPayment Gateway generated internal order ID
stateStringState of the order created, expected value is CREATED
expiryAtLongOrder expiry date in epoch
tokenStringOrder Token that should be passed to your app and then to the PhonePe SDK
headers
body params

Once the Order Token is created, the next step is to check the current status of the payment using the merchant order ID.

Go to Check Order Status to see the real-time payment status.

Is this article helpful?