Update Existing Plan for Subscription API

Sometimes it is important to update given plan associated with the subscription. Zion provides a platform to update startDate and totalCount with of already associated Subscription with some know assumptions -

  • startDate can be updated till it has not been elapsed
  • totalCount can be updated but new value should be always greater than number of iterations already completed. For example, if totalCount was initially set as 11 and out of them 4 iterations are already executed. Now totalCount cannot be updated to 4 or lesser values

HTTP method: PATCH

Path: {base_url}/api/sub/v1/merchant/subscriptions/{subscriptionId}/plans/{planId}

Request parameters

Header

ParameterDescription
X-PayU-Subscription- Signature
mandatory
SHA512 Signature generated by encrypting request parameters in body by Merchant Key, Merchant Salt and Subscription Id.
merchantId
mandatory
Merchant Key received during onboarding.
Example: YQeVda

X-PayU-Subscription-Signature generation guidelines

X-PayU-Subscription-Signature is SHA 512 signature used to provide security layer over existing APIs. Every API will have its own logic to generate X-PayU-Subscription- Signature logic. Let’s look at how it is calculated for Update Subscription API -

Signature = SHA512(“merchantId:" + merchantId + "|subscriptionId:" + subscriptionId + "|planId:" + planId + "|" + merchantSalt)

Example:

SHA512(merchantId:YQeVda|subscriptionId:5c972a35652d405ed9834f52|planId:ZION 155341061387133|1v9b1)

Sample request

The plan id ZION155341061387133 associated with subscription id 5c972a35652d405ed9834f52 is updated with startDate and totalCount parameters.

Example path: https://subscription.citruspay.com/api/sub/v1/merchant/subscriptions/5c972a35652d405> ed9834f52/plans/ZION155341061387133

{
"startDate": "2019-09-14T11:24:19.020Z",
"totalCount": 11
}

Sample response

{
  "planId": "ZION155341061387133",
  "startDate": "2019-09-14T11:24:19.020Z",
  "totalCount": 11,
  "numberOfPaidInvoices": 0,
  "numberOfInvoiceGenerated": 0,
  "status": "Active",
  "deleted": false,
  "nextBillingDates": "2019-09-14T11:24:19.020Z",
  "lastPaymentDates": null,
  "billingInterval": 1,
  "billingCycle": "DAILY",
  "planName": "Premium",
  "amount": {
    "value": 2,
    "currency": "INR"
  }
}

 

HTTP response codes

When plan is updated successfully, HTTP method 200 is returned in the response.

HTTP Status CodeDescription
200Plan is updated successfully
403Forbidden request invalid Signature
400Request is malformed
404Merchant or Plan Id not found
422Request has invalid values
500Interval Server Error