Create Order Token for Autopay Mobile SDK
This API is used to create a order token for mobile SDK to setup a subscription.
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
| Header Name | Header Value | Description |
| Content-Type | application/json | |
| Authorization | O-Bearer <access_token> | Pass access_token received in Authorization call |
| Parameter Name | Data Type | Mandatory (Yes/No) | Description | Constraints |
| merchantOrderId | String | Yes | Unique merchant order id generated by merchant | Max Length = 63 characters No Special characters allowed except underscore “_” and hyphen “-“ |
| amount | Long | Yes | Order amount in paisa | Min Value = 1 |
| expireAfter | Long | No | Order expiry in seconds. If not passed default value will be used. | Min Value = 300, Max Value = 3600 |
| metaInfo | Object | No | Merchant defined meta info to store additional information.same data will be returned in status and callback response | |
| metaInfo.udf1-15 | String | No | Merchant defined additional information | Max length = 256 characters |
| paymentFlow | Object | Yes | Additional details required by this flow | |
| paymentFlow.type | String | Yes | Type of payment flow. | Valued Allowed = [SUBSCRIPTION_CHECKOUT] |
| paymentFlow.message | String | No | Message to be displayed to user on paypage. | Allowed Characters = [ A-Za-z0-9+-_ ] Max Length = 128 |
The metaInfo object contains additional parameters, which are explained in the table below.
| 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 |
⚠️ Do Not Rename metainfo Parameters!
It is mandatory to keep the parameter names udf1, udf2, etc., exactly as they are in the metainfo block. Renaming these key values will result in a production error.
Request
{
"merchantOrderId": "{{merchantOrderId}}",
"amount": 47900,
"metaInfo": {
"udf1": "some meta info of max length 256",
"udf2": "some meta info of max length 256",
"udf3": "some meta info of max length 256",
"udf4": "some meta info of max length 256",
"udf5": "some meta info of max length 256",
"udf6": "some meta info of max length 256",
"udf7": "some meta info of max length 256",
"udf8": "some meta info of max length 256",
"udf10": "some meta info of max length 256",
"udf11": "some meta info of max length 50",
"udf12": "some meta info of max length 50",
"udf13": "some meta info of max length 50",
"udf14": "some meta info of max length 50",
"udf15": "some meta info of max length 50"
},
"paymentFlow": {
"type": "SUBSCRIPTION_CHECKOUT_SETUP",
"message": "Payment message used for collect requests",
"merchantUrls": {
"redirectUrl": "www.google.com",
"cancelRedirectUrl": "www.google.com"
},
"subscriptionDetails": {
"subscriptionType": "RECURRING",
"merchantSubscriptionId": "{{merchantSubId}}",
"authWorkflowType": "TRANSACTION",
"amountType": "FIXED",
"maxAmount": 47900,
"frequency": "ON_DEMAND",
"productType": "UPI_MANDATE",
"expireAt": 1779689282000
}
},
"expireAfter": 3000
}Response
{
"orderId": "OMO123456789",
"state": "PENDING",
"expireAt": 1703756259307,
"token": "<order-token>"
}| Parameter Name | Data Type | Description |
| orderId | String | PG generated internal order id |
| state | String | State of the order created, Expected value is PENDING |
| expiryAt | Long | Order expiry date in epoch |
| token | String | order token to be passed to SDK |
⚠️ Setup Mobile SDK Before you Setup Subscription!
Pass the obtained Order ID and Token to the startTransaction method within the mobile SDK. For Integration details, please refer to our Mobile Integration documentation: Android, iOS, Flutter, Ionic, React Native.
What’s Next?
In the next section, you will learn how to you check whether the subscription has been successfully created, is still pending user action, has failed, or is complete.