Error while using Hosted Pages for Checkout API in case of tier-based pricing

Modified on: Wed, 24 May, 2023 at 3:14 PM

This article covers

How do we pass the tiered plan while generating the checkout using Hosted pages API?

 

Summary

 

When you pass the quantity and the tier prices in the Hosted pages checkout page, you may get an error message. Here is the sample API call.


"Subscription Item Tiers does not match with the original item price”


curl --location --request POST 'https://{site_name}.chargebee.com/api/v2/hosted_pages/checkout_new_for_items' \
--header 'Authorization: Basic site_key=' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'subscription_items[item_price_id][0]=test-INR-Every-6-months' \
--data-urlencode 'item_tiers[item_price_id][0]=test-INR-Every-6-months' \

--data-urlencode 'subscription_items[quantity][0]=25' \
--data-urlencode 'item_tiers[starting_unit][0]=1' \
--data-urlencode 'item_tiers[ending_unit][0]=20' \
--data-urlencode 'item_tiers[
price][0]=20000' 



Clarification


The error comes when only one Tier is passed in the parameters. The logic works when you enter all the tiers that are present for the plan while creating the subscription.

Since you have passed only 1 Tier the mismatch is happening.

Refer to the CURL example:

curl --location --request POST 'https://{site_name}.chargebee.com/api/v2/hosted_pages/checkout_new_for_items' \
--header 'Authorization: Basic site_key=' \
--header 'Content-Type: application/x-www-form-urlencoded' \
--data-urlencode 'subscription_items[item_price_id][0]=test-INR-Every-6-months' \
--data-urlencode 'subscription_items[
quantity][0]=25' \
--data-urlencode 'item_tiers[starting_unit][0]=1' \
--data-urlencode 'item_tiers[ending_unit][0]=20' \
--data-urlencode 'item_tiers[
price][0]=20000' \
--data-urlencode 'item_tiers[starting_unit][1]=21' \
--data-urlencode 'item_tiers[ending_unit][1]=50' \
--data-urlencode 'item_tiers[
price][1]=50000' \
--data-urlencode 'item_tiers[starting_unit][2]=51' \
--data-urlencode 'item_tiers[
price][2]=70000' \
--data-urlencode 'item_tiers[item_price_id][0]=test-INR-Every-6-months' \
--data-urlencode 'item_tiers[item_price_id][1]=test-INR-Every-6-months' \
--data-urlencode 'item_tiers[item_price_id][2]=test-INR-Every-6-months'


Did you find it helpful? Yes No

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