gringotts v1.0.2 Gringotts.Gateways.Cams

A module for working with the Cams payment gateway.

You can test gateway operations in CAMS API TEST MODE. Test it using these crediantials username: testintegrationc, password: password9, as well as you can find api docs in this test account under integration link.

The following features of CAMS are implemented:

ActionMethod
Authorizeauthorize/3
Capturecapture/3
Purchasepurchase/3
Refundrefund/3
Cancelvoid/2

The opts argument

Most Gringotts API calls accept an optional Keyword list opts to supply optional arguments for transactions with the Cams gateway. The following keys are supported:

KeyRemarkStatus
billing_addressNot implemented
addressNot implemented
currencyImplemented
order_idNot implemented
descriptionNot implemented

All these keys are being implemented, track progress in issue #42!

Configuration parameters for Cams:

Config parameterCams secret
:usernameUsername
:passwordPassword

Your Application config must include the :username, :password fields and would look something like this:

config :gringotts, Gringotts.Gateways.Cams,
adapter: Gringotts.Gateways.Cams,
username: "your_secret_user_name",
password: "your_secret_password",

Scope of this module, and quirks

  • Cams process money in cents.
  • Although Cams supports payments from electronic check & various cards this library only accepts payments by cards like visa, master, american_express and discover.

Following the examples

  1. First, set up a sample application and configure it to work with Cams.

    • You could do that from scratch by following our Getting Started guide.
    • To save you time, we recommend cloning our example repo that gives you a pre-configured sample app ready-to-go.

      • You could use the same config or update it the with your “secrets” that you get after registering with Cams.
  2. Run an iex session with iex -S mix and add some variable bindings and aliases to it (to save some time):

iex> alias Gringotts.{Response, CreditCard, Gateways.Cams}
iex> opts = [currency: "USD"] # The default currency is USD, and this is just for an example.
iex> payment = %CreditCard{number: "4111111111111111", month: 11, year: 2018,
                          first_name: "Longbob", last_name: "Longsen",
                          verification_code: "123", brand: "visa"}

We’ll be using these in the examples below.

TODO

  • Credit Card Operations

    • Credit
  • Electronic Check

    • Sale
    • Void
    • Refund

Link to this section Summary

Functions

Authorize a credit card transaction

Captures a pre-authorized amount

Transfers amount from the customer to the merchant

Refunds the amount to the customer’s account with reference to a prior transfer

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

Voids the referenced payment

Link to this section Functions

Link to this function authorize(money, payment, options)
authorize(number(), Gringotts.CreditCard.t(), Keyword) :: Gringotts.Response

Authorize a credit card transaction.

The authorization validates the card details with the banking network, places a hold on the transaction amount in the customer’s issuing bank and also triggers risk management. Funds are not transferred.It needs to be followed up with a capture transaction to transfer the funds to merchant account.After successful capture, transaction will be sent for settlement.

Cams returns an authorization which can be used later to:

Examples

payment = %{
  number: "4111111111111111", month: 11, year: 2018,
  first_name: "Longbob", last_name: "Longsen",
  verification_code: "123", brand: "visa"
}

options = [currency: "USD"]
money   = 100

iex> Gringotts.authorize(Gringotts.Gateways.Cams, money, payment, options)
Link to this function capture(money, authorization, options)
capture(number(), String.t(), Keyword) :: Gringotts.Response

Captures a pre-authorized amount.

It captures existing authorizations for settlement.Only authorizations can be captured. Captures can be submitted for an amount equal to or less than the original authorization. It allows partial captures like many other gateways and release the remaining amount back to the payment source [citation-needed].Multiple captures can not be done using same authorization.

Examples

authorization = "3904093075"
options = [currency: "USD"]
money   = 100

iex> Gringotts.capture(Gringotts.Gateways.Cams, money, authorization, options)
Link to this function purchase(money, payment, options)
purchase(number(), Gringotts.CreditCard.t(), Keyword) :: Gringotts.Response

Transfers amount from the customer to the merchant.

Function to charge a user credit card for the specified amount. It performs authorize and capture at the same time.Purchase transaction are submitted and immediately sent for settlement.

After successful purchase it returns an authorization which can be used later to:

Examples

payment = %CreditCard{
  number: "4111111111111111", month: 11, year: 2018,
  first_name: "Longbob", last_name: "Longsen",
  verification_code: "123", brand: "visa"
}

options = [currency: "USD"]
money   = 100

iex> Gringotts.purchase(Gringotts.Gateways.Cams, money, payment, options)
Link to this function refund(money, authorization, options)
refund(number(), String.t(), Keyword) :: Gringotts.Response

Refunds the amount to the customer’s account with reference to a prior transfer.

It will reverse a previously settled or pending settlement transaction. If the transaction has not been settled, a transaction void/2 can also reverse it. It processes a full or partial refund worth amount, referencing a previous purchase/3 or capture/3. Authorized transaction can not be reversed.

authorization can be used to perform multiple refund, till:

  • all the pre-authorized amount is captured or,
  • the remaining amount is explicitly “reversed” via void/2. [citation-needed]

Examples

authorization = "3904093078"
options = [currency: "USD"]
money   = 100

iex> Gringotts.refund(Gringotts.Gateways.Cams, money, authorization, options)
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(authorization, options)
void(String.t(), Keyword) :: Gringotts.Response

Voids the referenced payment.

Transaction voids will cancel an existing sale or captured authorization. In addition, non-captured authorizations can be voided to prevent any future capture. Voids can only occur if the transaction has not been settled.

Examples

authorization = "3904093075"
options = []

iex> Gringotts.void(Gringotts.Gateways.Cams, authorization, options)