gringotts
gringotts copied to clipboard
keep common requirements in global config
The certain requirements which are common to all the gateways e.g. currency
can be kept in the global config
.
These should be overridden if something else is set by the gateway.
Example
Global configuration
config :gringotts, :global_config,
mode: :test
default_currency: 'USD'
Gateway specific configuration
# Keep the `key` name same as the adapter name
config :gringotts, Gringotts.Gateways.Stripe,
adapter: Gringotts.Gateways.Stripe,
api_key: "sk_test_vIX41hayC0BKrPWQerLuOMld",
default_currency: "EUR"
Updated Checks and modifications needed.(25th Jan)
- [ ] All the gateways require changes for this feature; sometimes there is just one url for both test and live, some have just one.
- [ ] Add this in the main documentation and on the getting started guide.
Updates(25th Jan):
We are just adding test
mode in the global_config
.
Though a default currency is required by all gateways, IMO it is unlikely that it will be same across all gateways:
- Large multi-national merchants might use multiple gateways because some gateways offer better/cheaper service in some regions, but not in others. In that case, each of these gateways would be configured for a different currency.
- All gateways should set a default currency (since this is truly very specific to a gateway and not merchant dependent), but where? We could do something like this or add it in the
required_config
for all gateways.
After the introduction of #62 and merges in #71 #85 it becomes evident that the lib users can use money lib to create money object.
Responsibility of creating a correct money struct lies on the developer and follows the rules and constraints of money ex_money lib.
Hence, having default_currency
in the global config does not make much sense now.