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.
Environment
| Environment | HTTP Method | API |
| Sandbox | POST | https://api-preprod.phonepe.com/apis/pg-sandbox/payments/v2/sdk/order |
| Production | POST | https://api.phonepe.com/apis/pg/payments/v2/sdk/order |
Request
Request Headers
| Header Name | Header Value |
| Content-Type | application/json |
| Authorization | O-Bearer <merchant-auth-token> |
Request Parameters
| Parameter Name | Data Type | Description | Mandatory (Yes/No) | Constraints |
merchantOrderId | String | Unique merchant order ID generated by you | Yes | Max Length = 63 characters No Special characters are allowed except underscore “_” and hyphen “-“ |
amount | Long | The total amount for the order, in paisa (e.g., ₹10 = 1000 paisa) | Yes | Minimum value = 100 |
expireAfter | Long | The time (in seconds) after which the order will expire. If not provided, the default value will be used | No | Minimum value = 300, maximum value = 3600 (in seconds) |
metaInfo | Object | Meta information is defined by you to store additional information. The same data will be returned in status and callback response. | No | |
metaInfo.udf1-5 | String | Additional details you can add for more information | No | Maximum length = 256 characters |
paymentFlow | Object | Additional details required by this flow | Yes | |
paymentFlow.type | String | Type of payment flow | Yes | 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"
}
}Response
Sample Response
{
"orderId": "OMO123456789",
"state": "PENDING",
"expireAt": 1703756259307,
"token": "<order-token>"
}Response Parameters
| Parameter Name | Data Type | Description |
orderId | String | Payment Gateway generated internal order ID |
state | String | State of the order created, expected value is CREATED |
expiryAt | Long | Order expiry date in epoch |
token | String | Order Token that should be passed to your app and then to the PhonePe SDK |
Try it yourself!
headers
body params
What’s Next?
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.