Recurring INIT

To notify in advance the user about the recurring debit. The API can also be used to debit the amount.

Headers

Header NameMandatoryHeader Value
Content-TypeYesapplication/json
X-VerifyYesSHA256(base64 encoded payload + “/v3/recurring/debit/init” + salt key) + ### + salt index
X-CALLBACK-URLYesThe callback URL to receive the server to server callback response.
{
  "merchantId": "MID12345",
  "merchantUserId": "U123456789",
  "subscriptionId": "OMS2006110139450123456789",
  "transactionId": "TX1234567890",
  "autoDebit": true,
  "amount": 39900
}

Convert the JSON Payload to Base64 Encoded Payload

The above JSON request payload should be converted to the Base64 Encoded Payload and then the request should be sent in the below format.

{
  "request":"ewogICJtZXJjaGFudElkIjogIk1JRDEyMzQ1IiwKICAibWVyY2hhbnRVc2VySWQiOiAiVTEyMzQ1Njc4OSIsCiAgInN1YnNjcmlwdGlvbklkIjogIk9NUzIwMDYxMTAxMzk0NTAxMjM0NTY3ODkiLAogICJ0cmFuc2FjdGlvbklkIjogIlRYMTIzNDU2Nzg5MCIsCiAgImF1dG9EZWJpdCI6IHRydWUsCiAgImFtb3VudCI6IDM5OTAwCn0="
}

Request Parameters

Field NameData TypeMandatoryDescriptionComments
merchantIdStringYesMID provided by PhonePe
merchantUserIdStringYesUser’s unique Id maintained by merchant
subscriptionIdStringYesPhonePe subscription Id
transactionIdStringYesMerchant’s unique transaction Id
amountLongYesThe redemption amount of the mandate
autoDebitBooleanNo
(Optional)
Default: false
Values: true/false
When this flag is set
no debit/execute
would be needed or
allowed
{
  "success": true,
  "code": "SUCCESS",
  "message": "Your request has been successfully submitted.",
  "data": {
    "notificationId": "OMN2006110154420123456789",
    "state": "ACCEPTED",
    "amount": 39900
  }
}

Response Parameters

Field NameData TypeDescription
notificationIdStringMerchant’s SubscriptionId
amountLongAmount
stateString● ACCEPTED
● FAILED
notifiedAtIntEpoch time when the user is notified.
validAfterIntEpoch time when the user is notified.
validUptoIntEpoch time after which the user cannot be debited.

S2S Callback – Recurring INIT

Callback for Recurring INIT

The server to server callback for Recurring INIT will have the “callbackType”: “NOTIFY”.

Validations

Validate the checksum and amount which has been passed with the response received in the Server to Server callback.

Sample Response

{
	"response": "ewogICJzdWNjZXNzIjogdHJ1ZSwKICAiY29kZSI6ICJTVUNDRVNTIiwKICAibWVzc2FnZSI6ICJVc2VyIGRlYml0IG5vdGlmaWNhdGlvbiBpcyBzdWNjZXNzZnVsLiIsCiAgImRhdGEiOiB7CiAgICAiY2FsbGJhY2tUeXBlIjogIk5PVElGWSIsCiAgICAibWVyY2hhbnRJZCI6ICJNSUQxMjM0NSIsCiAgICAidHJhbnNhY3Rpb25JZCI6ICJUWDEyMzQ1Njc4OTAiLAogICAgIm5vdGlmaWNhdGlvbkRldGFpbHMiOiB7CiAgICAgICJub3RpZmljYXRpb25JZCI6ICJPTU4yMDA2MTEwMTM5NDUwMTIzNDU2Nzg5IiwKICAgICAgInN0YXRlIjogIk5PVElGSUVEIiwKICAgICAgImFtb3VudCI6IDM5OTAwLAogICAgICAibm90aWZpZWRBdCI6ICIxNjI4MjI5MTMyNjQ5IiwKICAgICAgInZhbGlkQWZ0ZXIiOiAiMTYyODIyOTEzMTAwMCIsCiAgICAgICJ2YWxpZFVwdG8iOiAiMTYyODU3NDczMTAwMCIKICAgIH0sCiAgICAic3Vic2NyaXB0aW9uRGV0YWlscyI6IHsKICAgICAgInN1YnNjcmlwdGlvbklkIjogIk9NUzIwMDYxMTAxMzk0NTAxMjM0NTY3ODkiLAogICAgICAic3RhdGUiOiAiQUNUSVZFIgogICAgfQogIH0KfQ=="
}
{
  "success": true,
  "code": "SUCCESS",
  "message": "User debit notification is successful.",
  "data": {
    "callbackType": "NOTIFY",
    "merchantId": "MID12345",
    "transactionId": "TX1234567890",
    "notificationDetails": {
      "notificationId": "OMN2006110139450123456789",
      "state": "NOTIFIED",
      "amount": 39900,
      "notifiedAt": "1628229132649",
      "validAfter": "1628229131000",
      "validUpto": "1628574731000"
    },
    "subscriptionDetails": {
      "subscriptionId": "OMS2006110139450123456789",
      "state": "ACTIVE"
    }
  }
}
{
	"response": "ewogICJzdWNjZXNzIjogdHJ1ZSwKICAiY29kZSI6ICJTVUNDRVNTIiwKICAibWVzc2FnZSI6ICJQYXltZW50IEZhaWxlZCIsCiAgImRhdGEiOiB7CiAgICAiY2FsbGJhY2tUeXBlIjogIk5PVElGWSIsCiAgICAibWVyY2hhbnRJZCI6ICJNSUQxMjM0NSIsCiAgICAidHJhbnNhY3Rpb25JZCI6ICJUWDEyMzQ1Njc4OTAiLAogICAgIm5vdGlmaWNhdGlvbkRldGFpbHMiOiB7CiAgICAgICJub3RpZmljYXRpb25JZCI6ICJPTU4yMDA2MTEwMTM5NDUwMTIzNDU2Nzg5IiwKICAgICAgInN0YXRlIjogIkZBSUxFRCIsCiAgICAgICJhbW91bnQiOiAzOTkwMCwKICAgICAgInBheVJlc3BvbnNlQ29kZSIgOiAiWjkiCiAgICB9LAogICAgInN1YnNjcmlwdGlvbkRldGFpbHMiOiB7CiAgICAgICJzdWJzY3JpcHRpb25JZCI6ICJPTVMyMDA2MTEwMTM5NDUwMTIzNDU2Nzg5IiwKICAgICAgInN0YXRlIjogIkFDVElWRSIKICAgIH0KICB9Cn0="
}
{
  "success": true,
  "code": "SUCCESS",
  "message": "Payment Failed",
  "data": {
    "callbackType": "NOTIFY",
    "merchantId": "MID12345",
    "transactionId": "TX1234567890",
    "notificationDetails": {
      "notificationId": "OMN2006110139450123456789",
      "state": "FAILED",
      "amount": 39900,
      "payResponseCode" : "Z9"
    },
    "subscriptionDetails": {
      "subscriptionId": "OMS2006110139450123456789",
      "state": "ACTIVE"
    }
  }
}

If autoDebit flag is FALSE

Once you trigger Recurring INIT API 24 hours before the due date, You need to wait for the S2S Callback response from the Recurring INIT API and once the callback response is received check for the following:

  • state parameter value should be NOTIFIED.
  • Observe the value of the validAfter parameter.

Based on the value of the validAfter parameter you should call the Recurring Debit Execute API.
Important Note: Execution has to be done in validAfter to ValidUpto window only.

If autoDebit flag is True

Once you trigger Recurring INIT API 24 hours before the due date

  • If the Notification is successful sent, you will not receive the Notification Webhook response instead you need to wait for the final S2S Callback response of Recurring Debit.
  • If the Notification failed, then you will receive the Notification Failure Webhook response and once the callback response is received check for the following:
    • state parameter value should be FAILED.
{“method”:”post”,”url”:”/v3/recurring/debit/init”,”auth”:”required”,”results”:{“codes”:[{“name”:””,”code”:”{\n \”success\”: true,\n \”code\”: \”SUCCESS\”,\n \”message\”: \”Your request has been successfully submitted.\”,\n \”data\”: {\n \”notificationId\”: \”OMN2006110154420123456789\”,\n \”state\”: \”ACCEPTED\”,\n \”amount\”: 39900\n }\n}”,”language”:”json”,”status”:200},{“name”:””,”code”:”{\n \”success\”: false,\n \”code\”: \”SUBSCRIPTION_NOT_FOUND\”,\n \”message\”: \”No Subscription found with the given details.\”,\n \”data\”: {}\n}”,”language”:”json”,”status”:400}]},”params”:[{“name”:”Content-Type”,”type”:”string”,”enumValues”:””,”default”:”application/json”,”desc”:””,”required”:true,”in”:”header”,”ref”:””,”_id”:”60af0fdbac97200078c225d5″},{“name”:”X-VERIFY”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”SHA256(base64 encoded payload + \”/v3/recurring/debit/init\” + salt key) + ### + salt index”,”required”:true,”in”:”header”,”ref”:””,”_id”:”60af0fdbac97200078c225d4″},{“name”:”request”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”base64 encoded payload”,”required”:true,”in”:”body”,”ref”:””,”_id”:”60b75a934705b7023bdf78f2″},{“name”:”X-CALLBACK-URL”,”type”:”string”,”enumValues”:””,”default”:””,”desc”:”Dynamic callback URL for server to server callback”,”required”:false,”in”:”header”,”ref”:””,”_id”:”60ed800f826d6d00472f60ac”}],”apiSetting”:”63bb01b11abcf7046d98754c”,”examples”:{“codes”:[]}}
https://api-preprod.phonepe.com/apis/pg-sandbox