Home

Awesome

Commerce.Billing

Build Status

Payment processing library for Elixir. Based on Shopify's ActiveMerchant ruby gem

Supported Gateways

Advantages of Elixir

Card processing example

alias Commerce.Billing
alias Billing.{CreditCard, Address, Worker, Gateways}

config = %{credentials: {"sk_test_BQokikJOvBiI2HlWgH4olfQ2", ""},
           default_currency: "USD"}

Worker.start_link(Gateways.Stripe, config, name: :my_gateway)

card = %CreditCard{
  name: "John Smith",
  number: "4242424242424242",
  expiration: {2017, 12},
  cvc: "123"
}

address = %Address{
  street1: "123 Main",
  city: "New York",
  region: "NY",
  country: "US",
  postal_code: "11111"
}

case Billing.authorize(:my_gateway, 199.95, card, billing_address: address,
                                                   description: "Amazing T-Shirt") do
  {:ok,    %{authorization: authorization}} ->
    IO.puts("Payment authorized #{authorization}")

  {:error, %{code: :declined, reason: reason}} ->
    IO.puts("Payment declined #{reason}")

  {:error, %{code: error}} ->
    IO.puts("Payment error #{error}")
end

Road Map

License

MIT

@joshnuss is a freelance software consultant. joshnuss@gmail.com