Bluepay

CircleCIcodecov

Installation

If available in Hex, the package can be installed as:

  1. Add bluepay to your list of dependencies in mix.exs:
def deps do
[{:bluepay, "~> 0.4.0"}]
end
  1. Ensure bluepay is started before your application:
def application do
[applications: [:bluepay]]
end

Usage

Tokenize a Card

card = %Bluepay.Card{
name: "Bob Roberts",
number: "5191111111111111",
expiry_month: "12"
expiry_year: "17"
cvd: "400",
postal_code: "12345"
}
results = Bluepay.Token.create(terminal_id, card)
# {:ok, "fake-token-lol", "TOKEN ADDED"}

Pay with a Token

amount = 5000 #$50.00
token = "MY-TOKEN"
results = Bluepay.Token.purchase(terminal_id, token, amount)
# {:ok, "T00000 $50.00"}

The Bluepay Gateway

Requests to the Bluepay Gateway are all GET requests. Paremeters are URL encoded in both the request and also in the response body.

Add Token

Field NameValueDescription
TERMIDEXAMPLE1your terminal id
TYPEGthe type of transaction
TOKEN_ACTIONADDaction: ADD UPDATE DEACTIVATE REACTIVATE
TOKEN?You can pick a token or part of a token. ? is the rest.
CARD5191111111111111The card number to be tokenized
EXP1214The expiry date
CVV2123The CVV
AVS90210Address and/or zipcode for verification
TOKEN_REFxxx-xxx-xxxxxxxyour reference for the card. use it for searching
EXT_RESPY??????

Request:

https://lt3a.caledoncard.com/TERMID=EXAMPLE1&TYPE=G&TOKEN_ACTION=ADD&TOKEN=45125206MCRD0003&CARD=5550000000000003&EXP=1214&CVV2=400&AVS=12345&TOKEN_REF=JSMITH-MCRD&EXT_RESP=Y

Response:

TEXT=TOKEN ADDED &AVS=Y&CODE=0000&CTYPE=MCRD&CPROD=MC&CCO=124&CVV2=M

Pay with Token

Field NameValueDescription
TERMIDEXAMPLE1your terminal id
TYPESthe type of transaction
TOKEN45125206MCRD5111the card token
AMT14259the amount in cents as an integer
REFTOKENTRANSEXAMPLEyour reference

Request:

https://lt3a.caledoncard.com/TERMID=EXAMPLE1&TYPE=S&TOKEN=45125206MCRD5111&AMT=14259&REF=TOKENTRANSEXAMPLE

Response:

TEXT=T35698 $142.59&AUTH=T35698CODE=0000

Sample Transaction

The sample below shows a transaction request and response for a real-time credit card Sale transaction.

Transaction Request:

https://lt3a.caledoncard.com/TERMID=TESTMERC&CARD=5123456789012345&EXP=0407&AMT=4350&REF=43&TYPE=S

Transaction Response:

HTTP/1.0 200 OK Content-type: text/plain Content-length: 47 TEXT=045560 $43.50&AUTH=045560&CODE=0000

Gotchas

Ampersand & is encoded as && instead of %26 from the gateway.