1

I have a Laravel Spark project in which I'd like to offer plans in multiple currencies dependent on the user's geolocation.

I think each plan would have to be 'replicated' for its desired currency so I'm thinking something like the following would be required:

Spark::teamPlan('Business', 'business-usd')
        ->price(7)
        ->attributes([
            'currency' => "usd"
        ])
        ->features([
            'First', 'Second', 'Third'
        ]);

Spark::teamPlan('Business', 'business-gbp')
        ->price(7)
        ->attributes([
            'currency' => "gbp"
        ])
        ->features([
            'First', 'Second', 'Third'
        ]);

I know you can set the currency that Cashier uses by calling the following:

Laravel\Cashier\Cashier::useCurrency($plan->attributes['currency']);

But I can't work out where there would be a sensible place to make this call, or whether this would even be the right approach. Does anybody have any experience with this? Or even offer any insight into the rationale behind this approach?

Adam Thomason
  • 1,118
  • 11
  • 23
  • 1
    I've been developing a Laravel Spark application for the past two years, but it is yet to be released (soon now) therefore I have yet to encounter this obstacle. What you're asking is completely logical and other developers have been looking for a solution too. Creating separate plans per currency is the best approach as you've mentioned. I will find a solution to supporting multiple currencies in Laravel Spark, and once I do I'll either post here (if I remember) or I'll create a pull request on the Laravel Spark repository so everyone can benefit via an update. – aullah Dec 21 '20 at 20:40

0 Answers0