Scope
chargebee.api_error.InvalidRequestError: currency_code : Not applicable when subscription_id is specified.
Summary
This error normally occurs when you pass the currency_code for Charges in PC 2.0. Currency_code is applicable only when we raise unbilled charges for Quick Charges and it has to be the same as Subscription currency.
Solution
Referring to the API documentation for ‘Create unbilled charges for item subscription’ the ‘currency_code’ under Input parameters is ‘Required’ and not Optional.
Charges:
If you would like to add Charges, you need to pass on ‘item_prices[item_price_id][0..n]’ and while doing so, you don’t have to add ‘currency_code’ though you have multi-currency enabled. Chargebee will automatically consider the Subscription’s currency.
Quick Charges:
Quick charges require currency codes as they are charges that aren’t pre-defined and created manually. You will also see this parameter on the Chargebee UI.
Sample Screenshot of Quick Charges in Chargebee UI:
Hence, in the case of Quick Charges (or) one-time charges, it is required to pass the ‘currency_code’ parameter also the currency code must be the same as the subscription’s currency.
To know more about API docs
Related Links:
What is the difference between Charges and Quick Charges in PC 2.0?
How to view the details of changes to the unbilled charges via the API?