Setup Subscription


This API is used to set up a subscription for a customer.

EnvironmentHTTP MethodAPI
SandboxPOSThttps://api-preprod.phonepe.com/apis/pg-sandbox/checkout/v2/pay
ProductionPOSThttps://api.phonepe.com/apis/pg/checkout/v2/pay
Header NameHeader ValueDescription
Content-Typeapplication/json
AuthorizationO-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 NameData TypeMandatoryDescriptionConstraints
merchantOrderIdStringYesMerchant’s unique identifier for the orderMax Length: 63 characters
No Special characters are allowed except underscore “_” and hyphen “-“
amountLongYesInitial setup amount in paisa
paymentFlow.typeStringYesType of flowAllowed value: SUBSCRIPTION_CHECKOUT_SETUP
paymentFlow.merchantUrls.redirectUrlStringYesSuccess redirect URL
paymentFlow.merchantUrls.cancelRedirectUrlStringYesFailure/Cancel redirect URL
subscriptionDetails.subscriptionTypeStringYesSpecifies the type of subscription being created.Allowed value: “RECURRING”
subscriptionDetails.amountTypeStringYesType of recurring charge (e.g., FIXED or VARIABLE)
subscriptionDetails.merchantSubscriptionIdStringYesMerchant’s unique identifier for the subscription
subscriptionDetails.authWorkflowType
subscriptionDetails.maxAmountLongYesMaximum limit for recurring debits in paisa
subscriptionDetails.expireAtLongYesMandate expiry timestamp in epoch
subscriptionDetails.frequencyStringYesFrequency of debit (e.g., ON_DEMAND, MONTHLY)
paymentModeConfig.versionstringYes
paymentModeConfig.enabledPaymentModes.typeYes
paymentModeConfig.enabledPaymentModes.flowArrayYes
paymentModeConfig.enabledPaymentModes.authInstrumentTypesYes
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 NameData TypeDescription
orderIdStringPG generated internal order ID
stateStringCurrent state (e.g., PENDING)
redirectUrlStringURL to redirect user for bank authentication
expireAtLongOrder expiry date in epoch.

Is this article helpful?