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 Name | Value | Description ———— | ——————- | ———————————————————- TERMID | EXAMPLE1 | your terminal id TYPE | G | the type of transaction TOKEN_ACTION | ADD | action: ADD UPDATE DEACTIVATE REACTIVATE TOKEN | ? | You can pick a token or part of a token. ? is the rest. CARD | 5191111111111111 | The card number to be tokenized EXP | 1214 | The expiry date CVV2 | 123 | The CVV AVS | 90210 | Address and/or zipcode for verification TOKEN_REF | xxx-xxx-xxxxxxx | your reference for the card. use it for searching EXT_RESP | Y | ??????

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 Name | Value | Description ———— | ——————- | ———————————————————- TERMID | EXAMPLE1 | your terminal id TYPE | S | the type of transaction TOKEN | 45125206MCRD5111 | the card token AMT | 14259 | the amount in cents as an integer REF | TOKENTRANSEXAMPLE | your 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.