gringotts v0.0.2 Gringotts.Gateways.AuthorizeNet

A module for working with the Authorize.net payment gateway.

The module provides a set of functions to perform transactions via this gateway for a merchant. To use this module you need to create an account with the Authorize.net gateway which will provide you with a name and a transactionKey. You will need to configure these keys to use the module functions.

AuthorizeNet API reference

The following set of functions have been provided for a transaction:

ActionDescription
AuthorizeTo authorize the bank to charge the account and use it for payment.
CaptureTo capture the given amount from an account for which, the
transaction has already been authorized.
PurchaseTo charge the account of a customer and transfer the funds to merchants
account.
RefundTo refund a settled transaction from the merchant to the customer account.
voidTo void a transaction before the transaction is settled at merchant’s side.
storeTo store customer payment profile data.
unstoreTo remove the customer payment profile data.

Link to this section Summary

Functions

Authorize a credit card transaction

Capture a transaction

Charge a credit card

Refund amount for a settled transaction referenced by id

Store a customer payment profile

Remove a customer profile from the payment gateway

Validates the config dynamically depending on what is the value of required_config

To void a transaction

Link to this section Functions

Link to this function authorize(amount, payment, opts)
authorize(Float, Gringotts.CreditCard, Keyword) :: Tuple

Authorize a credit card transaction.

Function to authorize a transaction for the specified amount. It needs to be followed up with a capture transaction to transfer the funds to merchant account.

Required fields :

opts = [config: %{name:"", transactionKey: ""}] taken from the configuration in your 

application

Optional Fields

opts = [order: %{invoiceNumber: ,description: },
  refId: ,
  lineitems: %{itemId: , name: , description: , quantity: , unitPrice: },
  tax: %{amount: , name: ,description: },
  duty: %{amount: , name: ,description: },
  shipping: %{amount: , name: ,description: },
  poNumber: ,
  customer: %{id: },
  billTo: %{firstName: ,lastName: ,company: ,address: ,city: ,state: ,zip: ,country: },
  shipTo: %{firstName: ,lastName: ,company: ,address: ,city: ,state: ,zip: ,country: },
  customerIP: ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"}, 
  refId: "123456", 
  order: %{invoiceNumber: "INV-12345", description: "Product Description"}, 
  lineItem: %{itemId: "1", name: "vase", description: "Cannes logo", quantity: "18", unitPrice: "45.00" }
]
card = %CreditCard{number: "5424000000000015", year: 2020, month: 12, verification_code: "999"} 
amount = 5
Link to this function capture(id, amount, opts)
capture(String.t(), Float, Keyword) :: Tuple

Capture a transaction.

Function to capture an amount for an authorized transaction.

Required fields :

opts = [config: %{name:" ", transactionKey: " "}, ] taken from the configuration in your

application

Optional Fields

opts = [order: %{invoiceNumber: ,description: },
  refId: ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"}, 
  refId: "123456",
  order: %{invoiceNumber: "INV-12345", description: "Product Description"}
]
id = "transId of the authorize response"
amount = 5
Link to this function purchase(amount, payment, opts)
purchase(Float, Gringotts.CreditCard, Keyword) :: Tuple

Charge a credit card.

Function to charge a user credit card for the specified amount. It performs authorize and capture at the same time.

Required fields :

opts = [config: %{name:"", transactionKey: ""}]` taken from the configuration in your 

application

Optional Fields

opts = [order: %{invoiceNumber: ,description: },
  refId: ,
  lineitems: %{itemId: , name: , description: , quantity: , unitPrice: },
  tax: %{amount: , name: ,description: },
  duty: %{amount: , name: ,description: },
  shipping: %{amount: , name: ,description: },
  poNumber: ,
  customer: %{id: },
  billTo: %{firstName: ,lastName: ,company: ,address: ,city: ,state: ,zip: ,country: },
  shipTo: %{firstName: ,lastName: ,company: ,address: ,city: ,state: ,zip: ,country: },
  customerIP: ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"}, 
  refId: "123456", 
  order: %{invoiceNumber: "INV-12345", description: "Product Description"}, 
  lineItem: %{itemId: "1", name: "vase", description: "Cannes logo", quantity: "18", unitPrice: "45.00" }
]
card = %CreditCard{number: "5424000000000015", year: 2020, month: 12, verification_code: "999"} 
amount = 5
Link to this function refund(amount, id, opts)
refund(Float, String.t(), Keyword) :: Tuple

Refund amount for a settled transaction referenced by id.

Use this method to refund a customer for a transaction that was already settled, requires transId of the transaction.

Required fields

opts = [config: %{name:" ", transactionKey: " "}, payment: %{card: %{number: ,year: , month:}}]

Optional fields

opts = [refId: ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"},
  payment: %{card: %{number: "5424000000000015", year: 2020, month: 12}}
  refId: "123456",
]
id = "trans id of the transaction to be refunded"
amount = 5
Link to this function store(card, opts)
store(Gringotts.CreditCard, Keyword) :: Tuple

Store a customer payment profile.

Use this function to store the customer card information by creating a customer profile, and in case the customer_profile_exists with gateway then by creating customer payment profile.

Required Fields

opts = [config: %{name:" ", transactionKey: " "},
  profile: %{merchantCustomerId: ,description: ,email: }
]

Optional Fields

opts = [
  validationMode: , # testMode, liveMode
  billTo: %{firstName: ,lastName: ,company: ,address: ,city: ,state: ,zip: ,country: },
  customerType: ,
  customerProfileId: 
  ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"},
  profile: %{merchantCustomerId: 123456 ,description: "test store",email: "test@gmail.com"},
  validationMode: 'testMode'
]
card = %CreditCard{number: "5424000000000015", year: 2020, month: 12, verification_code: "999"}
Link to this function unstore(customer_profile_id, opts)
unstore(String.t(), Keyword) :: Tuple

Remove a customer profile from the payment gateway.

Use this function to unstore the customer card information by deleting the customer profile present. Requires the customer profile id.

Required Fields

opts = [config: %{name:" ", transactionKey: " "},
customerProfileId:
]
Link to this function validate_config(config)

Validates the config dynamically depending on what is the value of required_config

Link to this function void(id, opts)
void(String.t(), Keyword) :: Tuple

To void a transaction

Use this method to cancel either an original transaction that is not settled or an entire order composed of more than one transaction. It can be submitted against any other transaction type. Requires the transId of a transaction passed as id.

Required Fields

opts = [config: %{name:" ", transactionKey: " "}]

Optional fields

opts = [refId: ]

Example

opts = [config: %{name: "your_name", transactionKey: "your_key"},
  refId: "123456",
]
id = "trans id of the transaction to be void"