Gateway.js Quick Start

    Gateway.js is a JavaScript library that allows you to extend your integration with additional gateway services. By loading the library into your checkout page, you can enable advanced features such as payer authentication and fraud prevention without having to build those capabilities yourself.

    Overview

    The Gateway.js script is retrieved directly from the payment gateway's servers and should never be hosted on your own domain. Doing so ensures that the library remains up‑to‑date and that sensitive code isn't tampered with. The script tag looks like this:

    <script
      src="https://secure.networkmerchants.com/js/v1/Gateway.js">
    </script>

    Loading the script from the gateway means you always get the latest version. This is explicitly recommended in the official documentation.

    Getting Started

    1. Add the script tag. Copy the snippet above into the <head> or before the closing</body> tag of your checkout page. The library will load asynchronously.
    2. Create a public API key. The library authenticates using a public key with Checkout permissions. You can generate this key in your merchant dashboard under Settings → Security Keys. Once created, you'll use it when initialising the library.
    3. Initialise the library. CallGateway.create() with your public key. This returns a new Gateway instance you can use to access additional services:
      const gateway = Gateway.create('YOUR_PUBLIC_KEY_HERE');
    4. Enable extensions. Gateway.js supports optional modules such as payer authentication (3‑D Secure) and fraud prevention. After initialising, call methods on the gateway instance to configure these services. For example,gateway.get3DSecure() returns the object used for 3‑D Secure flows and gateway.getKount()provides fraud prevention features.

    Best Practices

    • Always load the script over HTTPS from the official gateway domain. Avoid serving it from your own server to ensure you receive security updates.
    • Restrict the scope of your public key. Create one key per environment (test or production) and rotate keys regularly.
    • Only initialise extensions you intend to use. Unused components don't need to be initialised, keeping your integration lean and performant.
    • Consult the official API reference for detailed methods and callback signatures. This page provides a high‑level overview to get you started quickly.

    Use Cases

    Gateway.js is ideal for merchants who wish to add advanced services to an existing checkout page without rebuilding their integration. For example, you can implement 3‑D Secure to authenticate cardholders prior to submission or integrate a machine‑learning fraud solution such as Kount. Because the library exposes modular APIs, you can pick and choose features based on your risk and compliance requirements.