How can I apply multiple Manual discounts via API to an existing subscription?

Modified on: Mon, 24 Jul, 2023 at 4:28 PM

This article covers 

How can I remove a Manual discount applied to a subscription via API?


Summary 


You will be able to apply the Manual discounts to an existing subscription via API in two different ways - For specific items of the subscription or All items of the subscription, while using the “update_subscription_for_items” API call on the Chargebee sites with PC 2.0 version of Product Catalog.


Manual Discounts: This feature is currently available on selective plans. Please refer to the plans and pricing page. If you are on our previous plans, then this feature is available on our Enterprise plans.


Solution


Please find the following sample curl command to apply Manual discounts to a subscription

 

To apply a discount of 20% on specific items of the subscription,

 

curl  https:/{site-name}.chargebee.com/api/v2/subscriptions/{subscription_id}/update_for_items \

     -u {site_api_key}:\

     -d discounts[apply_on][0]="specific_item_price" \

     -d discounts[item_price_id][0]="{item_price_id}" \

     -d discounts[duration_type][0]="{forever/onetime}" \

     -d discounts[percentage][0]=20.0 \

     -d discounts[operation_type][0]="add"

 

Here you need to pass the parameter discounts[apply_on][0…n] as "specific_item_price" and you need to pass the item price ID mandatorily in the parameter discounts[item_price_id][0…n]

 

 

To apply a discount of 20% on all items of the subscription,

 

curl  https:/{site-name}.chargebee.com/api/v2/subscriptions/{subscription_id}/update_for_items \

     -u {site_api_key}:\

     -d discounts[apply_on][0]="invoice_amount" \

     -d discounts[duration_type][0]="forever/onetime" \

     -d discounts[percentage][0]=20.0 \

     -d discounts[operation_type][0]="add"

 

Here you need to pass the parameter discounts[apply_on][0…n] as "invoice_amount".

 

 

You will be able to remove the discount by passing the value as "remove" for "discounts[operation_type][0...n]". In this case you don't have to pass all the details of the discount. You need to pass the "discounts[id][0...n]" parameter mandatorily. To get the correct discount ID of the discounts applied to a subscription, you can use "retrieve a subscription" API call.

 

Please access the API doc link below to know more about the discount parameters,

https://apidocs.chargebee.com/docs/api/subscriptions?prod_cat_ver=2#update_subscription_for_items_discounts_apply_on

 



Related articles and Documentation

Adding Manual Discounts while creating subscriptions




Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.
×