Create 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/checkout/v2/sdk/order |
| Production | POST | https://api.phonepe.com/apis/pg/checkout/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 | Merchant defined meta info to store additional information. same data will be returned in status and callback response. | No | For udf1 to udf 10, there is no constraint. For udf11 to udf15, alphanumeric values with _-+@. are allowed. |
paymentFlow | Object | Additional details required by this flow | Yes |
The metaInfo object contains additional parameters, which are explained in the table below.
Request Parameters of metoInfo Object:
| Parameter Name | Data Type | Description | Mandatory (Yes/No) | Constraints |
metaInfo.udf1-15 | String | Optional details you can add for more information | No | • Maximum length for Udf1-10 = 256 characters • Maximum length for Udf11-15 = 50 characters |
The paymentFlow object contains additional parameter, which is explained in the table below.
Request Parameters of paymentFlow Object:
| Parameter Name | Data Type | Description | Mandatory (Yes/No) | Constraints |
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>",
"udf6": "additional-information-6",
"udf7": "additional-information-7",
"udf8": "additional-information-8",
"udf9": "additional-information-9",
"udf10": "additional-information-10",
"udf11": "additional-information-11",
"udf12": "additional-information-12",
"udf13": "additional-information-13",
"udf14": "additional-information-14",
"udf15": "additional-information-15"
},
"paymentFlow": {
"type": "PG_CHECKOUT"
}
}Sample Request Body with Selected Instrument
{
"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>",
"udf6": "<additional-information-6>",
"udf7": "<additional-information-7>",
"udf8": "<additional-information-8>",
"udf9": "<additional-information-9>",
"udf10": "<additional-information-10>",
"udf11": "<additional-information-11>",
"udf12": "<additional-information-12>",
"udf13": "<additional-information-13>",
"udf14": "<additional-information-14>",
"udf15": "<additional-information-15>"
},
"paymentFlow": {
"type": "PG_CHECKOUT",
"paymentModeConfig": {
"enabledPaymentModes": [
{
"type": "UPI_INTENT"
},
{
"type": "UPI_COLLECT"
},
{
"type": "UPI_QR"
},
{
"type": "NET_BANKING"
},
{
"type": "CARD",
"cardTypes": [
"DEBIT_CARD",
"CREDIT_CARD"
]
}
],
"disabledPaymentModes": [
{
"type": "UPI_INTENT"
},
{
"type": "UPI_COLLECT"
},
{
"type": "UPI_QR"
},
{
"type": "NET_BANKING"
},
{
"type": "CARD",
"cardTypes": [
"DEBIT_CARD",
"CREDIT_CARD"
]
}
]
}
}
}Response
Sample Response
{
"orderId": "OMO123456789",
"state": "PENDING",
"expireAt": 1703756259307,
"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 |
Important:
- Include the
paymentModeConfigblock only if you want to control the payment instruments displayed at checkout - If this block is not passed, PhonePe will show the default enabled instruments
- Either
enabledPaymentModesordisabledPaymentModesmust be provided—not both. If both are included, the API will return an error.
Managing Payment Modes
enabledPaymentModes: Displays only the specified payment instruments. Any other instruments enabled by PhonePe will not be showndisabledPaymentModes: Hides only the specified payment instruments. All other instruments enabled by PhonePe will still be displayed
Special Case: Card Payments
When configuring card payments, ensure cardTypes is included along with type.
- If
enabledPaymentModes.type = "CARD"butcardTypesis not provided, the checkout will display cards based on PhonePe’s default settings (Credit and/or Debit Cards) - If
enabledPaymentModes.type = "CARD"andcardTypes = ["DEBIT_CARD"], only Debit Cards will be available
For disabling card options:
- If
disabledPaymentModes.type = "CARD"butcardTypesis not provided, cards will not be disabled and will follow PhonePe’s default settings - If
disabledPaymentModes.type = "CARD"andcardTypes = ["DEBIT_CARD"], only Debit Cards will be disabled - If
disabledPaymentModes.type = "CARD"andcardTypes = ["DEBIT_CARD", "CREDIT_CARD"], both Debit and Credit Cards will be disabled.
Run a Sample Order Token Request!
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.