joshnuss / commerce_billing

A payment processing library for Elixir
MIT License
180 stars 24 forks source link
billing elixir gateway payment stripe

Commerce.Billing

![Build Status](https://secure.travis-ci.org/joshnuss/commerce_billing.svg?branch=master "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