Start a new topic

How can I setup a simple hosted payment page using addons & discounts without resorting to API?

Our hosted payment page is a simple URL available at the "Plan" level. Using this you can quickly link any website to accept payments via Chargebee. 


Now this got more awesome with some advanced features. 


You can now make a bundled offering including addons and discounts without any API calls, just by including these details in the plan specific hosted page URL.


Here is how you can set it up:


Look for "Hosted page URL" at the bottom of your plan details page. 


All plan URLs will look something similar to this: https://yoursitename.chargebee.com/hosted_pages/plans/plan_id


1. Specifying plan quantity: 


If you have a single plan but with different quantities, you can specify the plan quantity in the URL and Chargebee will calculate the cost and display the total charge on the hosted page.


Sample URL: https://yoursitename.chargebee.com/hosted_pages/plans/<plan-id>?subscription[plan_quantity]=2


2. Apply a default coupon discount during sign up: 


When you would like to offer a discount to certain coupons without allowing users to key in a coupon code themselves, you can create a URL using the coupon code yourself. 


Sample URL: https://yoursitename.chargebee.com/hosted_pages/plans/<plan-id>?subscription[coupon]=<coupon-id>


Example Scenario:


Apply a setup fee and postpone the initial payment to the second billing cycle: 


For certain business models, merchants may want to charge their customers just the setup/installation fee during sign up and charge them on the second month. To get this done, create a plan along with its setup fee, and a coupon with the plan cost as the discount amount. Specify this coupon in the URL. When the customer signs up, their first month's plan cost will be waived off and they will only be charged for the setup fee. 


This is also displayed to them on the hosted page.




3. Include an addon during sign up: 


If you are selling a particular product and as an addon you want to allow customers to purchase an additional product/service, you can include this as an addon in the plan URL. 


Sample URL: https://yoursitename.chargebee.com/hosted_pages/plans/<plan-id>?addons[id][0]=<addon-id>


4. Include an addon with quantity during sign up: 


For quantity based addons you would specify the addon as well as the quantity amount in the URL.


Sample URL: https://yoursitename.chargebee.com/hosted_pages/plans/<plans-id>?addons[id][0]=<addon-id>&addons[quantity][0]=2


5. A Plan URL with all of the above:


Here's a sample URL for creating a subscription that includes subscription ID, plan quantity, addon with quantity and coupon.


Sample URL: https://yoursitename.chargebee.com/hosted_pages/plans/<plan-id>?subscription[id]=<unique-id>&subscription[plan_quantity]=2&addons[id][0]=<addon-id>&addons[quantity][0]=2&subscription[coupon]=coupon-id


Sample Demo: https://www.chargebee.com/labs/signup-with-addons-and-quantity.html


Placeholders used in the URL


subscription[id]=<unique-id> - This is the placeholder that you would use if you want to specify a subscription ID. If you are going to explicitly specify a subscription ID please make sure it is unique. This placeholder is NOT mandatory.


subscription[plan_quantity]= - You can specify the plan quantity after "=". 


addons[id][0]=<addon-id> - [0] specifies the number of the addon. So if you are going to include 2 addons to the subscription, then the URL will look something like:


addons[id][0]=<addon-id>&addons[id][1]=<addon-id>&addons[id][2]=<addon-id>


The <addon-id> is where you would enter the ID of the addon. You can find the ID by clicking on an existing addon.



addons[quantity][0]= - Used to indicate the quantity of the addon to be included in the subscription. Specify the quantity after "=".


subscription[coupon]= - Used to specify the coupon that needs to be applied to the subscription. Specify the coupon ID after "=".


subscription[trial_end]= - Used to override the default trial period. Specify the time in the Unix Timestamp format in UTC.


Use "?" at the end of the plan ID and "&" for each placeholder. "&" is not required after the "?" that is used after the plan ID.


<> - Do not include this when specifying your values like plan id or addon id.


A limitation for quantity based plans or addons when using this method is that your customers will not be able to choose or edit the quantity on the hosted page. As a workaround you can create a quantity drop down on the plan page of your website, and based on the input your customers enter, generate the URL along with the value specified.


Drop us a comment if you have a question or would like to add something.


4 people like this idea

Bee. I can do it easily after your reputed guide. 

Login or Signup to post a comment