Braintree.Address (Braintree v0.13.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

@type 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 \\ [])

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

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

example

Example

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

first_name: "Jenna"

})

address.company # Braintree

Link to this function

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

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

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

example

Example

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

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

@spec 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

Example

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

Convert a map into a Address struct.

example

Example

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

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

@spec 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

Example

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

address.company # "New Company Name"