Skip to content

Instantly share code, notes, and snippets.

@swelham
Created February 6, 2017 10:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save swelham/1b33d0e09d4082e68d25e468306c26e0 to your computer and use it in GitHub Desktop.
Save swelham/1b33d0e09d4082e68d25e468306c26e0 to your computer and use it in GitHub Desktop.
Cashier bad request example
defmodule CashierExample do
alias Cashier.Address
alias Cashier.PaymentCard
def purchase do
address = %Address{
line1: "123",
line2: "Main",
city: "New York",
state: "New York",
country_code: "US",
postal_code: "10004"
}
card = %PaymentCard{
holder: {"Stuart", "Welham"},
brand: "visa",
number: "4032030901103714",
expiry: {11, 2021},
cvv: ""
}
opts = [billing_address: address, currency: "GBP"]
case Cashier.purchase(19.45, card, opts) do
{:ok, result, _} -> IO.inspect result
{:error, :invalid, reason} -> IO.inspect reason
{:error, reason} -> IO.inspect reason
end
end
end
CashierExample.purchase
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment