Gocardless
Elixir wrapper for the GoCardless API.
Installation
-
Add
gocardlessto your list of dependencies in mix.exs:
def deps do
[{:gocardless, "~> 1.0.0"}]
endthen...
mix deps.get-
Ensure
gocardlessis started before your application:
def application do
[applications: [:gocardless]]
end- Add configuration to your app:
config :gocardless,
api_base: "https://api-sandbox.gocardless.com/",
api_version: "2015-07-06",
access_token: "<your-token>"- Example usage:
iex> params = %{
email: "name@email.com",
given_name: "Firstname",
family_name: "Lastname",
country_code: "GB"
}
iex> Gocardless.Client.create_customer(%{customers: params})
{:ok,
%{"customers" => %{"address_line1" => nil, "address_line2" => nil,
"address_line3" => nil, "city" => nil, "company_name" => nil,
"country_code" => "GB", "created_at" => "2017-06-23T13:04:45.459Z",
"email" => "name@email.com", "family_name" => "Lastname",
"given_name" => "Firstname", "id" => "CU0009999999", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}}}For more information, see the Hex docs
You can read the docs here
Development Setup
If you are making changes to this codebase and want to test your code, you will need to copy the sample secret file.
cp config/secret.sample.exs config/secret.exs
Then add your GoCardless token where the key is access_token.
Implementation state
Resources that are implemented so far.
- Customers
- Customer Bank Accounts
- Mandates
- Payments
- Creditors
- Events
- Creditor Bank Accounts
- Payouts
- Redirect Flows
- Refunds
- Subscriptions
Areas of the codebase that can be improved.
- Testing error cases