Setup Subscription
This API is used to set up a subscription for a customer.
Environment
| Environment | HTTP Method | API |
| Sandbox | POST | https://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/pay |
| Production | POST | https://api.phonepe.com/apis/pg/checkout/v2/pay |
Request
| Header Name | Header Value | Description |
| Content-Type | application/json | |
| Authorization | O-Bearer <access_token> | Pass access_token received in Authorization call |
Sample Request
{
"merchantOrderId": "ORD37835658271956985065",
"amount": 200,
"metaInfo": {
"udf1": "dummy1",
"udf2": "dummy2",
"udf3": "dummy3",
"udf4": "dummy4"
},
"paymentFlow": {
"type": "SUBSCRIPTION_CHECKOUT_SETUP",
"merchantUrls": {
"redirectUrl": "https://www.phonepe.com",
"cancelRedirectUrl": "https://www.google.com"
},
"subscriptionDetails": {
"subscriptionType": "RECURRING",
"amountType": "VARIABLE",
"merchantSubscriptionId": "MSUB931119373059899079",
"authWorkflowType": "PENNY_DROP",
"maxAmount": 15000,
"expireAt": 2105507164917,
"frequency": "ON_DEMAND"
},
"paymentModeConfig": {
"version": "V2",
"enabledPaymentModes": [
{
"type": "UPI",
"flows": ["INTENT", "QR"]
},
{
"type": "ENACH",
"authInstrumentTypes": ["NET_BANKING", "DEBIT_CARD"]
}
]
}
}
}Request Parameter
| Parameter Name | Data Type | Mandatory | Description | Constraints |
| merchantOrderId | String | Yes | Merchant’s unique identifier for the order | Max Length: 63 characters No Special characters are allowed except underscore “_” and hyphen “-“ |
| amount | Long | Yes | Initial setup amount in paisa | |
| paymentFlow.type | String | Yes | Type of flow | Allowed value: SUBSCRIPTION_CHECKOUT_SETUP |
| paymentFlow.merchantUrls.redirectUrl | String | Yes | Success redirect URL | |
| paymentFlow.merchantUrls.cancelRedirectUrl | String | Yes | Failure/Cancel redirect URL | |
| subscriptionDetails.subscriptionType | String | Yes | Specifies the type of subscription being created. | Allowed value: “RECURRING” |
| subscriptionDetails.amountType | String | Yes | Type of recurring charge (e.g., FIXED or VARIABLE) | |
| subscriptionDetails.merchantSubscriptionId | String | Yes | Merchant’s unique identifier for the subscription | |
| subscriptionDetails.authWorkflowType | ||||
| subscriptionDetails.maxAmount | Long | Yes | Maximum limit for recurring debits in paisa | |
| subscriptionDetails.expireAt | Long | Yes | Mandate expiry timestamp in epoch | |
| subscriptionDetails.frequency | String | Yes | Frequency of debit (e.g., ON_DEMAND, MONTHLY) | |
| paymentModeConfig.version | string | Yes | ||
| paymentModeConfig.enabledPaymentModes.type | Yes | |||
| paymentModeConfig.enabledPaymentModes.flow | Array | Yes | ||
| paymentModeConfig.enabledPaymentModes.authInstrumentTypes | Yes |
Response
Sample Response
{
"orderId": "OMO2609241434205711014273W",
"state": "PENDING",
"redirectUrl": "https://mercury-t2.phonepe.com/transact/pgv3?token=hq4wOGdzX31IuPyyh7/7AYOLiipO42P8QtgmusudZHta7zUAMbV5uMV5f6kF1hmvheryrKRViCFFSkJeROPrWmJEugXgAvXFgi0yl3Enmh9OIKu7L6FwTDJ09eoNh4dgE8VLreJqh7T+2Bl5DkyxtX0VjaWFK6w5rjtkocKIhHsTJpI6sXcXTvC6ich/JVlMkkvGbSDcJ9NqnhAnF3DTdEJ3wCd81BMlneL+WuSR+ffkfEPlu/ZC8HoCPF/CLs6nI01uTbcz914Rtb2y1RewHlb2Amg/7Iu2meBaCweBCDJOZszVN7YvOKi3p+w/e0+Bj2+KFxyvSeG8qWXAvWZgDQyTXmYTiaRXfoiP8ItBjQKBdI0mzr4HkGLkjkL8YPKQBoN4Vu6dSdVET5JenLvAS1x4JaVe9CZRn8x7zxXNG+2TSKzdwi1My0HjqNGMn8dCKksdM/jn6vypQM65+daT5Ylodr3aeO7K7NwdL6H3+rUA+4qMxnV+TA==&routingKey=W",
"expireAt": 1790241560571
}Response Parameters
| Parameter Name | Data Type | Description |
orderId | String | PG generated internal order ID |
state | String | Current state (e.g., PENDING) |
redirectUrl | String | URL to redirect user for bank authentication |
| expireAt | Long | Order expiry date in epoch. |