The interface
getRate() returns the multiplier that converts an amount in $from into $to. It’s called during checkout, so it must be fast and must not throw for a currency pair you support.
Implementation
Rates change slowly, so fetch them in bulk and cache them. Storing them in an option makes them survive cache clears and keeps the checkout path free of network calls.src/AcmeRates.php
Register it
src/Plugin.php
option.currency.provider.
Settings page
The billing page links to/admin/settings/rate-providers/{key}, so declare that route and point extra.default_url at it:
Testing
Set a gateway to a currency other than the platform default and confirm the charge is converted.
The converted amount is plausible, and rounding lands on whole minor units.
Rates are fetched once and reused until they expire.
With an invalid API key, checkout still completes in the default currency.