Skip to content

Instantly share code, notes, and snippets.

@oyeb
Last active February 1, 2018 12:17
Show Gist options
  • Save oyeb/b1030058bda1fa9a3d81f1cf30723695 to your computer and use it in GitHub Desktop.
Save oyeb/b1030058bda1fa9a3d81f1cf30723695 to your computer and use it in GitHub Desktop.
Some frequently used bindings for AuthorizeNet
# Handy bindings when developing the AuthorizeNet gateway integration.
# Most of the bindings are for the `opts`
# Instructions
# Just rename this file to `.iex.exs` and save it in either,
# 1. the gringotts root directory
# 2. your applications root directory
# essentially the place where you launch your `iex` sessions via `iex -S mix`.
alias Gringotts.{CreditCard, Response, Address}
alias Gringotts.Gateways.AuthorizeNet
amount = Money.new("2.99", :EUR)
card = %CreditCard {
number: "5424000000000015",
month: 12,
year: 2099,
verification_code: 999
}
auth = %{name: "64jKa6NA", transaction_key: "4vmE338dQmAN6m7B"}
lineitems = %{
item_id: "1",
name: "vase",
description: "Cannes logo",
quantity: 18,
unit_price: Money.mult!(amount, 18)
}
tax = %{name: "foo", amount: Money.new("0.1", :EUR), description: "bar"}
shipping = %{name: "titanic", amount: Money.new("0.56", :EUR), description: "fake"}
duty = %{name: "noduty", amount: Money.new("0", :EUR), description: "haha"}
opts = [
config: auth,
ref_id: "123456",
order: %{invoice_number: "INV-12345", description: "Product Description"},
lineitems: lineitems,
tax: tax,
shipping: shipping,
duty: duty
]
# AuthorizeNet.authorize amount, card, opts_all
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment