Create Order
Once your backend receives the Auth Token from the Fetch Auth Token API, you must call the Create Order API . Pass the required details to create the order. PhonePe will return the Order Token in response, which your backend should use in the next step.
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 | Description |
|---|---|---|
Content-Type | application/json | |
Authorization | O-Bearer <access_token> | Pass access_token received in Authorization call |
Request Parameters
| Parameter Name | Type | Description |
|---|---|---|
merchantOrderId | String | Unique merchant order id generated by merchant |
amount | Long | In paisa, minimum value Rs. 1 (100 in paise) |
paymentFlow | Object | |
paymentFlow.type | String | Values Allowed = [PG] |
Sample Request
{
"merchantOrderId": "TX123456",
"amount": 100,
"paymentFlow": {
"type": "PG"
}
}Response
Sample Response
{
"orderId": "OMO123456789",
"state": "PENDING",
"expireAt": 1703756259307,
"token": "<order-token>"
}Response Parameters
| Parameter Name | Type | Description |
|---|---|---|
orderId | String | PG generated internal order id |
state | String | State of the order created, Expected value is PENDING |
expireAt | Long | Order expiry date in epoch |
token | String | Order Token to be passed to SDK |
The token collected from this API will be passed from the your backend to the your app, and then to PhonePe SDK while initiating the payment.
What’s Next?
In the next section, you will learn how to initiate payment. This action is performed after the user selects a payment instrument and clicks “Pay.” This API call is essential as it returns the Order Token and Merchant Order ID required to proceed.