Table of Contents
Overview
Gateway.js, a JavaScript library, empowers merchants to tailor their integrations and incorporate additional gateway services like Kount. Kount serves to identify and prevent fraudulent transactions by analyzing various data points before transaction submission. The seamless integration of Kount's Data Collector into checkout pages is facilitated through our Payment API.
Integrating Gateway.js & Kount
In order to allow Kount to review and score transactions, integrators will need to utilize Gateway.js, by initializing the JavaScript Library and calling the Kount service within Gateway.js. This article will explain the flow and function that integrators should implement to their integrations in order to utilize the Kount service within Gateway.js:
- The integration will first need to start by adding Gateway.js as the Gateway.js JavaScript library will be used to complete this integration.
-
Once Gateway.js has been added, the integration will then need to initialize Gateway.js by utilizing the merchant's public Checkout Key. You can view your existing public keys or create a new one in the merchant portal's Security Key page.
- Here is an example of how to initialize Gateway.js:
<script src="https://secure.nmi.com/js/v1/Gateway.js"></script>
<script>
//Initialize Gateway.js, use own Public Key
const gateway = Gateway.create('collect_checkout_0000000000000000000000000');
...
- Once Gateway.js has been initialized you will then be able to initialize the Kount service by calling
gateway.getkount()
. Kount must be initialized prior to the next step where we run Kount in order to collect data in order to determine the transactions score.
//Initialize the Kount service
const kount = gateway.getKount();
- After Kount has been initialized you may now execute Kount to process transaction data via the Fraud protection service. Invoke the
createsession()
function to initiate Kount and capture itssessionId
using the.then
method.
//Run Kount
kount.createSession().then((res) = {
//Store session id
const sessionId = res;
The above functions will call Kount, retrieve Kount's session id and store the session id within the set parameter sessionId
.
- Once Kount has been run the integration will need to create a JavaScript object with additional transaction details. The details to include are credit card information(
ccnumber, ccexp, cvv
),currency, amount, email, city, address1, country, zip, first_name, last_name
and thetransaction_session_id
. - The JavaScript object is necessary to collect transaction data for submission to the Payment API. This object contains all the required transaction details to successfully complete the transaction. Here is an example of how to set up the object with the necessary details.
const options = {
ccnumber: '4111111111111111',
ccexp: '10/25',
cvv: '999',
currency: 'USD',
amount: '1000',
email: 'none@example.com',
phone: '8008675309',
city: 'New York',
state: 'NY',
address1: '123 First St.',
country: 'US',
firstName: 'John',
lastName: 'Doe',
postalCode: '60001',
transactionSessionId: sessionId
};
The above example shows the creation of a JavaScript object which holds transactional information for this transaction, including the transactionSessionId
. Upon creation of the object the integration will now need to submit the transaction via a POST method to the Payment API to complete the transaction.