Docs

Subscriptions Articles & FAQ

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

36225551

2022-09-30T12:56:06Z

2023-11-27T04:01:04Z

231

1

0

256119

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

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

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 

What is the Jump to Section under Customer/Subscription details page?
Is it possible to add multiple customers to a single subscription
Unable to create a subscription: "Cannot create the subscription as there is no valid card on file". How do I proceed?
How to move a subscription from one customer to another?
Collect first payment at a later date for a new subscription
Can I change the plan of an existing subscription on behalf of the customer ?
What happens when the number of billing cycle is 0?
How do I create/manage a subscription with users or licences ?
What's the difference between the subscription created, subscription activated and subscription started events?
How to change next billing for multiple subscriptions?
How to get a list of all subscriptions in the customer details page for Reseller type business- (above 20 subscriptions)?
How do I add or remove coupons in Subscriptions?
How can I delete a subscription in Chargebee?
How do I apply Coupons to subscriptions?
How to check the billing amount before an invoice is generated?
How to retrieve the next billing date of a subscription?
Can we have multiple subscriptions in Chargebee?
How do I change my subscription status from Non-Renewing to Active?
How to enable Proration Settings in Chargebee
How to apply coupon while creating a subscription?
Charge /Invoice one-time fee in Chargebee
Subscription Status as Active when payment failed on renewal
Changing the billing date to a different date
How to change the term end date for a specific subscription?
How to give my customers the credits for the unused period when there is a subscription change?
How to let my customer select a different plan during reactivation from the portal?
ChargeBee::InvalidRequestError "customer[company] : wrong value"
How to configure backdate subscription and invoices?
Prerequisites for Backdating Subscription actions
Generate a report that shows add-ons by customer/subscription
How do I set a Free Billing Period (manual free trial) for an existing Active subscription?
How do coupons and taxes work on Chargebee’s checkout page?
Timezone for Subscription filters in Chargebee
Can we apply the setup cost while changing a subscription in PC 1.0 sites?
How to set termination fee for Contract terms?
Will a manual discount be shown in the response of the List Subscriptions API?
Is it possible to receive Apple App Store notifications on my server first and then pass them to Chargebee?
Is there any customer information shared while using App Stores?
What does this statement mean: "This customer has signed up but has not set up their Self-Serve Portal account."?‌
Error “Subscription is in contract so you cannot pause” while pausing the subscription
Unable to backdate subscription cancellation when a contract term is applied
Was this article helpful?
Loading…