Created
February 6, 2017 10:17
-
-
Save swelham/1b33d0e09d4082e68d25e468306c26e0 to your computer and use it in GitHub Desktop.
Cashier bad request example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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