Braintree.Address (Braintree v0.12.0)

You can create an address for a customer only although the structure is also used for a merchant account.

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

Link to this section Summary

Functions

Create an address record, or return an error response after failed validation.

You can delete an address using its customer ID and address ID.

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

Convert a map into a Address struct.

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

Link to this section Types

Specs

t() :: %Braintree.Address{
  company: String.t(),
  country_code_alpha2: String.t(),
  country_code_alpha3: String.t(),
  country_code_numeric: String.t(),
  country_name: String.t(),
  created_at: String.t(),
  customer_id: String.t(),
  extended_address: String.t(),
  first_name: String.t(),
  id: String.t(),
  last_name: String.t(),
  locality: String.t(),
  postal_code: String.t(),
  region: String.t(),
  street_address: String.t(),
  updated_at: String.t()
}

Link to this section Functions

Link to this function

create(customer_id, params \\ %{}, opts \\ [])

Specs

create(binary(), map(), Keyword.t()) ::
  {:ok, t()} | {:error, Braintree.ErrorResponse.t()}

Create an address record, or return an error response after failed validation.

Example

= Braintree.Address.create("customer_id", %{

first_name: "Jenna"

})

address.company # Braintree

Link to this function

delete(customer_id, id, opts \\ [])

Specs

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

You can delete an address using its customer ID and address ID.

Example

:ok = Braintree.Address.delete("customer_id", "address_id")
Link to this function

find(customer_id, id, opts \\ [])

Specs

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

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

Example

address = Braintree.Address.find("customer_id", "address_id")

Convert a map into a Address struct.

Example

address = Braintree.Address.new(%{"company" => "Braintree"})
Link to this function

update(customer_id, id, params, opts \\ [])

Specs

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

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

Example

{:ok, address} = Braintree.Address.update("customer_id", "address_id", %{
  company: "New Company Name"
})

address.company # "New Company Name"