API Version
Library

Estimates, as the name implies, can be used to find out the estimate for performing an operation as against performing the operation itself. i.e Say you want to create a new subscription or update an existing one, using the estimate API one can deduce the details like how much money the customer needs to be charged for this operation, when it should be collected, the state the subscription would be in etc.

Note:
  • Invoking these APIs do not perform the actual operation but just generates an estimate.
  • Prorated Credits and Promotional Credits are not taken into account while generating the estimate.

Sample estimate [ JSON ]

{ "amount": 895, "amount_due": 895, "collect_now": true, "created_at": 1517506678, "credits_applied": 0, "line_items": [ { "amount": 895, "date_from": 1517506678, "date_to": 1519925878, "description": "No Trial", "entity_id": "no_trial", "entity_type": "plan", "is_taxed": false, "object": "line_item", "quantity": 1, "tax": 0, "type": "charge", "unit_amount": 895 } ], "object": "estimate", "price_type": "tax_exclusive", "recurring": true, "sub_total": 895, "subscription_status": "active", "term_ends_at": 1519925878 }

API Index URL GET

https://{site}.chargebee.com/api/v1/estimates

Model Class

ChargeBee.Models.Estimate
CreatedAt
timestamp(UTC) in seconds
The time at which this estimate got generated
Recurring
boolean, default=true
Whether or not the estimate for the invoice is recurring. Will be 'true' or 'false' for subscription related estimates.
SubscriptionId
optional, string, max chars=100
Applicable only for subsctiption related estimates. The identifier of the subscription this estimate belongs to.
SubscriptionStatus
optional, enumerated string
Applicable only for subsctiption related estimates. The post-operation status of the subscription.
Possible values are
FutureThe subscription is scheduled to start at a future date.InTrialThe subscription is in trial.ActiveThe subscription is active and will be charged for automatically based on the items in it.NonRenewingThe subscription will be canceled at the end of the current term.CancelledThe subscription has been canceled and is no longer in service.TransferredThe subscription has been transferred to another business entity within the organization.
FutureThe subscription is scheduled to start at a future date.InTrialThe subscription is in trial.ActiveThe subscription is active and will be charged for automatically based on the items in it.NonRenewingThe subscription will be canceled at the end of the current term.
CancelledThe subscription has been canceled and is no longer in service.TransferredThe subscription has been transferred to another business entity within the organization.
Show all values[+]
TermEndsAt
optional, timestamp(UTC) in seconds
Applicable only for subsctiption related estimates. End of the current billing term
CollectNow
boolean
'true' means the estimate amount needs to be collected immediately, whereas 'false' means the estimate amount needs to be collected at the term-end
PriceType
enumerated string, default=tax_exclusive
The price type of the invoice.
Possible values are
TaxExclusiveAll amounts in the document are exclusive of tax.TaxInclusiveAll amounts in the document are inclusive of tax.
TaxExclusiveAll amounts in the document are exclusive of tax.TaxInclusiveAll amounts in the document are inclusive of tax.
Show all values[+]
Amount
in cents, default=0, min=0
Total estimate amount in cents. The 'collect_now' field indicates when this amount needs to be collected.
CreditsApplied
in cents, default=0, min=0
credits applied to this invoice in cents.
AmountDue
in cents, default=0, min=0
Invoice amount due in cents
SubTotal
in cents, min=0
The sub-total amount
optional, list of line_item
The list of items in this estimate
optional, list of discount
The list of discounts applied to this estimate
optional, list of tax
The list of taxes applied to this estimate
CreatedAt CreatedAt
timestamp(UTC) in seconds
The time at which this estimate got generated
Recurring Recurring
boolean, default=true
Whether or not the estimate for the invoice is recurring. Will be 'true' or 'false' for subscription related estimates.
SubscriptionId SubscriptionId
optional, string, max chars=100
Applicable only for subsctiption related estimates. The identifier of the subscription this estimate belongs to.
SubscriptionStatus SubscriptionStatus
optional, enumerated string
Applicable only for subsctiption related estimates. The post-operation status of the subscription.
Possible values are
FutureThe subscription is scheduled to start at a future date.InTrialThe subscription is in trial.ActiveThe subscription is active and will be charged for automatically based on the items in it.NonRenewingThe subscription will be canceled at the end of the current term.CancelledThe subscription has been canceled and is no longer in service.TransferredThe subscription has been transferred to another business entity within the organization.
FutureThe subscription is scheduled to start at a future date.InTrialThe subscription is in trial.ActiveThe subscription is active and will be charged for automatically based on the items in it.NonRenewingThe subscription will be canceled at the end of the current term.
CancelledThe subscription has been canceled and is no longer in service.TransferredThe subscription has been transferred to another business entity within the organization.
Show all values[+]
TermEndsAt TermEndsAt
optional, timestamp(UTC) in seconds
Applicable only for subsctiption related estimates. End of the current billing term
CollectNow CollectNow
boolean
'true' means the estimate amount needs to be collected immediately, whereas 'false' means the estimate amount needs to be collected at the term-end
PriceType PriceType
enumerated string, default=tax_exclusive
The price type of the invoice.
Possible values are
TaxExclusiveAll amounts in the document are exclusive of tax.TaxInclusiveAll amounts in the document are inclusive of tax.
TaxExclusiveAll amounts in the document are exclusive of tax.TaxInclusiveAll amounts in the document are inclusive of tax.
Show all values[+]
Amount Amount
in cents, default=0, min=0
Total estimate amount in cents. The 'collect_now' field indicates when this amount needs to be collected.
CreditsApplied CreditsApplied
in cents, default=0, min=0
credits applied to this invoice in cents.
AmountDue AmountDue
in cents, default=0, min=0
Invoice amount due in cents
SubTotal SubTotal
in cents, min=0
The sub-total amount
LineItems
optional, list of line_item
The list of items in this estimate
Discounts
optional, list of discount
The list of discounts applied to this estimate
Taxes
optional, list of tax
The list of taxes applied to this estimate
Generates an estimate for the 'create subscription' operation. This input will be similar to the Create Subscription API but no subscription will be created, but just an estimate will be generated.

Note:

  • If you use the EU VAT tax option, you need to specify 'billing_address[country]' and 'customer[vat_number]' attributes for the tax calculation to happen. If these attributes are not passed, the tax will be ignored for this estimate.
  • If you use the Customized Tax option, you need to specify the shipping address and billing address parameters for the tax calculation to happen. This is because Chargebee will use the customer’s shipping address to determine the tax applicable. If the shipping address is not available, then the billing address will be used to determine tax. If both addresses are not available, tax will be ignored for this estimate.

Related Tutorial

Notes

Sample Codes
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateSubscription()
		.SubscriptionPlanId("no_trial")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.Request();

Estimate estimate = result.Estimate;

copy
Click to Copy
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateSubscription()
		.SubscriptionPlanId("no_trial")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.Request();

Estimate estimate = result.Estimate;

Sample Result [ JSON ]

Show more...
{
    "estimate": {
        "amount": 895,
        "amount_due": 895,
        "collect_now": true,
        "created_at": 1517506678,
        "credits_applied": 0,
        "line_items": [
            {
                "amount": 895,
                "date_from": 1517506678,
                "date_to": 1519925878,
                "description": "No Trial",
                "entity_id": "no_trial",
                "entity_type": "plan",
                "is_taxed": false,
                "object": "line_item",
                "quantity": 1,
                "tax": 0,
                "type": "charge",
                "unit_amount": 895
            },
            {..}
        ],
        "object": "estimate",
        "price_type": "tax_exclusive",
        "recurring": true,
        "sub_total": 895,
        "subscription_status": "active",
        "term_ends_at": 1519925878
    }
}

URL Format POST

https://{site}.chargebee.com/api/v1/estimates/create_subscription

Method

Estimate.CreateSubscription()
BillingCycles[(val)](val)
optional, integer, min=0
Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
SubscriptionId(val)
optional, string, max chars=50
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
SubscriptionPlanId(val)
required, string, max chars=100
Identifier of the plan for this subscription
SubscriptionPlanQuantity(val)
optional, integer, default=1, min=1
Plan quantity for this subscription
SubscriptionTrialEnd(val)
optional, timestamp(UTC) in seconds
The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
SubscriptionStartDate(val)
optional, timestamp(UTC) in seconds
The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
  • Backdating is enabled for subscription creation operations.
  • The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
  • The date is not more than duration X into the past, where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, start_date cannot be earlier than 14th February.
SubscriptionCoupon(val)
optional, string, max chars=100

The id of the coupon. For validating the coupon code provided by the user , use the following codes in combination with the param attribute in the error response.

  • resource_not_found : Returned if the coupon is not present.
  • resource_limit_exhausted : Returned if the coupon has expired or the maximum redemption for the coupon has already been reached.
  • invalid_request : Returned if the coupon is not applicable for the particular plan/addon.
BillingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
BillingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
BillingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

ShippingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
ShippingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
ShippingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

CustomerVatNumber(val)
optional, string, max chars=20
VAT number of this customer. If not provided then taxes are not calculated for the estimate. Applicable only when taxes are configured for the EU or UK region. VAT validation is not done for this.
CustomerTaxability(val)
optional, enumerated string, default=taxable
Specifies if the customer is liable for tax
Possible values are
TaxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.Exempt
  • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
TaxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.Exempt
  • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
Show all values[+]
AddonId(idx,val)
optional, string, max chars=100
Identifier of the addon. Multiple addons can be passed.
AddonQuantity(idx,val)
optional, integer, default=1, min=1
Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
estimate estimate
always returned
Resource object representing estimate

Sample admin console URL

https://{site}.chargebee.com/admin-console/estimates/123x
Create a subscription for the existing estimate of a customer.

Notes

Sample Codes
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateSubForCustomerEstimate("__test__5SK2liZoRZxq5Tg18")
		.Subscription().PlanId("no_trial")
		.Request();

Estimate estimate = result.Estimate;

copy
Click to Copy
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateSubForCustomerEstimate("__test__5SK2liZoRZxq5Tg18")
		.Subscription().PlanId("no_trial")
		.Request();

Estimate estimate = result.Estimate;

Sample Result [ JSON ]

Show more...
{
    "estimate": {
        "amount": 895,
        "amount_due": 895,
        "collect_now": true,
        "created_at": 1517480027,
        "credits_applied": 0,
        "line_items": [
            {
                "amount": 895,
                "date_from": 1517480027,
                "date_to": 1519899227,
                "description": "No Trial",
                "entity_id": "no_trial",
                "entity_type": "plan",
                "is_taxed": false,
                "object": "line_item",
                "quantity": 1,
                "tax": 0,
                "type": "charge",
                "unit_amount": 895
            },
            {..}
        ],
        "object": "estimate",
        "price_type": "tax_exclusive",
        "recurring": true,
        "sub_total": 895,
        "subscription_status": "active",
        "term_ends_at": 1519899227
    }
}

URL Format GET

https://{site}.chargebee.com/api/v1/customers/{customer-id}/create_subscription_estimate

Method

Estimate.CreateSubForCustomerEstimate(<customer_id>)
UseCustomerBalances[(val)](val)
optional, boolean, default=false
If true, all the existing balances - promotional credits, refundable credits and excess payments - will be included for the invoice estimate.
BillingCycles[(val)](val)
optional, integer, min=0
Number of cycles(plan interval) this subscription should be charged. After the billing cycles exhausted, the subscription will be cancelled.
SubscriptionId(val)
optional, string, max chars=50
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
SubscriptionPlanId(val)
required, string, max chars=100
Identifier of the plan for this subscription
SubscriptionPlanQuantity(val)
optional, integer, default=1, min=1
Plan quantity for this subscription
SubscriptionTrialEnd(val)
optional, timestamp(UTC) in seconds
The time at which the trial ends for this subscription. Can be specified to override the default trial period.If '0' is passed, the subscription will be activated immediately.
SubscriptionStartDate(val)
optional, timestamp(UTC) in seconds
The date/time at which the subscription is to start. If not provided, the subscription starts immediately. You can provide a value in the past as well. This is called backdating the subscription creation and is done when the subscription has already been provisioned but its billing has been delayed. Backdating is allowed only when the following prerequisites are met:
  • Backdating is enabled for subscription creation operations.
  • The current day of the month does not exceed the limit set in Chargebee for backdating such operations. This day is typically the day of the month by which the accounting for the previous month must be closed.
  • The date is not more than duration X into the past, where X is the billing period of the plan. For example, if the period of the plan in the subscription is 2 months and today is 14th April, start_date cannot be earlier than 14th February.
SubscriptionCoupon(val)
optional, string, max chars=100

The id of the coupon. For validating the coupon code provided by the user , use the following codes in combination with the param attribute in the error response.

  • resource_not_found : Returned if the coupon is not present.
  • resource_limit_exhausted : Returned if the coupon has expired or the maximum redemption for the coupon has already been reached.
  • invalid_request : Returned if the coupon is not applicable for the particular plan/addon.
ShippingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
ShippingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
ShippingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

AddonId(idx,val)
optional, string, max chars=100
Identifier of the addon. Multiple addons can be passed.
AddonQuantity(idx,val)
optional, integer, default=1, min=1
Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
estimate estimate
always returned
Resource object representing estimate

Sample admin console URL

https://{site}.chargebee.com/admin-console/estimates/123x

Generates an estimate for the 'update subscription' operation. The input will be similar to the Update Subscription API but subscription will not be updated, but just an estimate will be generated.

In case 'update subscription' operation will not create an invoice immediately, the estimate generated will be for the 'end of term' invoice. Some of the cases where the invoice will not be generated immediately are

  • In case of downgrades only credits will be added to customer.
  • 'end_of_term' option is true.
  • 'prorate' option is false.
  • Only coupon is applied.

Note:

  • If you use the EU VAT tax option, you need to specify 'billing_address[country]' and 'customer[vat_number]' attributes for the tax calculation to happen. If these attributes are not passed, the tax will be ignored for this estimate.
  • If you use the Customized Tax option, you need to specify the shipping address and billing address parameters for the tax calculation to happen. This is because Chargebee will use the customer’s shipping address to determine the tax applicable. If the shipping address is not available, then the billing address will be used to determine tax. If both addresses are not available, tax will be ignored for this estimate.

Notes

Sample Codes
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.UpdateSubscription()
		.SubscriptionId("__test__5SK0bLNFRFuBxbNB6")
		.SubscriptionPlanId("plan1")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.Request();

Estimate estimate = result.Estimate;

copy
Click to Copy
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.UpdateSubscription()
		.SubscriptionId("__test__5SK0bLNFRFuBxbNB6")
		.SubscriptionPlanId("plan1")
		.BillingAddressZip("91789")
		.BillingAddressCountry("US")
		.Request();

Estimate estimate = result.Estimate;

Sample Result [ JSON ]

Show more...
{
    "estimate": {
        "amount": 1500,
        "amount_due": 1500,
        "collect_now": true,
        "created_at": 1517506678,
        "credits_applied": 0,
        "line_items": [
            {
                "amount": 1500,
                "date_from": 1517506678,
                "date_to": 1519925878,
                "description": "Plan1 - Prorated Charges",
                "entity_id": "plan1",
                "entity_type": "plan",
                "is_taxed": false,
                "object": "line_item",
                "quantity": 1,
                "tax": 0,
                "type": "prorated_charge",
                "unit_amount": 1500
            },
            {..}
        ],
        "object": "estimate",
        "price_type": "tax_exclusive",
        "recurring": true,
        "sub_total": 1500,
        "subscription_id": "__test__5SK0bLNFRFuBxbNB6",
        "subscription_status": "active",
        "term_ends_at": 1519925878
    }
}

URL Format POST

https://{site}.chargebee.com/api/v1/estimates/update_subscription

Method

Estimate.UpdateSubscription()
ReplaceAddonList[(val)](val)
optional, boolean, default=false
Should be true if the existing addons should be replaced with the ones that are being passed.
BillingCycles[(val)](val)
optional, integer, min=0
The number of billing cycles the subscription runs before canceling. If not provided, then the billing cycles set for the plan is used.
Prorate[(val)](val)
optional, boolean
  • When true: Prorated credits or charges are created as applicable for this change.
  • When false: The subscription is changed without creating any credits or charges.
  • When not provided, the value configured in the site settings is considered.
Caveat

For further changes within the same billing term, when prorate is set to true, credits are not created when all the conditions below hold true:

An immediate previous change was made

  • with prorate set to false and
  • no changes were made to the subscription’s billing term and
  • a change was made to either the subscription’s plan, its addons, or the prices of the plan or addons.
EndOfTerm[(val)](val)
optional, boolean, default=false
Set this to true if you want the update to be applied at the end of the current subscription billing cycle.
IncludeDelayedCharges[(val)](val)
optional, boolean, default=false
If true, all the unbilled charges will be included for the invoice estimate.
UseCustomerBalances[(val)](val)
optional, boolean, default=false
If true, all the existing balances - promotional credits, refundable credits and excess payments - will be included for the invoice estimate.
SubscriptionId(val)
required, string, max chars=50
A unique and immutable identifier for the subscription. If not provided, it is autogenerated.
SubscriptionPlanId(val)
optional, string, max chars=100
Identifier of the plan for this subscription
SubscriptionPlanQuantity(val)
optional, integer, default=1, min=1
Represents the plan quantity for this subscription.
SubscriptionStartDate(val)
optional, timestamp(UTC) in seconds
The new start date of a future subscription. Applicable only for future subscriptions.
SubscriptionTrialEnd(val)
optional, timestamp(UTC) in seconds
The time at which the trial has ended or will end for the subscription. This is only allowed when the subscription status is future, in_trial, or cancelled. Also, the value must not be earlier than changes_scheduled_at or start_date. Note: This parameter can be backdated (set to a value in the past) only when the subscription is in cancelled or in_trial status. Do this to keep a record of when the trial ended in case it ended at some point in the past. When trial_end is backdated, the subscription immediately goes into active or non_renewing status.
SubscriptionCoupon(val)
optional, string, max chars=100

Used to uniquely identify the coupon in your website/application and to integrate with Chargebee.

Note:

When the coupon ID contains a special character; for example: #, the API returns an error. Make sure that you encode the coupon ID in the path parameter before making an API call.

BillingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
BillingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
BillingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

ShippingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
ShippingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
ShippingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

CustomerVatNumber(val)
optional, string, max chars=20
VAT number of this customer. If not provided then taxes are not calculated for the estimate. Applicable only when taxes are configured for the EU or UK region. VAT validation is not done for this.
AddonId(idx,val)
optional, string, max chars=100
Identifier of the addon. Multiple addons can be passed.
AddonQuantity(idx,val)
optional, integer, default=1, min=1
Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
AddonProrationType(idx,val)
optional, enumerated string
The proration_type parameter allows you to specify how each addon should be charged when you update a subscription in the middle of a billing period. This parameter provides three enum values:
Possible values are
FullTermfull charge will be added for the partial termPartialTermprorated charge will be calculated for the partial term.NoneNo charge will be added for the partial term
FullTermfull charge will be added for the partial termPartialTermprorated charge will be calculated for the partial term.NoneNo charge will be added for the partial term
Show all values[+]
estimate estimate
always returned
Resource object representing estimate

Sample admin console URL

https://{site}.chargebee.com/admin-console/estimates/123x

This returns an estimate of the amount that will be charged when the subscription renews. The estimate is calculated based on the items present in the subscription. This includes the plan, addons and coupons(if any) of the subscription. This API is not supported for "Cancelled" subscriptions.

You can also specify whether you need the estimate to include delayed charges.

For "Non Renewing" subscriptions, only delayed charges(one time charges and non renewing addons) that may have been added to the subscription to be charged at the end of the current term will be included. Plan, addons and coupons(if any) of the subscription will not be included.

This API will not generate a renewal invoice if an advance invoice is already present for the subscription.

Notes

Sample Codes
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.RenewalEstimate("__test__5SK0bLNFRFuBxMhAX").Request();

Estimate estimate = result.Estimate;

copy
Click to Copy
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.RenewalEstimate("__test__5SK0bLNFRFuBxMhAX").Request();

Estimate estimate = result.Estimate;

Sample Result [ JSON ]

Show more...
{
    "estimate": {
        "amount": 895,
        "amount_due": 895,
        "collect_now": false,
        "created_at": 1517506678,
        "credits_applied": 0,
        "line_items": [
            {
                "amount": 895,
                "date_from": 1519925877,
                "date_to": 1522604277,
                "description": "No Trial",
                "entity_id": "no_trial",
                "entity_type": "plan",
                "is_taxed": false,
                "object": "line_item",
                "quantity": 1,
                "tax": 0,
                "type": "charge",
                "unit_amount": 895
            },
            {..}
        ],
        "object": "estimate",
        "price_type": "tax_exclusive",
        "recurring": true,
        "sub_total": 895,
        "subscription_id": "__test__5SK0bLNFRFuBxMhAX",
        "subscription_status": "active",
        "term_ends_at": 1519925877
    }
}

URL Format GET

https://{site}.chargebee.com/api/v1/subscriptions/{subscription-id}/renewal_estimate

Method

Estimate.RenewalEstimate(<subscription_id>)
IncludeDelayedCharges[(val)](val)
optional, boolean, default=true
If true, all the unbilled charges will be included for the invoice estimate.
UseCustomerBalances[(val)](val)
optional, boolean, default=false
If true, all the existing balances - promotional credits, refundable credits and excess payments - will be included for the invoice estimate.
estimate estimate
always returned
Resource object representing estimate

Sample admin console URL

https://{site}.chargebee.com/admin-console/estimates/123x

Generates an estimate for the 'create an invoice' operation. This is similar to the Create an invoice API, but the invoice will not be generated. Only an estimate for this operation is created.

Notes

Sample Codes
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateInvoice()
		.InvoiceCustomerId("__test__5SK2liZoRZxq5Dum")
		.ChargeAmount(0,1000)
		.ChargeDescription(0,"Adhoc charge")
		.Request();

Estimate estimate = result.Estimate;

copy
Click to Copy
 
using ChargeBee.Api;
using ChargeBee.Models;
ApiConfig.Configure("{site}","{site_api_key}");
EntityResult result = Estimate.CreateInvoice()
		.InvoiceCustomerId("__test__5SK2liZoRZxq5Dum")
		.ChargeAmount(0,1000)
		.ChargeDescription(0,"Adhoc charge")
		.Request();

Estimate estimate = result.Estimate;

Sample Result [ JSON ]

Show more...
{
    "estimate": {
        "amount": 1000,
        "amount_due": 1000,
        "collect_now": true,
        "created_at": 1517480026,
        "credits_applied": 0,
        "line_items": [
            {
                "amount": 1000,
                "date_from": 1517480026,
                "date_to": 1517480026,
                "description": "Adhoc charge",
                "entity_type": "adhoc",
                "is_taxed": false,
                "object": "line_item",
                "quantity": 1,
                "tax": 0,
                "type": "charge",
                "unit_amount": 1000
            },
            {..}
        ],
        "object": "estimate",
        "price_type": "tax_exclusive",
        "recurring": false,
        "sub_total": 1000
    }
}

URL Format POST

https://{site}.chargebee.com/api/v1/estimates/create_invoice

Method

Estimate.CreateInvoice()
Coupon[(val)](val)
optional, string, max chars=100
The 'One Time' coupon to be applied.
InvoiceCustomerId(val)
optional, string, max chars=50
Identifier of the customer for which this invoice needs to be created. Should be specified if 'subscription_id' is not specified.
InvoiceSubscriptionId(val)
optional, string, max chars=50
Identifier of the subscription for which this invoice needs to be created. Should be specified if 'customer_id' is not specified.(not applicable for consolidated invoice)
InvoicePoNumber(val)
optional, string, max chars=100
Purchase Order Number for this invoice.
CustomerVatNumber(val)
optional, string, max chars=20
VAT number of this customer. If not provided then taxes are not calculated for the estimate. Applicable only when taxes are configured for the EU or UK region. VAT validation is not done for this.
CustomerTaxability(val)
optional, enumerated string, default=taxable
Specifies if the customer is liable for tax
Possible values are
TaxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.Exempt
  • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
TaxableComputes tax for the customer based on the site configuration. In some cases, depending on the region, shipping_address is needed. If not provided, then billing_address is used to compute tax. If that’s not available either, the tax is taken as zero.Exempt
  • Customer is exempted from tax. When using Chargebee’s native Taxes feature or when using the TaxJar integration, no other action is needed.
  • However, when using our Avalara integration, optionally, specify entity_code or exempt_number attributes if you use Chargebee’s AvaTax for Sales or specify exemption_details attribute if you use Chargebee’s AvaTax for Communications integration. Tax may still be applied by Avalara for certain values of entity_code/exempt_number/exemption_details based on the state/region/province of the taxable address.
Show all values[+]
BillingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
BillingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
BillingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

ShippingAddressFirstName(val)
optional, string, max chars=150
The first name of the contact.
ShippingAddressLastName(val)
optional, string, max chars=150
The last name of the contact.
ShippingAddressEmail(val)
optional, string, max chars=70
The email address.
ShippingAddressCompany(val)
optional, string, max chars=250
The company name.
ShippingAddressPhone(val)
optional, string, max chars=50
The phone number.
ShippingAddressLine1(val)
optional, string, max chars=150
Address line 1
ShippingAddressLine2(val)
optional, string, max chars=150
Address line 2
ShippingAddressLine3(val)
optional, string, max chars=150
Address line 3
ShippingAddressCity(val)
optional, string, max chars=50
The name of the city.
ShippingAddressStateCode(val)
optional, string, max chars=50
The ISO 3166-2 state/province code without the country prefix. Currently supported for USA, Canada and India. For instance, for Arizona (USA), set state_code as AZ (not US-AZ). For Tamil Nadu (India), set as TN (not IN-TN). For British Columbia (Canada), set as BC (not CA-BC).
ShippingAddressState(val)
optional, string, max chars=50
The state/province name. Is set by Chargebee automatically for US, Canada and India If state_code is provided.
ShippingAddressZip(val)
optional, string, max chars=20
Zip or postal code. The number of characters is validated according to the rules specified here.
ShippingAddressCountry(val)
optional, string, max chars=50
The billing address country of the customer. Must be one of ISO 3166 alpha-2 country code.

Note: If you enter an invalid country code, the system will return an error.

Brexit

If you have enabled EU VAT in 2021 or later, or have manually enable the Brexit configuration, then XI (the code for United Kingdom – Northern Ireland) is available as an option.

AddonId(idx,val)
optional, string, max chars=100
Identifier of the addon. Multiple addons can be passed.
AddonQuantity(idx,val)
optional, integer, default=1, min=1
Quantity of the addon. Applicable for addons with pricing_model other than flat_fee.
ChargeAmount(idx,val)
optional, in cents, min=1
The amount to be charged. The unit depends on the type of currency.
ChargeDescription(idx,val)
optional, string, max chars=250
Description for this charge
estimate estimate
always returned
Resource object representing estimate

Sample admin console URL

https://{site}.chargebee.com/admin-console/estimates/123x