Braintree.HTTP (Braintree v0.15.0)

Base client for all server interaction, used by all endpoint specific modules.

This request wrapper coordinates the remote server, headers, authorization and SSL options.

Using Braintree.HTTP requires the presence of three config values:

  • merchant_id - Braintree merchant id
  • private_key - Braintree private key
  • public_key - Braintree public key

All three values must be set or a Braintree.ConfigError will be raised at runtime. All those config values support the {:system, "VAR_NAME"} as a value - in which case the value will be read from the system environment with System.get_env("VAR_NAME").

Summary

Functions

Centralized request handling function. All convenience structs use this function to interact with the Braintree servers. This function can be used directly to supplement missing functionality.

Types

error()

@type error() ::
  {:error, atom()} | {:error, Braintree.ErrorResponse.t()} | {:error, binary()}

response()

@type response() :: {:ok, map()} | error()

Functions

delete(path)

@spec delete(binary()) :: response()

delete(path, payload)

@spec delete(binary(), map() | list()) :: response()

delete(path, payload, opts)

@spec delete(binary(), map(), list()) :: response()

get(path)

@spec get(binary()) :: response()

get(path, payload)

@spec get(binary(), map() | list()) :: response()

get(path, payload, opts)

@spec get(binary(), map(), list()) :: response()

post(path)

@spec post(binary()) :: response()

post(path, payload)

@spec post(binary(), map() | list()) :: response()

post(path, payload, opts)

@spec post(binary(), map(), list()) :: response()

put(path)

@spec put(binary()) :: response()

put(path, payload)

@spec put(binary(), map() | list()) :: response()

put(path, payload, opts)

@spec put(binary(), map(), list()) :: response()

request(method, path, body \\ %{}, opts \\ [])

@spec request(atom(), binary(), binary() | map(), Keyword.t()) :: response()

Centralized request handling function. All convenience structs use this function to interact with the Braintree servers. This function can be used directly to supplement missing functionality.

Example

defmodule MyApp.Disbursement do
  alias Braintree.HTTP

  def disburse(params \ %{}) do
    HTTP.request(:get, "disbursements", params)
  end
end