Chargebee's Multi-currency feature allows you to create Plans in multiple currencies, enabling your customers to conveniently pay in their preferred local currency. Please review this documentation to understand the multi-currency feature in Chargebee.
This currency resource contains exchange rate configurations associated with a specific currency. The multi-currency feature must be enabled, and all prerequisites must be addressed to successfully add a new currency via the API.
To invoke a single currency-specific API like update, retrieve, and more, the currency ID has to be passed as a path parameter. You can use list API to fetch the IDs of each currency configured in your site to use with the currency-specific APIs below. Chargebee supports billing in over 100 currencies.
On this page, you can find information about how currency units are expressed in the API, as well as some pointers to keep in mind when using multiple currencies.
By default, the Chargebee API supports only whole numbers for currency values. To allow for fractional (decimal) values, you must enable the multi-decimal pricing feature. Additionally, the units in which currencies are expressed in the API depend on whether the currency is zero-decimal and whether multi-decimal pricing is enabled.
By default, Chargebee supports currency values in whole numbers; fractions are not supported. In the API, currency values can be identified by checking their data types. For all whole number currency values in this API, the data type is indicated as "in cents" in this documentation.
The specific unit used for the currency in the API depends on whether it is a zero-decimal currency:
15
.
153
.
When multi-decimal pricing is enabled in Chargebee, you can work with fractional currency values using dedicated API parameters and attributes of the String
type. Usually, these attributes and parameters have the suffix _in_decimal
in their names. The value is expressed in the major unit of the currency, which is the unit represented
by its ISO 4217
code. For example, $1.6782 should be provided as 1.6782
. The maximum number of decimal places supported by the API can be configured in
the admin console.
Note: For zero-decimal currencies, such as the Japanese Yen (JPY), decimal places are not allowed.
amount
attribute is always rounded off to two decimal places in the major unit of the currency. The major unit of a currency is the unit represented by its
ISO 4217 code.
The rounding logic used is ROUND_HALF_EVEN
. For example, if the quantity
is 0.0765 and unit_amount
is $10.674, the line item amount
is (0.0765 x $10.674) = $0.816561 and is rounded off to $0.82.
By default, Chargebee is able to process transactions in only one currency. However, you can enable the multi-currency feature to support more currencies. The first currency enabled in Chargebee also becomes the "base currency" by default. If you have multiple currencies enabled and want to change the base currency for your site, reach out to Support for assistance.
Warning
For some API endpoints, the currency_code
parameter becomes required when the multi-currency feature is enabled. Before enabling the feature for your site, ensure that you update your code to provide the currency_code
parameter when calling the endpoints listed in the next section.
currency_code
parameter to be passed when the multi-currency feature has been enabled.
{
"currency": {
"id": "cur_XpbNwDtU56AzUh3j",
"currency_code": "USD",
"is_base_currency": true,
"forex_type": "auto"
}
}
ChargeBee::Currency
forex_type
is manual
, you will be able to set the conversion rate for the currency. You need to update the exchange rate each time your exchange rate provider changes itautoIf forex_type
is auto
, conversion rate will be auto updated by Chargebee every day with third party providers (using external currency conversion providers)require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.list({ :limit => "5" }) currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.list({ :limit => "5" }) currency = result.currency
ChargeBee::Currency.list({<param name> => <value>,<param name> => <value> ...})
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.retrieve("cur_XpbNwDtU56AzUh3j") currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.retrieve("cur_XpbNwDtU56AzUh3j") currency = result.currency
ChargeBee::Currency.retrieve(<site_currency_id>,{<param name> => <value>,<param name> => <value> ...})
forex_type
is set to manual
, you can specify the manual_exchange_rate
. Additionally, the currency code provided must adhere to the three-letter ISO standard currency codes.require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.create({ :currency_code => "EUR", :forex_type => "MANUAL", :manual_exchange_rate => "1.234784" }) currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.create({ :currency_code => "EUR", :forex_type => "MANUAL", :manual_exchange_rate => "1.234784" }) currency = result.currency
ChargeBee::Currency.create({<param name> => <value>,<param name> => <value> ...})
forex_type
is manual
, you will be able to set the conversion rate for the currency. You need to update the exchange rate each time your exchange rate provider changes itautoIf forex_type
is auto
, conversion rate will be auto updated by Chargebee every day with third party providers (using external currency conversion providers)forex_type
is manual
you have to set the exchange rate for additional currencies in manual_exchange_rate
parameter. A maximum of nine decimal values are allowed to pass in this field. forex_type
is set to manual
, you can specify the manual_exchange_rate
.require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.update("cur_XpbNwDtU56AzUh3j",{ :forex_type => "MANUAL", :manual_exchange_rate => "1.234784" }) currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.update("cur_XpbNwDtU56AzUh3j",{ :forex_type => "MANUAL", :manual_exchange_rate => "1.234784" }) currency = result.currency
ChargeBee::Currency.update(<site_currency_id>,{<param name> => <value>,<param name> => <value> ...})
forex_type
is manual
, you will be able to set the conversion rate for the currency. You need to update the exchange rate each time your exchange rate provider changes itautoIf forex_type
is auto
, conversion rate will be auto updated by Chargebee every day with third party providers (using external currency conversion providers)forex_type
is manual
you have to set the exchange rate for additional currencies in manual_exchange_rate
parameter. A maximum of nine decimal values are allowed to pass in this field. manual
forex_type
currency.require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.add_schedule("cur_XpbNwDtU56AzUh3j",{ :manual_exchange_rate => "1.234784", :schedule_at => 1608209339 }) currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.add_schedule("cur_XpbNwDtU56AzUh3j",{ :manual_exchange_rate => "1.234784", :schedule_at => 1608209339 }) currency = result.currency
ChargeBee::Currency.add_schedule(<site_currency_id>,{<param name> => <value>,<param name> => <value> ...})
forex_type
is manual
you have to set the exchange rate for additional currencies in manual_exchange_rate
parameter. A maximum of nine decimal values are allowed to pass in this field. require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.remove_schedule("cur_XpbNwDtU56AzUh3j") currency = result.currency
require 'chargebee' ChargeBee.configure(:site => "{site}", :api_key => "{site_api_key}") result = ChargeBee::Currency.remove_schedule("cur_XpbNwDtU56AzUh3j") currency = result.currency
ChargeBee::Currency.remove_schedule(<site_currency_id>,{<param name> => <value>,<param name> => <value> ...})