Braintree.Customer (Braintree v0.12.0)
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
Link to this section Summary
Functions
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.
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.
To search for customers, pass a map of search parameters.
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.
Link to this section Types
Specs
t() :: %Braintree.Customer{
addresses: [map()],
android_pay_cards: [Braintree.AndroidPayCard.t()],
apple_pay_cards: [Braintree.ApplePayCard.t()],
coinbase_accounts: [map()],
company: String.t(),
created_at: String.t(),
credit_cards: [Braintree.CreditCard.t()],
custom_fields: map(),
email: String.t(),
fax: String.t(),
first_name: String.t(),
id: String.t(),
last_name: String.t(),
paypal_accounts: [Braintree.PaypalAccount.t()],
phone: String.t(),
updated_at: String.t(),
website: String.t()
}
Link to this section Functions
create(params \\ %{}, opts \\ [])
Specs
create(map(), Keyword.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, opts \\ [])
Specs
delete(binary(), Keyword.t()) :: :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, opts \\ [])
Specs
find(binary(), Keyword.t()) :: {: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")
new(params)
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.new(%{"company" => "Soren",
"email" => "parker@example.com"})
search(params, opts \\ [])
Specs
search(map(), Keyword.t()) :: {:ok, t()} | {:error, Braintree.ErrorResponse.t()}
To search for customers, pass a map of search parameters.
Example:
{:ok, customers} = Braintree.Customer.search(%{first_name: %{is: "Jenna"}})
update(id, params, opts \\ [])
Specs
update(binary(), map(), Keyword.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"