This also enables EUR payment methods in mollie.
This now just converts directly using the exchange rate from openexchangerates.org, without applying any safety margin.
I removed the "Application Currency" from the config because it doesn't seem to make sense in our case (we have per wallet currencies), and I assume it was initially added due to some copy/paste work. May be that some other cleanup could be done in that config file.
I was going to say that it would probably be better to move it to app\Providers, but thinking more, I'm not sure. Maybe it's ok and we should rather move payment providers code here, and leave app\Providers for the Laravel framework stuff only.
Missing argument doc.
Short array syntax, please (here and below). Shouldn't it be 'base' => $base_currency?
I don't remember if we ever do both Log::error() and throw. Looks redundant.
A space after the cast would be nice.
Again, the phpdoc formatting is not correct.
I think Jeroen and I would prefer to do this differently. When fetching the exchange rates we rather use cron and store the rates in a file (or DB). This way a failing request to openexchangerates website does not cause issues for our users. In such cases we'd just use the old rates instead of throwing an exception.
This config file was added when Jeroen did some testing with "torann/currency" package. We got rid of it since, but forgot about the file. So, you can remove what we don't need from it.
Looks good to me. Two things:
- Some tests would be nice.
- In bin/quickstart.php we should probably run the command if the api key is set somewhere. And/or maybe we should check-in some already fetched data into the repository. It will be needed for tests.
@vanmeeuwen should also review this.
This code does not look nice. We should make exchange() to be able to work with any exchange direction. Actually exchangeRate() should.
Also, how about adding a couple of simple tests for exchange() and/or exchangeRate() itself? Also maybe remove exchangeRate() from the payment provider and use the one from Utils directly, the wrapper should not be needed.