gocardless v1.0.3 Gocardless.Client
Starts up Gocardless Client
Uses Gocardless.ClientApi.Customer
and other client APIs
from /lib/client_apis/
Link to this section Summary
Functions
Cancels a mandate based on their ID in GoCardless
Cancels the payment if it has not already been submitted to the banks
Examples
Completes a Redirect Flow
Creates a new Creditor
Creates a new Creditor Bank Account
Creates a new Customer
Creates a new Customer Bank Account
Creates a new mandate
Creates a new Payment
Creates a new Redirect Flow
Creates a new Refund
Creates a new Subscription
Disables a Creditor Bank Account based on their ID in GoCardless
Gets a Creditor based on their ID in GoCardless
Gets a Creditor Bank Account based on their ID in GoCardless
Gets a Customer based on their ID in GoCardless
Gets a Customer Bank Account based on their ID in GoCardless
Gets an individual event by ID
Gets a mandate based on their ID in GoCardless
Gets an individual payment by ID
Gets an individual payout by ID
Gets a Redirect Flow based on their ID in GoCardless
Gets a Refund based on their ID in GoCardless
Gets a Subscription based on their ID in GoCardless
Callback implementation for Gocardless.Behaviour.CreditorBankAccount.list_creditor_bank_accounts/1
Callback implementation for Gocardless.Behaviour.Creditor.list_creditors/1
Lists Customer Bank Accounts from GoCardless
Lists Customers from GoCardless
Lists all events
Lists mandates from GoCardless
Lists all payments
Lists all payouts
Lists Refunds from GoCardless
Lists Subscriptions from GoCardless
Creates a new mandate preview
Reinstates a mandate based on their ID in GoCardless
Retries a failed payment if the underlying mandate is active
Updates a Creditor based on their ID in GoCardless
Updates a Customer based on their ID in GoCardless
Updates a Customer Bank Account metadata based on their ID in GoCardless. Only the metadata parameter is allowed
Updates a mandate based on their ID in GoCardless
Updates a Payment metadata based by ID. Only the metadata parameter is allowed
Updates a Refund metadata based on their ID in GoCardless. Only the metadata parameter is allowed
Updates a Subscription in GoCardless
Link to this section Functions
Cancels a mandate based on their ID in GoCardless
Examples
iex> Gocardless.Client.cancel_mandate("MD000999999999")
{:ok,
%{"mandates" => %{"created_at" => "2017-06-23T15:31:52.850Z",
"id" => "MD000999999999",
"links" => %{"creditor" => "CR000999999999",
"customer" => "CU000999999999",
"customer_bank_account" => "BA000999999999"},
"metadata" => %{}, "next_possible_charge_date" => nil,
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "cancelled"}}}
Callback implementation for Gocardless.Behaviour.Mandate.cancel_mandate/1
.
Cancels the payment if it has not already been submitted to the banks.
Examples
iex> Gocardless.Client.cancel_payment("PM000099999999")
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{"db_id" => "1234"},
"reference" => nil, "status" => "cancelled"}}}
Callback implementation for Gocardless.Behaviour.Payment.cancel_payment/2
.
Examples
iex> Gocardless.Client.cancel_subscription("SB000999999998")
{:ok,
%{"subscriptions" => %{"amount" => 2500,
"created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
"day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
"interval" => 1, "interval_unit" => "monthly",
"links" => %{"mandate" => "MD000999999998"},
"metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
"name" => "Updated Name", "payment_reference" => nil,
"start_date" => "2017-07-03", "status" => "cancelled",
"upcoming_payments" => []}}}
Callback implementation for Gocardless.Behaviour.Subscription.cancel_subscription/1
.
Completes a Redirect Flow
Examples
iex> params = %{data: %{session_token: "SESS_0000000000000000"}}
iex> Gocardless.Client.complete_redirect_flow("RE000099999999999999999999999999", params)
{:ok,
%{"redirect_flows" => %{"created_at" => "2017-06-26T14:48:26.874Z",
"description" => nil, "id" => "RE000099999999999999999999999999",
"links" => %{"creditor" => "CR000999999998",
"customer" => "CU000999999998",
"customer_bank_account" => "BA000999999998",
"mandate" => "MD000999999998"}, "scheme" => nil,
"session_token" => "SESS_0000000000000000",
"success_redirect_url" => "https://mysite.com/redirect_path"}}}
Callback implementation for Gocardless.Behaviour.RedirectFlow.complete_redirect_flow/2
.
Creates a new Creditor
Examples
iex> params = %{
creditors: %{
name: "Test Creditor"
}
}
iex> Gocardless.Client.create_creditor(params)
{:ok, %{"address_line1" => nil, "address_line2" => nil, "address_line3" => nil,
"city" => nil, "country_code" => nil,
"created_at" => "2017-06-27T08:52:52.655Z", "id" => "CR000099999999",
"links" => %{}, "logo_url" => nil, "name" => "Test Creditor",
"postal_code" => nil, "region" => nil,
"scheme_identifiers" => [%{"address_line1" => "338-346 Goswell Road",
"address_line2" => nil, "address_line3" => nil,
"can_specify_mandate_reference" => false, "city" => "London",
"country_code" => "GB", "currency" => "GBP",
"email" => "help@gocardless.com", "minimum_advance_notice" => 3,
"name" => "GoCardless", "phone_number" => "+40 20 1234 1234",
"postal_code" => "EC1V 7LQ", "reference" => "275069", "region" => nil,
"scheme" => "bacs"}], "verification_status" => "successful"}}
Callback implementation for Gocardless.Behaviour.Creditor.create_creditor/1
.
Creates a new Creditor Bank Account
Examples
iex> params = %{
creditor_bank_accounts: %{
account_holder_name: "John Doe",
account_number: "55779911",
branch_code: "200000",
country_code: "GB",
links: %{
creditor: "CR000099999999"
}
}
}
iex> Gocardless.Client.create_creditor_bank_account("BA000999999999")
{:ok,
%{"creditor_bank_accounts" => %{"account_holder_name" => "JOHN DOE",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-27T11:16:37.353Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999999",
"links" => %{"creditor" => "CR000099999999"}, "metadata" => %{}},
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.CreditorBankAccount.create_creditor_bank_account/1
.
Creates a new Customer
Examples
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" => "CU00099999999", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}}}
Callback implementation for Gocardless.Behaviour.Customer.create_customer/1
.
Creates a new Customer Bank Account
Examples
iex> params = %{
customer_bank_accounts: %{
account_holder_name: "FirstName LastName",
account_number: "55779911",
branch_code: "200000",
country_code: "GB",
links: %{
customer: "CU000999999998"
}
}
}
iex> Gocardless.Client.create_customer_bank_account(params)
{:ok,
%{"customer_bank_accounts" => %{"account_holder_name" => "FirstName LastName",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-23T13:37:09.967Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999998",
"links" => %{"customer" => "CU000999999998"}, "metadata" => %{}}}}
Callback implementation for Gocardless.Behaviour.CustomerBankAccount.create_customer_bank_account/1
.
Creates a new mandate
Examples
iex> params = %{
scheme: "bacs",
links: %{customer_bank_account: "BA000999999999"}
}
iex> Gocardless.Client.create_mandate(%{mandates: params})
{:ok,
%{"mandates" => %{"created_at" => "2017-06-23T15:29:20.872Z",
"id" => "MD000999999999",
"links" => %{"creditor" => "CR000999999999",
"customer" => "CU000999999999",
"customer_bank_account" => "BA000999999999"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Mandate.create_mandate/1
.
Creates a new Payment
Examples
iex> params = %{
payments: %{
amount: 100,
currency: "GBP",
charge_date: "2017-06-30",
links: %{
mandate: "MD000099999999"
}
}
}
iex> Gocardless.Client.create_payment(params)
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
"status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Payment.create_payment/1
.
Creates a new Redirect Flow
Examples
iex> params = %{
redirect_flows: %{
session_token: "SESS_0000000000000000",
success_redirect_url: "https://mysite.com/redirect_path"
}
}
iex> Gocardless.Client.create_redirect_flow(params)
{:ok,
%{"redirect_flows" => %{"created_at" => "2017-06-26T14:48:26.874Z",
"description" => nil, "id" => "RE000099999999999999999999999999",
"links" => %{"creditor" => "CR000999999998"},
"redirect_url" => "https://pay-sandbox.gocardless.com/flow/RE000099999999999999999999999999",
"scheme" => nil, "session_token" => "SESS_0000000000000000",
"success_redirect_url" => "https://mysite.com/redirect_path"}}}
Callback implementation for Gocardless.Behaviour.RedirectFlow.create_redirect_flow/1
.
Creates a new Refund
Examples
iex> params = %{
refunds: %{
amount: 100,
total_amount_confirmation: 100,
reference: "partial refund",
links: %{
payment: "PM000999999998"
}
}
}
iex> Gocardless.Client.create_refund(params)
{:ok,
%{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
"currency" => "GBP", "id" => "RF000999999998",
"links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
"reference" => "partial refund"}}}
Callback implementation for Gocardless.Behaviour.Refund.create_refund/1
.
Creates a new Subscription
Examples
iex> params = %{
subscriptions: %{
amount: "2500",
currency: "GBP",
name: "Monthly Magazine",
interval_unit: "monthly",
day_of_month: "1",
metadata: %{
"order_no": "ABCD1234"
},
links: %{
mandate: "MD000999999998"
}
}
}
iex> Gocardless.Client.create_subscription(params)
{:ok,
%{"subscriptions" => %{"amount" => 2500,
"created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
"day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
"interval" => 1, "interval_unit" => "monthly",
"links" => %{"mandate" => "MD000999999998"},
"metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
"name" => "Monthly Magazine", "payment_reference" => nil,
"start_date" => "2017-07-03", "status" => "active",
"upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
%{"amount" => 2500, "charge_date" => "2017-08-01"},
%{"amount" => 2500, "charge_date" => "2017-09-01"},
%{"amount" => 2500, "charge_date" => "2017-10-02"},
%{"amount" => 2500, "charge_date" => "2017-11-01"},
%{"amount" => 2500, "charge_date" => "2017-12-01"},
%{"amount" => 2500, "charge_date" => "2018-01-02"},
%{"amount" => 2500, "charge_date" => "2018-02-01"},
%{"amount" => 2500, "charge_date" => "2018-03-01"},
%{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}
Callback implementation for Gocardless.Behaviour.Subscription.create_subscription/1
.
Disables a Creditor Bank Account based on their ID in GoCardless
Examples
iex> Gocardless.Client.disable_creditor_bank_account("BA000999999999")
{:ok,
%{"creditor_bank_accounts" => %{"account_holder_name" => "JOHN DOE",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-27T11:16:37.353Z",
"currency" => "GBP", "enabled" => false, "id" => "BA000999999999",
"links" => %{"creditor" => "CR000099999999"}, "metadata" => %{}},
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.CreditorBankAccount.disable_creditor_bank_account/1
.
Examples
iex> Gocardless.Client.disable_customer_bank_account("BA000999999998")
{:ok,
%{"customer_bank_accounts" => %{"account_holder_name" => "FirstName LastName",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-23T13:37:09.967Z",
"currency" => "GBP", "enabled" => false, "id" => "BA000999999998",
"links" => %{"customer" => "CU000999999998"},
"metadata" => %{}}}}
Callback implementation for Gocardless.Behaviour.CustomerBankAccount.disable_customer_bank_account/1
.
Gets a Creditor based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_creditor("CR000099999999")
{:ok, %{"address_line1" => nil, "address_line2" => nil, "address_line3" => nil,
"city" => nil, "country_code" => nil,
"created_at" => "2017-06-27T08:52:52.655Z", "id" => "CR000099999999",
"links" => %{}, "logo_url" => nil, "name" => "Test Creditor",
"postal_code" => nil, "region" => nil,
"scheme_identifiers" => [%{"address_line1" => "338-346 Goswell Road",
"address_line2" => nil, "address_line3" => nil,
"can_specify_mandate_reference" => false, "city" => "London",
"country_code" => "GB", "currency" => "GBP",
"email" => "help@gocardless.com", "minimum_advance_notice" => 3,
"name" => "GoCardless", "phone_number" => "+40 20 1234 1234",
"postal_code" => "EC1V 7LQ", "reference" => "275069", "region" => nil,
"scheme" => "bacs"}], "verification_status" => "successful"}}
Callback implementation for Gocardless.Behaviour.Creditor.get_creditor/1
.
Gets a Creditor Bank Account based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_creditor_bank_account("BA000999999999")
{:ok,
%{"creditor_bank_accounts" => %{"account_holder_name" => "JOHN DOE",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-27T11:16:37.353Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999999",
"links" => %{"creditor" => "CR000099999999"}, "metadata" => %{}},
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.CreditorBankAccount.get_creditor_bank_account/1
.
Gets a Customer based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_customer("CU000999999998")
{:ok,
%{"customers" => %{"address_line1" => nil, "address_line2" => nil,
"address_line3" => nil, "city" => nil, "company_name" => nil,
"country_code" => "GB", "created_at" => "2017-06-23T10:47:22.248Z",
"email" => "name@email.com", "family_name" => "Lastname",
"given_name" => "Firstname", "id" => "CU000999999998", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}}}
Callback implementation for Gocardless.Behaviour.Customer.get_customer/1
.
Gets a Customer Bank Account based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_customer_bank_account("BA000999999998")
{:ok,
%{"customer_bank_accounts" => %{"account_holder_name" => "FirstName LastName",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-23T13:37:09.967Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999998",
"links" => %{"customer" => "CU000999999998"},
"metadata" => %{"account_holder_name" => "FirstName LastName"}}}}
Callback implementation for Gocardless.Behaviour.CustomerBankAccount.get_customer_bank_account/1
.
Gets an individual event by ID
Examples
iex> Gocardless.Client.get_event("EV000099999999")
{:ok,
%{"events" => %{"action" => "created",
"created_at" => "2017-06-27T10:00:26.278Z",
"details" => %{"cause" => "payment_refunded",
"description" => "The refund has been created, and will be submitted in the next batch.",
"origin" => "api"}, "id" => "EV000099999999",
"links" => %{"refund" => "RF000099999999"}, "metadata" => %{},
"resource_type" => "refunds"}}}
Callback implementation for Gocardless.Behaviour.Event.get_event/1
.
Gets a mandate based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_mandate("MD000999999998")
{:ok,
%{"mandates" => %{"created_at" => "2017-06-23T15:29:20.872Z",
"id" => "MD000999999998",
"links" => %{"creditor" => "CR000999999998",
"customer" => "CU000999999998",
"customer_bank_account" => "BA000999999998"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Mandate.get_mandate/1
.
Gets an individual payment by ID
Examples
iex> Gocardless.Client.get_payment("PM000099999999")
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
"status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Payment.get_payment/1
.
Gets an individual payout by ID
Examples
iex> Gocardless.Client.get_payout("PO000099999999")
{:ok,
%{"payouts" => %{"amount" => 9900, "arrival_date" => "2017-06-27",
"created_at" => "2017-06-27T09:51:33.167Z", "currency" => "GBP",
"deducted_fees" => 100, "id" => "PO000099999999",
"links" => %{"creditor" => "CR000099999999",
"creditor_bank_account" => "BA000099999999"},
"payout_type" => "merchant", "reference" => "REF-REF",
"status" => "paid"}}}
Callback implementation for Gocardless.Behaviour.Payout.get_payout/1
.
Gets a Redirect Flow based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_redirect_flow("RE000099999999999999999999999999")
{:ok,
%{"redirect_flows" => %{"created_at" => "2017-06-26T14:48:26.874Z",
"description" => nil, "id" => "RE000099999999999999999999999999",
"links" => %{"creditor" => "CR000999999998"},
"redirect_url" => "https://pay-sandbox.gocardless.com/flow/RE000099999999999999999999999999",
"scheme" => nil, "session_token" => "SESS_0000000000000000",
"success_redirect_url" => "https://mysite.com/redirect_path"}}}
Callback implementation for Gocardless.Behaviour.RedirectFlow.get_redirect_flow/1
.
Gets a Refund based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_refund("RF000999999998")
{:ok,
%{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
"currency" => "GBP", "id" => "RF000999999998",
"links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
"reference" => "partial refund"}}}
Callback implementation for Gocardless.Behaviour.Refund.get_refund/1
.
Gets a Subscription based on their ID in GoCardless
Examples
iex> Gocardless.Client.get_subscription("SB000999999998")
{:ok,
%{"subscriptions" => %{"amount" => 2500,
"created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
"day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
"interval" => 1, "interval_unit" => "monthly",
"links" => %{"mandate" => "MD000999999998"},
"metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
"name" => "Monthly Magazine", "payment_reference" => nil,
"start_date" => "2017-07-03", "status" => "active",
"upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
%{"amount" => 2500, "charge_date" => "2017-08-01"},
%{"amount" => 2500, "charge_date" => "2017-09-01"},
%{"amount" => 2500, "charge_date" => "2017-10-02"},
%{"amount" => 2500, "charge_date" => "2017-11-01"},
%{"amount" => 2500, "charge_date" => "2017-12-01"},
%{"amount" => 2500, "charge_date" => "2018-01-02"},
%{"amount" => 2500, "charge_date" => "2018-02-01"},
%{"amount" => 2500, "charge_date" => "2018-03-01"},
%{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}
Callback implementation for Gocardless.Behaviour.Subscription.get_subscription/1
.
Callback implementation for Gocardless.Behaviour.CreditorBankAccount.list_creditor_bank_accounts/1
.
Callback implementation for Gocardless.Behaviour.Creditor.list_creditors/1
.
Lists Customer Bank Accounts from GoCardless
Examples
iex> Gocardless.Client.list_customer_bank_accounts
{:ok,
%{"customer_bank_accounts" => [%{"account_holder_name" => "FirstName LastName",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-23T13:37:09.967Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999998",
"links" => %{"customer" => "CU000999999998"},
"metadata" => %{"account_holder_name" => "FirstName LastName"}}],
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.CustomerBankAccount.list_customer_bank_accounts/1
.
Lists Customers from GoCardless
Examples
iex> Gocardless.Client.list_customers()
{:ok,
%{"customers" => [%{"address_line1" => nil, "address_line2" => nil,
"address_line3" => nil, "city" => nil, "company_name" => nil,
"country_code" => "GB", "created_at" => "2017-06-23T10:47:22.248Z",
"email" => "name@email.com", "family_name" => "Lastname",
"given_name" => "Firstname", "id" => "CU000999999997", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil},
%{"address_line1" => nil, "address_line2" => nil, "address_line3" => nil,
"city" => nil, "company_name" => nil, "country_code" => "GB",
"created_at" => "2017-06-22T17:11:04.112Z",
"email" => "name@email.com", "family_name" => "Lastname2",
"given_name" => "Firstname2", "id" => "CU000999999998", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}],
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
iex> Gocardless.Client.list_customers(%{"created_at[gt]" => "2017-06-22T17:18:06.000Z"})
{:ok,
%{"customers" => [%{"address_line1" => nil, "address_line2" => nil,
"address_line3" => nil, "city" => nil, "company_name" => nil,
"country_code" => "GB", "created_at" => "2017-06-23T10:47:22.248Z",
"email" => "name@email.com", "family_name" => "Lastname",
"given_name" => "Firstname", "id" => "CU000999999997", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}],
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.Customer.list_customers/1
.
Lists all events
Examples
iex> Gocardless.Client.list_events
{:ok,
%{"events" => [%{"action" => "created",
"created_at" => "2017-06-27T14:14:43.390Z",
"details" => %{"cause" => "mandate_created",
"description" => "Mandate created via the API.", "origin" => "api"},
"id" => "EV000QBP163MV1", "links" => %{"mandate" => "MD000099999999"},
"metadata" => %{}, "resource_type" => "mandates"}],
"meta" => %{"cursors" => %{"after" => "EV000099999999", "before" => nil},
"limit" => 50}}}
Callback implementation for Gocardless.Behaviour.Event.list_events/1
.
Lists mandates from GoCardless
Examples
iex> Gocardless.Client.list_mandates()
{:ok,
%{"mandates" => [%{"created_at" => "2017-06-23T15:31:52.850Z",
"id" => "MD000999999998",
"links" => %{"creditor" => "CR000999999998",
"customer" => "CU000999999998",
"customer_bank_account" => "BA000999999998"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"},
%{"created_at" => "2017-06-23T15:29:20.872Z", "id" => "MD000999999997",
"links" => %{"creditor" => "CR000999999998",
"customer" => "CU000999999998",
"customer_bank_account" => "BA000999999998"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"},
%{"created_at" => "2017-06-23T15:24:31.356Z", "id" => "MD000999999996",
"links" => %{"creditor" => "CR000999999998",
"customer" => "CU000999999998",
"customer_bank_account" => "BA000999999998"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}],
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
iex> Gocardless.Client.list_mandates(%{customer: "CU000999999999"})
{:ok,
%{"mandates" => [%{"created_at" => "2017-06-23T15:31:52.850Z",
"id" => "MD000999999999",
"links" => %{"creditor" => "CR000999999999",
"customer" => "CU000999999999",
"customer_bank_account" => "BA000999999999"}, "metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}],
"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50}}}
Callback implementation for Gocardless.Behaviour.Mandate.list_mandates/1
.
Lists all payments
Examples
iex> Gocardless.Client.list_payments
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
"payments" => [%{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
"status" => "pending_submission"}]}}
iex> Gocardless.Client.list_payments(%{"created_at[gt]" => "2017-06-22T17:18:06.000Z"})
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
"payments" => [%{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{}, "reference" => nil,
"status" => "pending_submission"}]}}
Callback implementation for Gocardless.Behaviour.Payment.list_payments/1
.
Lists all payouts
Examples
iex> Gocardless.Client.list_payouts
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
"payouts" => [%{"amount" => 9900, "arrival_date" => "2017-06-27",
"created_at" => "2017-06-27T09:51:33.167Z", "currency" => "GBP",
"deducted_fees" => 100, "id" => "PO000999999998",
"links" => %{"creditor" => "CR000999999998",
"creditor_bank_account" => "BA000999999998"},
"payout_type" => "merchant", "reference" => "REF-REF",
"status" => "paid"}]}}
Callback implementation for Gocardless.Behaviour.Payout.list_payouts/1
.
Lists Refunds from GoCardless
Examples
iex> Gocardless.Client.list_refunds
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
"refunds" => [%{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
"currency" => "GBP", "id" => "RF000999999998",
"links" => %{"payment" => "PM000999999998"}, "metadata" => %{},
"reference" => "partial refund"}]}}
Callback implementation for Gocardless.Behaviour.Refund.list_refunds/1
.
Lists Subscriptions from GoCardless
Examples
iex> Gocardless.Client.list_subscriptions
{:ok,
%{"meta" => %{"cursors" => %{"after" => nil, "before" => nil}, "limit" => 50},
"subscriptions" => [%{"amount" => 2500,
"created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
"day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
"interval" => 1, "interval_unit" => "monthly",
"links" => %{"mandate" => "MD000999999998"},
"metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
"name" => "Monthly Magazine", "payment_reference" => nil,
"start_date" => "2017-07-03", "status" => "active",
"upcoming_payments" => [%{"amount" => 2500,
"charge_date" => "2017-07-03"},
%{"amount" => 2500, "charge_date" => "2017-08-01"},
%{"amount" => 2500, "charge_date" => "2017-09-01"},
%{"amount" => 2500, "charge_date" => "2017-10-02"},
%{"amount" => 2500, "charge_date" => "2017-11-01"},
%{"amount" => 2500, "charge_date" => "2017-12-01"},
%{"amount" => 2500, "charge_date" => "2018-01-02"},
%{"amount" => 2500, "charge_date" => "2018-02-01"},
%{"amount" => 2500, "charge_date" => "2018-03-01"},
%{"amount" => 2500, "charge_date" => "2018-04-03"}]}]}}
Callback implementation for Gocardless.Behaviour.Subscription.list_subscriptions/1
.
Creates a new mandate preview
Examples
iex> params = %{
links: %{mandate: "MD123"}
}
iex> Gocardless.Client.pdf_preview(%{params: params})
{:ok, %{
"mandate_pdfs" => %{
"url" => "https://mandate-previews.gocardless.com/?token=lhulxcPEbT9v3W0QUpBOxhlGUSYEayQQ4VVrpO7YnUKRYynP5",
"expires_at" => "2014-05-08T17:01:06.000Z"
}}}
Callback implementation for Gocardless.Behaviour.Mandate.pdf_preview/1
.
Reinstates a mandate based on their ID in GoCardless
Examples
iex> Gocardless.Client.reinstate_mandate("MD000999999999")
{:ok,
%{"mandates" => %{"created_at" => "2017-06-23T15:31:52.850Z",
"id" => "MD000999999999",
"links" => %{"creditor" => "CR000999999999",
"customer" => "CU000999999999",
"customer_bank_account" => "BA000999999999"},
"metadata" => %{},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Mandate.reinstate_mandate/1
.
Retries a failed payment if the underlying mandate is active.
Examples
iex> Gocardless.Client.retry_payment("PM000099999999")
Callback implementation for Gocardless.Behaviour.Payment.retry_payment/2
.
Updates a Creditor based on their ID in GoCardless
Examples
iex> params = %{
creditors: %{
name: "Updated Creditor"
}
}
iex> Gocardless.Client.update_creditor("CR000099999999", params)
{:ok, %{"address_line1" => nil, "address_line2" => nil, "address_line3" => nil,
"city" => nil, "country_code" => nil,
"created_at" => "2017-06-27T08:52:52.655Z", "id" => "CR000099999999",
"links" => %{}, "logo_url" => nil, "name" => "Test Creditor",
"postal_code" => nil, "region" => nil,
"scheme_identifiers" => [%{"address_line1" => "338-346 Goswell Road",
"address_line2" => nil, "address_line3" => nil,
"can_specify_mandate_reference" => false, "city" => "London",
"country_code" => "GB", "currency" => "GBP",
"email" => "help@gocardless.com", "minimum_advance_notice" => 3,
"name" => "GoCardless", "phone_number" => "+40 20 1234 1234",
"postal_code" => "EC1V 7LQ", "reference" => "275069", "region" => nil,
"scheme" => "bacs"}], "verification_status" => "successful"}}
Callback implementation for Gocardless.Behaviour.Creditor.update_creditor/2
.
Updates a Customer based on their ID in GoCardless
Examples
iex> params = %{email: "new@email.com"}
iex> Gocardless.Client.update_customer("CU000999999998", %{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" => "new@email.com", "family_name" => "Lastname",
"given_name" => "Firstname", "id" => "CU000999999998", "language" => "en",
"metadata" => %{}, "postal_code" => nil, "region" => nil,
"swedish_identity_number" => nil}}}
Callback implementation for Gocardless.Behaviour.Customer.update_customer/2
.
Updates a Customer Bank Account metadata based on their ID in GoCardless. Only the metadata parameter is allowed.
Examples
iex> params = %{
customer_bank_accounts: %{
metadata: %{
db_id: "1234"
}
}
}
iex> Gocardless.Client.update_customer_bank_account("BA000999999998", params)
{:ok,
%{"customer_bank_accounts" => %{"account_holder_name" => "FirstName LastName",
"account_number_ending" => "11", "bank_name" => "BARCLAYS BANK PLC",
"country_code" => "GB", "created_at" => "2017-06-23T13:37:09.967Z",
"currency" => "GBP", "enabled" => true, "id" => "BA000999999998",
"links" => %{"customer" => "CU000999999998"},
"metadata" => %{"db_id" => "1234"}}}}
Callback implementation for Gocardless.Behaviour.CustomerBankAccount.update_customer_bank_account/2
.
Updates a mandate based on their ID in GoCardless
Examples
iex> params = %{
mandates: %{
metadata: %{
db_id: "1234"
}
}
}
iex> Gocardless.Client.update_mandate("MD000999999999", params)
{:ok,
%{"mandates" => %{"created_at" => "2017-06-23T15:31:52.850Z",
"id" => "MD000999999999",
"links" => %{"creditor" => "CR000999999999",
"customer" => "CU000999999999",
"customer_bank_account" => "BA000999999999"},
"metadata" => %{"db_id" => "1234"},
"next_possible_charge_date" => "2017-06-30",
"payments_require_approval" => false, "reference" => "REF-REF",
"scheme" => "bacs", "status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Mandate.update_mandate/2
.
Updates a Payment metadata based by ID. Only the metadata parameter is allowed.
Examples
iex> params = %{
payments: %{
metadata: %{
db_id: "1234"
}
}
}
iex> Gocardless.Client.update_payment("PM000099999999", mtd)
{:ok,
%{"payments" => %{"amount" => 100, "amount_refunded" => 0,
"charge_date" => "2017-06-30", "created_at" => "2017-06-23T15:27:18.656Z",
"currency" => "GBP", "description" => nil, "id" => "PM000099999999",
"links" => %{"creditor" => "CR000099999999",
"mandate" => "MD000099999999"}, "metadata" => %{"db_id" => "1234"},
"reference" => nil, "status" => "pending_submission"}}}
Callback implementation for Gocardless.Behaviour.Payment.update_payment/2
.
Updates a Refund metadata based on their ID in GoCardless. Only the metadata parameter is allowed.
Examples
iex> params = %{
refunds: %{
metadata: %{
db_id: "1234"
}
}
}
iex> Gocardless.Client.update_refund("RF000999999998", params)
{:ok,
%{"refunds" => %{"amount" => 100, "created_at" => "2017-06-27T10:00:26.248Z",
"currency" => "GBP", "id" => "RF000999999998",
"links" => %{"payment" => "PM000999999998"},
"metadata" => %{"db_id" => "1234"}, "reference" => "partial refund"}}}
Callback implementation for Gocardless.Behaviour.Refund.update_refund/2
.
Updates a Subscription in GoCardless.
Examples
iex> params = %{
subscriptions: %{
name: "Updated Name"
}
}
iex> Gocardless.Client.update_subscription("SB000999999998", params)
{:ok,
%{"subscriptions" => %{"amount" => 2500,
"created_at" => "2017-06-26T11:03:27.037Z", "currency" => "GBP",
"day_of_month" => 1, "end_date" => nil, "id" => "SB000999999998",
"interval" => 1, "interval_unit" => "monthly",
"links" => %{"mandate" => "MD000999999998"},
"metadata" => %{"order_no" => "ABCD1234"}, "month" => nil,
"name" => "Updated Name", "payment_reference" => nil,
"start_date" => "2017-07-03", "status" => "active",
"upcoming_payments" => [%{"amount" => 2500, "charge_date" => "2017-07-03"},
%{"amount" => 2500, "charge_date" => "2017-08-01"},
%{"amount" => 2500, "charge_date" => "2017-09-01"},
%{"amount" => 2500, "charge_date" => "2017-10-02"},
%{"amount" => 2500, "charge_date" => "2017-11-01"},
%{"amount" => 2500, "charge_date" => "2017-12-01"},
%{"amount" => 2500, "charge_date" => "2018-01-02"},
%{"amount" => 2500, "charge_date" => "2018-02-01"},
%{"amount" => 2500, "charge_date" => "2018-03-01"},
%{"amount" => 2500, "charge_date" => "2018-04-03"}]}}}
Callback implementation for Gocardless.Behaviour.Subscription.update_subscription/2
.