Braintree v0.7.0 Braintree.Customer

You can create a customer by itself, with a payment method, or with a credit card with a billing address.

For additional reference see: https://developers.braintreepayments.com/reference/request/customer/create/ruby

Summary

Functions

Convert a map into a Company struct along with nested payment options. Credit cards and paypal accounts are converted to a list of structs as well

Create a customer record, or return an error response with after failed validation

You can delete a customer using its ID. When a customer is deleted, all associated payment methods are also deleted, and all associated recurring billing subscriptions are canceled

If you want to look up a single customer using its ID, use the find method

To update a customer, use its ID along with new attributes. The same validations apply as when creating a customer. Any attribute not passed will remain unchanged

Types

t :: %Braintree.Customer{addresses: [], coinbase_accounts: [], company: String.t, created_at: String.t, credit_cards: [], custom_fields: %{}, email: String.t, fax: String.t, first_name: String.t, id: String.t, last_name: String.t, paypal_accounts: [], phone: String.t, updated_at: String.t, website: String.t}

Functions

construct(params)

Specs

construct(Map.t | [Map.t]) :: t | [t]

Convert a map into a Company struct along with nested payment options. Credit cards and paypal accounts are converted to a list of structs as well.

Example

customer = Braintree.Customer.construct(%{"company" => "Soren",
                                          "email" => "parker@example.com"})
create(params \\ %{})

Specs

create(Map.t) ::
  {:ok, t} |
  {:error, Braintree.ErrorResponse.t}

Create a customer record, or return an error response with after failed validation.

Example

{:ok, customer} = Braintree.Customer.create(%{
  first_name: "Jen",
  last_name: "Smith",
  company: "Braintree",
  email: "jen@example.com",
  phone: "312.555.1234",
  fax: "614.555.5678",
  website: "www.example.com"
})

customer.company # Braintree
delete(id)

Specs

delete(binary) ::
  :ok |
  {:error, Braintree.ErrorResponse.t}

You can delete a customer using its ID. When a customer is deleted, all associated payment methods are also deleted, and all associated recurring billing subscriptions are canceled.

Example

:ok = Braintree.Customer.delete("customer_id")
find(id)

Specs

find(binary) ::
  {:ok, t} |
  {:error, Braintree.ErrorResponse.t}

If you want to look up a single customer using its ID, use the find method.

Example

customer = Braintree.Customer.find("customer_id")
update(id, params)

Specs

update(binary, Map.t) ::
  {:ok, t} |
  {:error, Braintree.ErrorResponse.t}

To update a customer, use its ID along with new attributes. The same validations apply as when creating a customer. Any attribute not passed will remain unchanged.

Example

{:ok, customer} = Braintree.Customer.update("customer_id", %{
  company: "New Company Name"
})

customer.company # "New Company Name"