Elixir Libraries

Accepting credit card payments with Elixir

The following example uses PINXS by Hotdoc:

order = Order.create(#...)

card = %Card{
  number: "5520000000000000",
  expiry_month: "12",
  expiry_year: "20",
  name: "Rubius Hagrid",
  address_line1: "The Game Keepers Cottage",
  address_city: "Hogwarts",
  address_country: "England",
  cvc: "321"

charge = %Charge{
  email: "hagrid@hogwarts.wiz",
  description: "Dragon eggs",
  ip_address: "",
  amount: 50000,
  card: card

with {:ok, created_order} <- Repo.insert(order),
     {:ok, created_charge} <- Charge.create(charge),
     {:ok, paid_order} <- Order.mark_paid(created_order, created_charge),
     {:ok, _email} <- Mailer.send("receipt", created_charge),
     {:ok, _email} <- Mailer.send("notify_fulfullment_team", order)
do   {:ok, created_order}

  {:error, %Changeset{} = changeset} ->
    # response appropriately to changeset error
  {:error, %PinError{error_code: "insufficient_funds"}} ->
    Mailer.send("order_failed", charge)
  {:error, other} ->
    # handle some other error
  error -> 
    Logger.error("Some unknown error: #{IO.inspect(error)}")

Elixir libraries compatible with Pin Payments:

Southern Payment Systems Pty Ltd
t/a Pin Payments
ABN: 46 154 451 582
Level 4, 356 Collins St,
Melbourne VIC 3000

A Checkout.com company

Privacy Policy Terms Security Status