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:
| Action | Method |
|---|---|
| Authorize | authorize/3 |
| Capture | capture/3 |
| Purchase | purchase/3 |
| Refund | refund/3 |
| Cancel | void/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:
| Key | Remark | Status |
|---|---|---|
billing_address | Not implemented | |
address | Not implemented | |
currency | Implemented | |
order_id | Not implemented | |
description | Not implemented |
All these keys are being implemented, track progress in issue #42!
Configuration parameters for Cams:
| Config parameter | Cams secret |
|---|---|
:username | Username |
:password | Password |
Your Application config must include the
:username,:passwordfields 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
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.
Run an
iexsession withiex -S mixand 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
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)
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)
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)
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)
Validates the config dynamically depending on what is the value of required_config
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)