Java Script API

API Document version 0.1

Easy Payment Gateway Java Script Flow Diagram

EPGJS Flow

 

Flow explanation.

  1. Authorization Token call
    • The merchant performs a call to the authorisation service located in Easy Payment Gateway Merchant REST service.
    • An authorisation token is provided by the Easy Payment Gateway Merchant REST service.
  2. Render Checkout page
    • Checkout page example.
    • Add Div container on the Merchant page.
  3. Card registering call
    • The merchant performs a call to the Easy Payment Gateway Web REST service.
    • A card registry response is provided by Easy Payment Gateway Web REST service, this response contains information about the card internal token and about the account unique identifier.
  4. Perform payment

API Details.


1. Authorisation Token call API.

Authorisation request

The authorisation request provides the required details to initiate a session within the Easy Payment Gateway Core system, like the merchant id or the customer details.

This can be tested from here: http://docsapi-stg.easypaymentgateway.com/

The authorisation request requires to be formed in valid JSON format.

  • End point:
    • Staging: https://epgjs-mep-stg.easypaymentgateway.com/auth/
    • Live: https://epgjs-mep.easypaymentgateway.com/auth/
  • Method: POST
  • Headers:
    • Accept: application/json
    • Content-Type: application/json
  • Request body:

Parameter

Type

Mandatory

Description

Example value

merchantId

Long

Y

Easy Payment Gateway Merchant identifier

9999

customerId

String

Y

Merchant customer id

MyCustomer123

merchantKey

String (UUID)

Y

Merchant key provided by Easy Payment Gateway

d512318e-df5e-427d-95e0- f15b38039988

productId

Long

Y

Easy Payment Gateway Product identifier

99991

country

String

Y

Customer Country ISO code

GB

currency

String

Y

Customer Currency ISO code

GBP

operations

Array of operations

Y

Transaction Auth operation

[“deposit”] or [“credit”]

  • Payload example: {“merchantId”:”9999″,”customerId”:”MyCustomer123″, “merchantKey”:”d512318e-df5e-427d-95e0-f15b38039988″, “productId”:”99991″,”country”:”GB”,“currency”:”GBP”, “operations”:”[“deposit”]”}

Authorisation response

The authorisation response contains the Auth token that will be required in the subsequent calls to the Easy Payment Gateway system during the card registering process.

  • Response headers: 
    • Content-Type: application/json;charset=UTF-8

Parameter

Type

Description

Example value

authToken

String (UUID)

Auth token required in subsequent calls

b1db9d6e- c001-4203-962a-6887e421b58f

  • Raw response example: {“authToken”:”b1db9d6e-c001-4203-962a-6887e421b58f”}

 


2. Render Checkout page

Checkout page example

HTML

<!DOCTYPE html>

<html lang=“en” xmlns=“http://www.w3.org/1999/xhtml” xmlns:th=“http://www.thymeleaf.org”>

<head>

<meta charset=“UTF-8”></meta>

<meta name=“viewport” content=“width=device-width, initial-scale=1”></meta>

<title>Merchant Example Site</title>

<link rel=“stylesheet” href=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css”/>

<!– import Easy Payment Gateway Bootstrap CSS –>

<link rel=“stylesheet” type=“text/css” href=“https://epgjs-rendercashier-stg.easypaymentgateway.com/css/default-bootstrap.css”/>

<script src=“https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js”></script>

<script src=“http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js”></script>

<!– import EPGJS javascript –>

<script src=“https://epgjs-rendercashier-stg.easypaymentgateway.com/js/epgjs.js”></script>

<script type=“text/javascript”>

function pay() {

    // Injecting AuthToken

    var authToken = ${authToken};   

    // Setting Easy Payment Gateway endpoint and merchant callbacks

    EPGJS_COMM.setEpgBaseUrl(https://epgjs-web-stg.easypaymentgateway.com);

    EPGJS_COMM.setMerchantRegisterAccountCallback(registerAccountCallback);

    EPGJS_COMM.setMerchantPrePayCallback(prePayCallback);

    // Configure Cashier CSS theme

    EPGJS_STYLE.setCssTheme(EPGJS_STYLE.DEFAULT_BOOTSTRAP_THEME);

    // Call to render Cashier

    EPGJS.renderCashier(authToken, epgjs-cashier-div);

}

function registerAccountCallback(registerData) {

// Account registration callback

}

function prePayCallback(prepayData) {

        var f = document.createElement(“form”);

        f.setAttribute(‘method’, “post”);

        // Pay form submission. The merchant get the form submission, getting the customer details and processing a Direct Easy Payment Gateway payment.

        f.setAttribute(‘action’, “https://merchant.domain/charge”);

        var i = document.createElement(“input”);

        i.setAttribute(‘type’, ‘hidden’);

        i.setAttribute(‘name’,“prepayToken”);

        i.value = JSON.stringify(prepayData);

        f.appendChild(i);

        f.submit();

}

</script>

</head>

<body>

<button onclick=“javascript:pay()”>PAY</button>

<div id=“epgjs-cashier-div”></div>

</body>

</html>

View

Checkout page - Example

 


3. Account Registration call API

Register account request

The register account request provides the required details register an account in the Easy Payment Gateway system. The register account request requires to be formed in valid JSON format.

This call is Idempotent, so if an account that is already registered in the system is required to be registered again, the original account identifier will be provided back and the account won’t be registered twice.

This applies for Merchant + Customer, so if a credit card for example is registered for two different customer, two account tokens will be provided and they will be different.

  • End point:
    • Staging: https://epgjs-web-stg.easypaymentgateway.com/account/creditcard
    • Live: https://epgjs-web.easypaymentgateway.com/account/creditcard
  • Method: POST
  • Headers: 
    • Accept: application/json
    • Content-Type: application/json
    • authToken: b1db9d6e-c001-4203-962a-6887e421b58f

It is very important to note that the response token from the authorisation call must be provided as a header in the account registration call.

  • Card register params:

Parameter

Type

Mandatory

Description

Example value

cardNumber

String

Y

Card number

4900123412341234

expDate

String

Y

Expiration date, MMYY format

1220

cardHolderName

String

Y

Card holder name

John Smith

  • Payload example: {“cardNumber”:”4900123412341234″, “expDate”:”1220″, “cardHolderName”:”John Smith”}

Register account response

The card registration process returns an account registration object that contains an account identifier (UUID) and the account number, this is in the case of credit/debit card the tokenisation process result for the card number

  • Response headers: Content-Type: application/json;charset=UTF-8

Parameter

Type

Description

Example value

accountId

String (UUID)

Internal account identifier

2087bfb1-ecfe-455e-b45a- b0fcb99f13ee

accountNumber

String

Account number, this will be the tokenisation result for credit/debit cards

4683530627670000
  • Raw response example: {“accountId”: “2087bfb1-ecfe-455e-b45a-b0fcb99f13ee”, “accountNumber”: “4683530627670000”}


4. Perform Payment API

Please refer to Direct Payout API or Hosted Payment Gateway API guide to get more information on how a payment is performed and what sort of parameters are required when making this server to server call. However, you can also see the exact calls and parameters that you can test from here: http://docsapi-stg.easypaymentgateway.com/

 


Error responses

In the event of error a Error JSON bean will be provided by the system along an error status depending in the error nature.

The error JSON has the following format:

Parameter

Type

Description

Example value

error

Boolean

This flag will be always present and true in the event of an error

TRUE

errorMessage

String

Description of the error

“Error in Core service: The provided auth token is invalid or expired: 91828dd3-28ae-4b00- 9c71-3d479f036233”

errorCode

Integer

Internal error identifier

-1

  • Raw error response example: {“error”: true, “errorMessage”: “Error in Core service: The provided auth token is invalid or expired: 91828dd3-28ae-4b00-9c71-3d479f036233”, “errorCode”: -1}

 

Cookies Policy We need our cookies to make Easy Payment Gateway better. If you need more information click here.