Braintree.Customer (Braintree v0.16.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
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.
Types
@type 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(), us_bank_accounts: [Braintree.UsBankAccount.t()], website: String.t() }
Functions
@spec create(map(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()
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
@spec delete(binary(), Keyword.t()) :: :ok | Braintree.HTTP.error()
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")
@spec find(binary(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()
If you want to look up a single customer using its ID, use the find method.
Example
customer = Braintree.Customer.find("customer_id")
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"})
@spec search(map(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()
To search for customers, pass a map of search parameters.
Example:
{:ok, customers} = Braintree.Customer.search(%{first_name: %{is: "Jenna"}})
@spec update(binary(), map(), Keyword.t()) :: {:ok, t()} | Braintree.HTTP.error()
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"