6. Loading the frontend library

You are provided HTML/Javascript snippets that can be embedded in any frontend framework. Below you will find examples of this platform embedded in some popular frontend frameworks.

React

Step 1. Install the npm package

npm install payengine

Step 2. Load the platform using react useEffect hook

import { useEffect } from "react";
import { loadPayengine } from "payengine";

const MyComponent = () => {

    useEffect(() => {
        // Load Payengine on first render only
        loadPayengine({
            publicKey: config.PAYENGINE_PUBLIC_KEY,      
        }).then((pe) => {
            console.log(pe)
        });  
    }, []);
 
    return (
    <>
    <pay-engine 
      type="boarding" 
      merchant-id="<payengine_merchant_id>" 
    </pay-engine>        
    </>
    )   
}

This is just our recommended way of loading the library. There are other ways library can be loaded for example by leveraging React's provider pattern.

React Native

Step 1. Install npm package https://www.npmjs.com/package/payengine-react-native

Step 2. Step 2. Load the platform

Vue.js

Step 1. Install the npm package

Step 2. Load the platform using Vue.js lifecycle created hook

This is our recommended way of loading the library. Other methods can be used according to your own requirements.

Angular

Step 1. Install the npm package

Step 2. Enable `CUSTOM_ELEMENTS_SCHEMA` mode

By default, Angular assumes that all custom HTML elements are Angular components and throws errors when encountering non-angular components. You need to enable custom elements by adding the CUSTOM_ELEMENTS_SCHEMA to the application module.

Following is an example of what a module file should look like with CUSTOM_ELEMENTS_SCHEMA added.

Step 3. Load the platform using lifecycle ngOnInit hook

Step 4. Add the respective HTML components to the Angular Components.

Plain HTML/Javascript

In HTML you can enable web components by adding a script tag pointing to javascript library. Once loaded, pay-engine web component are available to use anywhere in your HTML.

Flutter

The Flutter package can be downloaded from https://pub.dev/packages/payengine

Step 1. Configuration

Step 2. Displaying a credit card form

Step 3. Displaying a bank account form for ACH

Step 4 - Using other components.

Note that the type can be any of the web components:

iOS SDK

Please ask your technical contact to get access to iOS SDK.

Displaying secure form

Capturing card token

Displaying ACH form and capturing token

Lightweight Version (Optimized for Secure Fields)

For applications that don't require all web components, an optimized library version enables faster load times with access to only a limited set of components. This is advisable for those needing only secure fields or Plaid in their web application.

Please note that the optimized library only provides the following functionalities. For UI web widgets, please use the full library as specified in the previous section.

  • Secure Fields

  • Plaid

  • Fraud Session

  • 3DS flow

  • Apple Pay

  • Google Pay

Last updated