Start a new topic

Struggling with Tiered Pricing setup

Being new to Chargbee this has been a particular tough task


I need to have a single payment page, where the price changes depending on how many users.  

For example if i have 

01-10 users price is £25.00 per month per user (8 users will be £200.00 total per month)

11-25 users price is £20.00 per month per user (11 Users will be £220.00 total per month)


i have tried to follow this article but getting stuck at Step 3 (it i think i have done the first part right but the highlighted second part, not sure where that goes). I'm not a developers so may need some hand holding to get this right.


https://www.chargebee.com/usecase-guides/tiered-pricing/

image


Can any one guide me through how to set this up properly 


Thanks

Diviesh 

1 Comment

Hello Diviesh,


Please follow these steps to be able to setup tired pricing use case for your business :


Step 1: Create a Zero Dollar plan(charge_zero_dollar). This would just serve as a placeholder for holding your JSON metadata.


Step 2: Create multiple add-ons each varying in price.For ex: charge_01_10 (£25.00), charge_11_25 (£20.00), charge_25plus (£15.00).


Step 3: Construct the structure of your Tiered Pricing Model by creating a simple JSON structure. I’ve constructed the JSON structure as per your specified requirements as mentioned below:


{"tiered_pricing": [

{

    "addon_id": "charge_01_10",

    "start_range": 1,

    "end_range": 10

},

{

    "addon_id": "charge_11_25", 

    "start_range": 11,

    "end_range": 25

},

{

    "addon_id": "charge_25plus",

    "start_range": 26

}

]}


Step 4: Add the JSON mentioned above to your zero dollar plan(charge_zero_dollar).Step 5: Now you need to use one of Chargebee’s supported programming languages to construct a system that enables you to charge users according to the tiered plan model. The example mentioned below uses Python and Chargebee’s Update Subscription API, however you could choose to use any other language or APIs for your respective use-cases.


import chargebee
import json
chargebee.configure(“replace_with_your_api_key”,”replace_with_your_chargeebee_site_name")

#Plan of the Zero Dollar plan.
plan_id=“charge_zero_dollar”

#Subscription ID of the customer
subscription_id=“replace_with_the_subscription_id”

#Pass the quantity of the users in this field
subscribe_qty=34

#Function that adds multiple add-ons based on the quantity
def tiered_pricing_update_subscription(plan_id, subscription_id, subscribe_qty):
    plan_result = chargebee.Plan.retrieve(plan_id)
    meta_data = plan_result.plan.meta_data
    tiered_pricing = meta_data["tiered_pricing"]
    addons = []
    for addon_obj in tiered_pricing:
        addon_id = addon_obj.get("addon_id")
        start_range = addon_obj.get("start_range")
        end_range = addon_obj.get("end_range", None)
        addon_qty = 0
        if subscribe_qty < start_range:
            break
        if end_range == None or subscribe_qty <= end_range:
            addon_qty = subscribe_qty - start_range
        else:
            addon_qty = end_range - start_range
            addon_qty = addon_qty + 1
            addons.append({"id": addon_id, "quantity" : addon_qty})
            result = chargebee.Subscription.update(subscription_id, {"replace_addon_list" : "true","addons" : addons})
    return result

print(tiered_pricing_update_subscription(plan_id,subscription_id,subscribe_qty))


Please note that setting up the Tiered pricing use case needs some development method so I recommend that you should take assistance from a developer to help you set this up.

Let us know if you need any further assistance.


Login or Signup to post a comment