spreedly v2.0.0 Spreedly
An Elixir client implementation of the Spreedly API.
For more info visit the Spreedly API docs for a detailed listing of available API methods.
Usage
API interactions happen with a Spreedly.Environment
.
iex> env = Spreedly.Environment.new(environment_key, access_secret)
Once you have an environment, you can use it to interact with the API.
Run a purchase using a credit card
You can pattern match on the response.
iex> case Spreedly.purchase(env, "R8AKGmYwkZrrj2BpWcPge", "RjTFFZQp4MrH2HJNfPwK", 2344) do
{:ok, %{succeeded: true}} ->
IO.puts "Success!"
{:ok, %{succeeded: false, message: msg}} ->
IO.puts "Declined!"
{:error, reason} ->
IO.inspect reason
end
Show a Transaction
iex> Spreedly.show_transaction(env, "7f6837d1d22e049f8a47a8cc1fa9")
{:ok,
%{created_at: "2016-01-10T16:36:14Z", currency_code: nil, description: nil,
...
state: "gateway_processing_failed", succeeded: false,
token: "7f6837d1d22e049f8a47a8cc1fa9", transaction_type: "Verification",
updated_at: "2016-01-10T16:36:14Z"}}
iex> Spreedly.find_transaction(env, "NonExistentToken")
{:error, "Unable to find the transaction NonExistentToken."}
Summary
Functions
Authorize a payment method to be charged a specific amount for the provided gateway token with optional request body data specified as a keyword list
List transactions for the provided gateway token with optional query params specified as a keyword list
List transactions for the provided payment method token with optional query params specified as a keyword list
Make a purchase for the provided gateway token and payment method token with optional request body data specified as a keyword list
Determine if a credit card is a chargeable card and available for purchases, with optional request body data specified as a keyword list
Functions
add_credit_card(Spreedly.Environment.t, Keyword.t) :: {:ok, any} | {:error, any}
add_gateway(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
add_receiver(Spreedly.Environment.t, String.t, Keyword.t) :: {:ok, any} | {:error, any}
authorization(Spreedly.Environment.t, String.t, String.t, pos_integer, String.t, Keyword.t) :: {:ok, any} | {:error, any}
Authorize a payment method to be charged a specific amount for the provided gateway token with optional request body data specified as a keyword list.
Amount should be provided as a positive integer in cents.
Examples
authorization(env, "gateway_token", "payment_method_token", 100)
authorization(env, "gateway_token", "payment_method_token", 100, "USD", [order_id: "44", description: "My auth"])
capture(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
credit(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
list_gateway_transactions(Spreedly.Environment.t, String.t, Keyword.t) :: {:ok, any} | {:error, any}
List transactions for the provided gateway token with optional query params specified as a keyword list.
Examples
list_gateway_transactions(env, "token")
list_gateway_transactions(env, "token", order: :desc, since_token: "token"])
list_payment_method_transactions(Spreedly.Environment.t, String.t, Keyword.t) :: {:ok, any} | {:error, any}
List transactions for the provided payment method token with optional query params specified as a keyword list.
Examples
list_payment_method_transactions(env, "token")
list_payment_method_transactions(env, "token", [order: :desc, since_token: "token"])
purchase(Spreedly.Environment.t, String.t, String.t, pos_integer, String.t, Keyword.t) :: {:ok, any} | {:error, any}
Make a purchase for the provided gateway token and payment method token with optional request body data specified as a keyword list.
Amount should be provided as a positive integer in cents.
Examples
purchase(env, "gateway_token", "payment_method_token", 100)
purchase(env, "gateway_token", "payment_method_token", 100, "USD", [order_id: "44", description: "My purchase"])
redact_payment_method(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
retain_payment_method(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
show_gateway(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
show_payment_method(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
show_receiver(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
show_transaction(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
show_transcript(Spreedly.Environment.t, String.t) :: {:ok, any} | {:error, any}
store_payment_method(Spreedly.Environment.t, String.t, String.t) :: {:ok, any} | {:error, any}
verify(Spreedly.Environment.t, String.t, String.t, String.t | nil, Keyword.t) :: {:ok, any} | {:error, any}
Determine if a credit card is a chargeable card and available for purchases, with optional request body data specified as a keyword list.
Examples
verify(env, "gateway_token", "payment_method_token")
verify(env, "gateway_token", "payment_method_token", "USD", [retain_on_success: true])