Getting Started
Step 1: Start transaction
Merchant server only
The code samples below show how you can start a checkout transaction from your merchant server and generate a transaction token that will be used on the client-side to continue the transaction flow.
Environment & Asset URLs
Sandbox Account
URL Type | URL |
---|---|
environment | https://api.emergepay-sandbox.chargeitpro.com/virtualterminal/v1 |
assets | https://assets.emergepay-sandbox.chargeitpro.com |
Production Account
URL Type | URL |
---|---|
environment | https://api.emergepay.chargeitpro.com/virtualterminal/v1 |
assets | https://assets.emergepay.chargeitpro.com |
Available transaction types
CreditSale
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.CreditSale,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.CreditSale,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'CreditSale',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "CreditSale",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
CreditReturn
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.CreditReturn,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.CreditReturn,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'CreditReturn',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "CreditReturn",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
CreditAuth
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.CreditAuth,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.CreditAuth,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'CreditAuth',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "CreditAuth",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
CreditSaveCard
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.CreditSaveCard,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.CreditSaveCard,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'CreditSaveCard',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "CreditSaveCard",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
AchSale
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.AchSale,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.AchSale,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'AchSale',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "AchSale",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
AchReturn
The transaction token retrieved here is used by the client-side sdk to load the emergepay form fields, which is where customers can enter their card or account information.
//install the modules below with the following command:
//npm install express cors emergepay-sdk
var express = require("express");
var cors = require("cors");
var sdk = require("emergepay-sdk");
//Ensure that you replace these with valid values before trying to issue a request
var oid = "your_oid";
var authToken = "your_authToken";
var environmentUrl = "environment_url";
var emergepay = new sdk.emergepaySdk({ oid: oid, authToken: authToken, environmentUrl: environmentUrl });
var app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: true }));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", function (req, res) {
var config = {
transactionType: sdk.TransactionType.AchReturn,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(function (transactionToken) {
res.send({
transactionToken: transactionToken
});
})
.catch(function (err) {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
//install the modules below with the following command:
//npm install express cors emergepay-sdk
import * as express from "express";
import * as cors from "cors";
import {emergepaySdk, TransactionType} from "emergepay-sdk";
//Ensure that you replace these with valid values before trying to issue a request
const oid: string = "your_oid";
const authToken: string = "your_authToken";
const environmentUrl: string = "environment_url";
const emergepay: emergepaySdk = new emergepaySdk({oid, authToken, environmentUrl});
const app: any = express();
app.use(express.json());
app.use(express.urlencoded({extended:true}));
app.use(cors());
//The client side can hit this endpoint by issuing a POST request to
//localhost:5555/start-transaction
app.post("/start-transaction", (req, res) => {
const config: any = {
transactionType: TransactionType.AchReturn,
method: "hostedFields",
submissionType: "manual"
};
emergepay.startTransaction(config)
.then(transactionToken => {
res.send({
transactionToken: transactionToken
});
})
.catch(err => {
res.send(err.message);
});
});
console.log("listening on port 5555");
app.listen(5555);
<?php
//Configure your oid, authToken, and environmentUrl.
//These are required and supplied by ChargeItPro.
//Note: Make sure you set these before attempting to retrieve transaction results.
$oid = 'your_oid';
$authToken = 'your_authToken';
$environmentUrl = 'environment_url';
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/start';
//Set up the request body.
//base_amount and external_tran_id are required in the fields array.
$body = array(
'transactionType' => 'AchReturn',
'method' => 'hostedFields',
'submissionType' => 'manual'
)
);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_POST, true);
curl_setopt($request, CURLOPT_POSTFIELDS, json_encode($body));
//Issue the request and get the response
$response = curl_exec($request);
curl_close($request);
echo $response;
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public async Task StartTransactionAsync(StartTransactionModel config)
{
var response = new object();
//Ensure these are set before trying to issue the request.
//Please contact ChargeItPro to get these values.
const string OID = "your_oid";
const string AUTH_TOKEN = "your_authToken";
const string ENDPOINT_URL = "environment_url";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/start";
var contents = new
{
transactionData = new
{
transactionType = "AchReturn",
method = "hostedFields",
submissionType = "manual"
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Post, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields
These fields are the fields sent in the transactionData
object found in the request body.
Name | Details | Required | Description |
---|---|---|---|
transactionType | Type: string Possible values: - CreditSale - CreditReturn - CreditAuth - CreditSaveCard - AchSale - AchReturn | Yes | The transaction type for the transaction request |
method | Type: string Possible values: - hostedFields | Yes | The integration method. The only applicable value for checkout integrations is hostedFields |
submissionType | Type: string Possible values: - manual | Yes | The submissionType indicates that we're only using the form fields to collect the sensitive customer data and plan on submitting the other transaction details in a later request. |
Step 2: Present payment form
Client-side only
After setting up a way to get a transaction token on your server, you will now need to retrieve that transaction token client-side and use it to load the emergepay form fields.
Parent Domain
You must supply Gravity Payments with a valid parent domain. Connect with an Integration Specialist for more information.
Basic flow of Checkout
The form fields work by appending iframe
 elements to container elements, such as divs, on your site. The iframes display input fields hosted from our servers that will collect sensitive customer data. The type of form fields appended to your site will depend on the transaction type supplied in step 1.
For card-specific transaction types, the available form fields are:
- Credit card number
- Expiration date
- Card security code
For ACH-specific transaction types, the available form fields are:
- Account number
- Routing number
- Account holder name
Here are the steps:
- Your page loads withÂ
<div>
 elements in your checkout form that will serve as containers for the form fields. For example,
<div id="cardNumberContainer"></div>
 would act as a container for the iframe that contains the credit card form field. - Your page includes a reference to the form fields assets javascript file in a script tag:
<script src="assets_url/cip-hosted-fields.js"></script>
When this assets file loads, it will expose aÂwindow.emergepayFormFields
 object. - Take a look at the sample code below to configure the emergepay form fields. This process will include fetching a transaction token from your server and initializing the form fields with a supplied configuration object. This will let emergepay know where to append the fields to your site, how to style them, and what action should occur when the field values are submitted successfully.
- Attach a listener to the submit event on your checkout form that callsÂ
hosted.process()
 when the form submits. This will
initiate the process of sending the values of each form field to our backend and then indicate to you that the transaction is ready to be processed by calling theÂonUserAuthorized
 callback that you supplied in theÂemergepayFormFields.init()
 configuration object.
Field styling
Styling form fields can be done in your merchant configuration or on a per-field per-transaction basis.
An example of per-field styling can be seen in the code sample below in the styles
 object under each field in fieldSetUp
. Any CSS property applicable to the input
 element is valid. A reference for the available CSS properties can be found here.
Note: if any styles are set via merchant configuration, the styles set in the styles
 object under each field will override them.
<!-- These are the elements that the fields will be appended to -->
<div>
<!-- Elements that fields will be appended to for credit card transactions -->
<div id="cardNumberContainer"></div>
<div id="expirationDateContainer"></div>
<div id="securityCodeContainer"></div>
<!-- Elements that fields will be appended to for ACH transactions -->
<div id="accountNumberContainer"></div>
<div id="routingNumberContainer"></div>
<div id="accountHolderNameContainer"></div>
<button id="payBtn">Pay</button>
</div>
<!--
Load emergepay fields javascript file.
NOTE: make sure you replace assets_url with the correct url for the environment you're working in.
-->
<script src="assets_url/cip-hosted-fields.js"></script>
<!--
After the script has loaded you will have access to the `window.emergepayFormFields` object.
This object has two public methods: `init()` and `process()`.
-->
<!-- Use the emergepay library -->
<script>
$(document).ready(function () {
getToken().then(function(transactionToken) {
// Initialize the hosted fields
var hosted = emergepayFormFields.init({
// (required) Used to set up each field
transactionToken: transactionToken,
// (required) The type of transaction to run
transactionType: "CreditSale",
// (optional) Configure which fields to use and the id's of the elements to append each field to
fieldSetUp: {
// These fields are valid for credit card transactions
cardNumber: {
appendToSelector: "cardNumberContainer",
useField: true,
// optional, see styles section above for more information
styles: { "background-color": "blue" }
},
cardExpirationDate: {
appendToSelector: "expirationDateContainer",
useField: true,
// optional, see styles section above for more information
styles: { "border": "1px solid red" }
},
cardSecurityCode: {
appendToSelector: "securityCodeContainer",
useField: true,
// optional, see styles section above for more information
styles: {}
},
// These fields are valid for ACH transactions
accountNumber: {
appendToSelector: "accountNumberContainer",
useField: true,
// optional, see styles section above for more information
styles: {}
},
routingNumber: {
appendToSelector: "routingNumberContainer",
useField: true,
// optional, see styles section above for more information
styles: {}
},
accountHolderName: {
appendToSelector: "accountHolderNameContainer",
useField: true,
// optional, see styles section above for more information
styles: {}
},
// These fields are valid for all transaction types
totalAmount: {
appendToSelector: "amountContainer",
useField: false,
// optional, see styles section above for more information
styles: {}
},
externalTranId: {
useField: false,
// optional, see styles section above for more information
styles: {}
}
},
// (optional) If there is a validation error for a field, the styles set in this object will be applied to the field
fieldErrorStyles: {
"border": "none",
"box-shadow": "0px 0px 4px 1px red"
},
// (optional) This callback function will be called when there is a validation error for a field.
onFieldError: function (data) {
console.log(data);
},
// (optional) This callback function will be called when a field validation error has been cleared.
onFieldErrorCleared: function (data) {
console.log(data);
},
// (required) Callback function that gets called after user successfully enters their information into the form fields and triggers the execution of the `process` function
onUserAuthorized: function (transactionToken) {
console.log('transactionToken', transactionToken);
var details = {
transactionToken,
// any other transaction details you may need to send to your server
};
$.ajax({
url: 'http://localhost:5555/submit',
type: 'POST',
dataType: 'json',
contentType: 'application/json',
data: JSON.stringify(details)
})
.done(function(data) {
// your server successfully ran the transaction
location = 'https://www.gravitypayments.com';
})
.fail(function(error) {
console.error(error);
});
},
});
$('#payBtn').on("click", function (event) {
event.preventDefault();
// run the transaction if all fields are valid
hosted.process();
});
});
});
// This function makes a call to your server to get a transaction token
function getToken() {
return new Promise(function (resolve, reject) {
$.ajax({
url: 'http://localhost:5555/start-transaction',
type: 'POST',
dataType: 'json',
contentType: 'application/json'
})
.done(function(data) {
if (data.transactionToken) resolve(data.transactionToken);
else reject('Error getting transaction token');
})
.fail(function(err) {
reject(err);
});
});
}
</script>
Step 3: Process the transaction
Merchant server only
When the onUserAuthorized
callback is triggered as part of Step Two, the customer’s sensitive card or ACH account info is temporarily retained in memory in emergepay’s backend until the session either expires or the transaction is processed.
To process the transaction, you will need to send a transaction request to emergepay’s checkout endpoint, which will merge the customer’s sensitive card or ACH account info with the transaction details you supply in the request. The type of transaction being run will be fetched from the session and will have the same value as supplied in Step One.
Getting results
Checkout transactions will always return the transaction results directly; you will not get a postback and there should be no need to make any additional calls to retrieve the results.
Transaction Methods
Process a sale
Process a checkout transaction initiated with the CreditSale
 transaction type.
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
const sdk = require('emergepay-sdk').emergepaySdk;
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new sdk({ oid, authToken, environmentUrl });
emergepay.checkoutTransaction({
transactionToken: "value from step 1",
transactionType: "CreditSale",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
tipAmount: "0.25",
transactionReference: "My Invoice ID",
})
.then(response => {
const transactionResponse = response.data;
});
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
import {
emergepaySdk,
CheckoutTransaction,
TransactionResponse,
} from "emergepay-sdk";
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new emergepaySdk({ oid, authToken, environmentUrl });
const request: CheckoutTransaction = {
transactionToken: "value from Step 1",
transactionType: "CreditSale",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
tipAmount: "0.25",
transactionReference: "My Invoice ID",
}
emergepay.checkoutTransaction(request)
.then((response: TransactionResponse) => {
const transactionResponse = response.data;
});
<?php
// Ensure that you replace these with valid values before trying to issue a request
$oid = 'oid';
$authToken = 'authToken';
$environmentUrl = 'environment_url';
$transactionToken = "value from Step 1";
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/checkout/' . $transactionToken;
// Configure the request body
// externalTransactionId and amount are required.
$body = [
'transactionData' => [
'amount' => '1.00',
'externalTransactionId' => GUID(),
//optional
'billingAddress': '123 Main St',
'billingName': 'John Smith',
'billingPostalCode': '90210',
'cashierId': 'My Cashier',
'tipAmount': '0.25',
'transactionReference': 'My Invoice ID',
]
];
$payload = json_encode($body);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
//Issue the request and get the result
$response = curl_exec($request);
echo $response;
curl_close($request);
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public static async Task<object> CheckoutTransactionAsync()
{
var response = new object();
// Ensure these are set before trying to issue the request.
const string OID = "oid";
const string AUTH_TOKEN = "authToken";
const string ENDPOINT_URL = "environment_url";
string transactionToken = "value from Step 1";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/checkout/{transactionToken}";
var contents = new
{
transactionData = new
{
amount = "1.00",
externalTransactionId = Guid.NewGuid().ToString(),
//optional
billingAddress = "123 Main St",
billingName = "John Smith",
billingPostalCode = "90210",
cashierId = "My Cashier",
tipAmount = "0.25",
transactionReference = "My Invoice ID",
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields for CreditSale
Name | Details | Required | Description |
---|---|---|---|
amount | Type: string
Example values: |
Yes | The transaction amount. |
externalTransactionId | Type: v4 uuid | Yes | A unique transaction identifier (must be a Version-4 UUID) for each transaction. This value is used to look up transaction results as well as confirm to the merchant and emergepay that a transaction was completed. |
billingAddress | Type: string | No | The customer’s street address. |
billingName | Type: string Max length: 75 |
No | The customer’s billing name. |
billingPostalCode | Type: string | No | The customer’s zip code |
cashierId | Type: string Max length: 150 |
No | The name of the cashier that ran the transaction |
tipAmount | Type: string
Example values: |
No | An optional tip amount that can be added at the time of the sale. The total amount of the sale will be equal to tipAmount + amount . |
transactionReference | Type: string Min length: 3 Max length: 65 |
No | The order id associated with the transaction. |
Process a Return
Process a checkout transaction initiated with the CreditReturn transaction type.
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
const sdk = require('emergepay-sdk').emergepaySdk;
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new sdk({ oid, authToken, environmentUrl });
emergepay.checkoutTransaction({
transactionToken: "value from step 1",
transactionType: "CreditReturn",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
})
.then(response => {
const transactionResponse = response.data;
});
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
import {
emergepaySdk,
CheckoutTransaction,
TransactionResponse,
} from "emergepay-sdk";
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new emergepaySdk({ oid, authToken, environmentUrl });
const request: CheckoutTransaction = {
transactionToken: "value from Step 1",
transactionType: "CreditReturn",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
}
emergepay.checkoutTransaction(request)
.then((response: TransactionResponse) => {
const transactionResponse = response.data;
});
<?php
// Ensure that you replace these with valid values before trying to issue a request
$oid = 'oid';
$authToken = 'authToken';
$environmentUrl = 'environment_url';
$transactionToken = "value from Step 1";
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/checkout/' . $transactionToken;
// Configure the request body
// externalTransactionId and amount are required.
$body = [
'amount' => '1.00',
'externalTransactionId' => GUID(),
//optional
'billingAddress': '123 Main St',
'billingName': 'John Smith',
'billingPostalCode': '90210',
'cashierId': 'My Cashier',
'transactionReference': 'My Invoice ID',
]
];
$payload = json_encode($body);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
//Issue the request and get the result
$response = curl_exec($request);
echo $response;
curl_close($request);
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public static async Task CheckoutTransactionAsync()
{
var response = new object();
// Ensure these are set before trying to issue the request.
const string OID = "oid";
const string AUTH_TOKEN = "authToken";
const string ENDPOINT_URL = "environment_url";
string transactionToken = "value from Step 1";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/checkout/{transactionToken}";
var contents = new
{
transactionData = new
{
amount = "1.00",
externalTransactionId = Guid.NewGuid().ToString(),
//optional
billingAddress = "123 Main St",
billingName = "John Smith",
billingPostalCode = "90210",
cashierId = "My Cashier",
transactionReference = "My Invoice ID",
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields for CreditReturn
Name | Details | Required | Description |
---|---|---|---|
amount | Type: string
Example values: |
Yes | The transaction amount. |
externalTransactionId | Type: v4 uuid | Yes | A unique transaction identifier (must be a Version-4 UUID) for each transaction. This value is used to look up transaction results as well as confirm to the merchant and emergepay that a transaction was completed. |
billingAddress | Type: string | No | The customer’s street address. |
billingName | Type: string Max length: 75 |
No | The customer’s billing name. |
billingPostalCode | Type: string | No | The customer’s zip code |
cashierId | Type: string Max length: 150 |
No | The name of the cashier that ran the transaction |
transactionReference | Type: string Min length: 3 Max length: 65 |
No | The order id associated with the transaction. |
Process an Authorization
Process a checkout transaction initiated with the CreditAuth transaction type.
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
const sdk = require('emergepay-sdk').emergepaySdk;
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new sdk({ oid, authToken, environmentUrl });
emergepay.checkoutTransaction({
transactionToken: "value from step 1",
transactionType: "CreditAuth",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
tipAmount: "0.25",
transactionReference: "My Invoice ID",
})
.then(response => {
const transactionResponse = response.data;
});
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
import {
emergepaySdk,
CheckoutTransaction,
TransactionResponse,
} from "emergepay-sdk";
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new emergepaySdk({ oid, authToken, environmentUrl });
const request: CheckoutTransaction = {
transactionToken: "value from Step 1",
transactionType: "CreditAuth",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
tipAmount: "0.25",
transactionReference: "My Invoice ID",
}
emergepay.checkoutTransaction(request)
.then((response: TransactionResponse) => {
const transactionResponse = response.data;
});
<?php
// Ensure that you replace these with valid values before trying to issue a request
$oid = 'oid';
$authToken = 'authToken';
$environmentUrl = 'environment_url';
$transactionToken = "value from Step 1";
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/checkout/' . $transactionToken;
// Configure the request body
// externalTransactionId and amount are required.
$body = [
'amount' => '1.00',
'externalTransactionId' => GUID(),
//optional
'billingAddress': '123 Main St',
'billingName': 'John Smith',
'billingPostalCode': '90210',
'cashierId': 'My Cashier',
'tipAmount': '0.25',
'transactionReference': 'My Invoice ID',
]
];
$payload = json_encode($body);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
//Issue the request and get the result
$response = curl_exec($request);
echo $response;
curl_close($request);
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public static async Task CheckoutTransactionAsync()
{
var response = new object();
// Ensure these are set before trying to issue the request.
const string OID = "oid";
const string AUTH_TOKEN = "authToken";
const string ENDPOINT_URL = "environment_url";
string transactionToken = "value from Step 1";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/checkout/{transactionToken}";
var contents = new
{
transactionData = new
{
amount = "1.00",
externalTransactionId = Guid.NewGuid().ToString(),
//optional
billingAddress = "123 Main St",
billingName = "John Smith",
billingPostalCode = "90210",
cashierId = "My Cashier",
tipAmount = "0.25",
transactionReference = "My Invoice ID",
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields for CreditAuth
Name | Details | Required | Description |
---|---|---|---|
amount | Type: string
Example values: |
Yes | The transaction amount. |
externalTransactionId | Type: v4 uuid | Yes | A unique transaction identifier (must be a Version-4 UUID) for each transaction. This value is used to look up transaction results as well as confirm to the merchant and emergepay that a transaction was completed. |
billingAddress | Type: string | No | The customer’s street address. |
billingName | Type: string Max length: 75 |
No | The customer’s billing name. |
billingPostalCode | Type: string | No | The customer’s zip code |
cashierId | Type: string Max length: 150 |
No | The name of the cashier that ran the transaction |
tipAmount | Type: string
Example values: |
No | An optional tip amount that can be added at the time of the authorization. The total amount of the authorization will be equal to tipAmount + amount . |
transactionReference | Type: string Min length: 3 Max length: 65 |
No | The order id associated with the transaction. |
Tokenize a card
Process a checkout transaction initiated with the CreditSaveCard transaction type.
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
const sdk = require('emergepay-sdk').emergepaySdk;
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new sdk({ oid, authToken, environmentUrl });
emergepay.checkoutTransaction({
transactionToken: "value from step 1",
transactionType: "CreditSaveCard",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
})
.then(response => {
const transactionResponse = response.data;
});
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
import {
emergepaySdk,
CheckoutTransaction,
TransactionResponse,
} from "emergepay-sdk";
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new emergepaySdk({ oid, authToken, environmentUrl });
const request: CheckoutTransaction = {
transactionToken: "value from Step 1",
transactionType: "CreditSaveCard",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
}
emergepay.checkoutTransaction(request)
.then((response: TransactionResponse) => {
const transactionResponse = response.data;
});
<?php
// Ensure that you replace these with valid values before trying to issue a request
$oid = 'oid';
$authToken = 'authToken';
$environmentUrl = 'environment_url';
$transactionToken = "value from Step 1";
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/checkout/' . $transactionToken;
// Configure the request body
// externalTransactionId and amount are required.
$body = [
'externalTransactionId' => GUID(),
//optional
'billingAddress': '123 Main St',
'billingName': 'John Smith',
'billingPostalCode': '90210',
'cashierId': 'My Cashier',
'transactionReference': 'My Invoice ID',
]
];
$payload = json_encode($body);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
//Issue the request and get the result
$response = curl_exec($request);
echo $response;
curl_close($request);
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public static async Task CheckoutTransactionAsync()
{
var response = new object();
// Ensure these are set before trying to issue the request.
const string OID = "oid";
const string AUTH_TOKEN = "authToken";
const string ENDPOINT_URL = "environment_url";
string transactionToken = "value from Step 1";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/checkout/{transactionToken}";
var contents = new
{
accountData = new
{
externalTransactionId = Guid.NewGuid().ToString(),
//optional
billingAddress = "123 Main St",
billingName = "John Smith",
billingPostalCode = "90210",
cashierId = "My Cashier",
transactionReference = "My Invoice ID",
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields for CreditSaveCard
Name | Details | Required | Description |
---|---|---|---|
externalTransactionId | Type: v4 uuid | Yes | A unique transaction identifier (must be a Version-4 UUID) for each transaction. This value is used to look up transaction results as well as confirm to the merchant and emergepay that a transaction was completed. |
billingAddress | Type: string | No | The customer’s street address. |
billingName | Type: string Max length: 75 |
No | The customer’s billing name. |
billingPostalCode | Type: string | No | The customer’s zip code |
cashierId | Type: string Max length: 150 |
No | The name of the cashier that ran the transaction |
transactionReference | Type: string Min length: 3 Max length: 65 |
No | The order id associated with the transaction. |
Process an ACH Return
Process a checkout transaction initiated with the AchReturn transaction type.
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
const sdk = require('emergepay-sdk').emergepaySdk;
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new sdk({ oid, authToken, environmentUrl });
emergepay.checkoutTransaction({
transactionToken: "value from step 1",
transactionType: "AchReturn",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
accountType: "Checking",
checkNumber: "100",
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
})
.then(response => {
const transactionResponse = response.data;
});
// install the module below with the following command:
// npm install emergepay-sdk@^1.8
import {
emergepaySdk,
CheckoutTransaction,
TransactionResponse,
} from "emergepay-sdk";
// Ensure that you replace these with valid values before trying to issue a request
const oid = "oid";
const authToken = "authToken";
const environmentUrl = "environment_url";
const emergepay = new emergepaySdk({ oid, authToken, environmentUrl });
const request: CheckoutTransaction = {
transactionToken: "value from step 1",
transactionType: "AchReturn",
amount: "1.00",
externalTransactionId: emergepay.getExternalTransactionId(),
// Optional
accountType: "Checking",
checkNumber: "100",
billingAddress: "123 Main St",
billingName: "John Smith",
billingPostalCode: "90210",
cashierId: "My Cashier",
transactionReference: "My Invoice ID",
}
emergepay.checkoutTransaction(request)
.then((response: TransactionResponse) => {
const transactionResponse = response.data;
});
<?php
// Ensure that you replace these with valid values before trying to issue a request
$oid = 'oid';
$authToken = 'authToken';
$environmentUrl = 'environment_url';
$transactionToken = "value from Step 1";
$url = $environmentUrl . '/orgs/' . $oid . '/transactions/checkout/' . $transactionToken;
// Configure the request body
// externalTransactionId and amount are required.
$body = [
'amount' => '1.00',
'externalTransactionId' => GUID(),
//optional
'accountType' => 'Checking',
'checkNumber' => '100',
'billingAddress': '123 Main St',
'billingName': 'John Smith',
'billingPostalCode': '90210',
'cashierId': 'My Cashier',
'transactionReference': 'My Invoice ID',
]
];
$payload = json_encode($body);
//Configure the request
$request = curl_init($url);
curl_setopt($request, CURLOPT_HEADER, false);
curl_setopt($request, CURLOPT_RETURNTRANSFER, true);
curl_setopt($request, CURLOPT_HTTPHEADER, array('Content-Type: application/json', 'Content-Length: ' . strlen($payload), 'Authorization: Bearer ' . $authToken));
curl_setopt($request, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($request, CURLOPT_POSTFIELDS, $payload);
//Issue the request and get the result
$response = curl_exec($request);
echo $response;
curl_close($request);
//Helper function used to generate a GUID/UUID
//source: http://php.net/manual/en/function.com-create-guid.php#99425
function GUID()
{
if (function_exists('com_create_guid') === true)
{
return trim(com_create_guid(), '{}');
}
return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
}
public static async Task CheckoutTransactionAsync()
{
var response = new object();
// Ensure these are set before trying to issue the request.
const string OID = "oid";
const string AUTH_TOKEN = "authToken";
const string ENDPOINT_URL = "environment_url";
string transactionToken = "value from Step 1";
string url = $"{ENDPOINT_URL}/orgs/{OID}/transactions/checkout/{transactionToken}";
var contents = new
{
transactionData = new
{
amount = "1.00",
externalTransactionId = Guid.NewGuid().ToString(),
//optional
accountType = "Checking",
checkNumber = "100",
billingAddress = "123 Main St",
billingName = "John Smith",
billingPostalCode = "90210",
cashierId = "My Cashier",
transactionReference = "My Invoice ID",
}
};
try
{
using (var client = new HttpClient())
{
var transactionJson = JsonConvert.SerializeObject(contents);
HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Put, url);
request.Headers.Add("Authorization", $"Bearer {AUTH_TOKEN}");
request.Content = new StringContent(transactionJson, Encoding.UTF8, "application/json");
var httpResponse = await client.SendAsync(request);
var data = await httpResponse.Content.ReadAsStringAsync();
response = JsonConvert.DeserializeObject(data);
}
}
catch (Exception exc)
{
throw exc;
}
return response;
}
Input fields for ACHReturn
Name | Details | Required | Description |
---|---|---|---|
amount | Type: string
Example values: |
Yes | The transaction amount. |
externalTransactionId | Type: v4 uuid | Yes | A unique transaction identifier (must be a Version-4 UUID) for each transaction. This value is used to look up transaction results as well as confirm to the merchant and emergepay that a transaction was completed. |
accountType | Type: string
Possible values: |
No | The customer’s account type associated with the account number supplied. |
checkNumber | Type: string | No | An optional check number to associate with the transaction. |
billingAddress | Type: string | No | The customer’s street address. |
billingName | Type: string Max length: 75 |
No | The customer’s billing name. |
billingPostalCode | Type: string | No | The customer’s zip code |
cashierId | Type: string Max length: 150 |
No | The name of the cashier that ran the transaction |
transactionReference | Type: string Min length: 3 Max length: 65 |
No | The order id associated with the transaction. |
Account Card Type Values
Card Brand | Response Code |
---|---|
Mastercard | MC |
Diners Club | DN |
Visa | VS |
JCB | JC |
American Express | AX |
Discover | DC |
Example Transaction Result Responses
{
"uniqueTransId": "77c87064222c4bf88c27f0865d176cf0-0e7453dc741e4233ad571d6ca8d73587",
"batchNumber": "115",
"resultMessage": "Approved",
"resultStatus": "true",
"approvalNumberResult": "039275",
"amountProcessed": "0.01",
"amount": "0.01",
"amountBalance": "",
"transactionReference": "",
"avsResponseCode": "Y",
"avsResponseText": "Address: Match & 5 Digit Zip: Match",
"cvvResponseCode": "P",
"cvvResponseText": "Not Processed",
"accountCardType": "AX",
"accountExpiryDate": "0123",
"transactionType": "CreditSale",
"billingName": "",
"maskedAccount": "***********1111",
"accountEntryMethod": "Keyed",
"externalTransactionId": "cad8d603-0c51-478a-b410-c5ffa7425be1"
}