-
Notifications
You must be signed in to change notification settings - Fork 52
Architecture
gringotts
is an OTP application and launches a worker
when it
is started. All calls made to the API (ie, Gringotts.*()
calls) are
serviced by this worker
.
The merchants provide their authentication secrets for each of the Gateway they
use in the Application
config. You can see an example of the
config/config.exs
in the example repo.
Currently,
gringotts
does not fetch the secrets from the system environment.
This information is picked by the worker
and is added to the opts
argument
under the :config
key. Let's say GatewayXYZ
gives the merchant an
:api_key
, then the merchant would put this in his config.exs
:
config :gringotts, Gringotts.Gateways.GatewayXYZ,
adapter: Gringotts.Gateways.GatewayXYZ,
api_key: "merchant's_valuable_secret",
A call to
Gringotts.purchase(GatewayXYZ, amount, card, foo: "bar")
will eventually hit the GatewayXYZ
module
GatewayXYZ.purchase(
amount,
card,
[config: %{api_key: "merchant's_valuable_secret"},
foo: "bar"]
)
So during development, we recommend adding a variable binding for the opts
argument:
opts = [config: {auth_key: "your_secret_value"}] ++ other_opts
instead of providing this information in gringotts/config/config.exs
. See
Adding a new Gateway for a concrete example.
Where to next? Wanna add a new gateway? Head to our guide for that.
Chat/Discuss with the core team directly on gitter!