Docs

Hosted Pages Articles & FAQ

hosted, pages, tiered, plan, api, error, does not, match, item, price, subscription, tiers

36225551

2023-05-24T09:44:21Z

2025-02-12T08:24:43Z

97

0

0

259104

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

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

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'

Was this article helpful?
Loading…