laravel / cashier-stripe

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.
https://laravel.com/docs/billing
MIT License
2.37k stars 671 forks source link

Cashier::useCurrency() missing #741

Closed clive-verrall closed 5 years ago

clive-verrall commented 5 years ago

Description:

The method Cashier::useCurrency() can't be found in Cashier v10.

There is no mention in the upgrade guide of this method being removed or of any other way of dynamically setting the Cashier currency at run time. If this is an over sight, can the method be added back in please?

IMHO, for the same Laravel application to allow subscriptions in the local currency of the subscriber it is necessary to change the Cashier currency dynamically when that user logs in. I have subscribers in multiple countries, each wants pricing in their local currency and subscription payments in their local currency.

If there is another way to solve this problem then I will be delighted to hear about it.

Steps To Reproduce:

Try Cashier 8 code that uses Cahsier::userCurrency() Run it again on v10 and it will fail with "Call to undefined method error".

driesvints commented 5 years ago

Hey @clive-verrall. Thanks for pointing this out. We indeed forgot to add this in the upgrade guide. All of the currency settings have been moved to the new config file. The new formatAmount method on the Cashier object that you can use to format money values accepts a secondary $currency parameter which you can use to choose whatever currency you want.

I'll add this to the upgrade guide on Monday.

scottybo commented 5 years ago

For anyone else who comes across this issue, if you want to modify the currency on the fly, you can do something along the lines of:

Config::set('cashier.currency', 'usd');

Note that you no longer need to specify the symbol as this is now automatically handled by Cashier.