These are the docs for version 2. For the current version docs click here.

BankPay SDK for JS Documentation

This SDK allows you to implement ACH payments in an environment where JavaScript is executable.

Using the SDK

Including BankPay.js is as easy adding a script tag with the import.

<script src="https://js.bankpay.certegy.com/v2"></script>

For best secure practices - You can’t pack the script in a bundle or host a copy of it yourself.

After including, you may import the library using:

const sdk = new BankPay({
    publishableKey: 'publishable-key',
    environment: 'cce'|'production',
});

Environment can be set to either cce or production (default).

At this point, it is time to register callback events. As of now there are a few:

  • close - optional
  • enrollmentError - optional
  • bankAccountAdded - required in enroll
  • acceptedTransactionIntentServiceFee - required in transact

An example is below for attaching functions to the events. BankPay.js will call out to these functions as these events occur. If required events are not registered, BankPay.js will error out.

sdk.setEventHandlers({
    close: () => {
        // handle modal close
    },
    enrollmentError: ({error, message}) => {
        // handle enrollment error
    },
    bankAccountAdded: ({intent_id}) => {
        // handle enrollment processing
    },
    acceptedTransactionIntentServiceFee: ({transactionIntentId}) => {
        // handle transaction authorization
    }
});

Adding a Payment Method (Enrollments)

When you are ready to securely collect payment methods. You can first prepare an Enrollment Intent and pass along that intentId.

sdk.enroll(intentId);

This will launch a modal and begin the process for securely collecting information. Now, it is possible for 3 events to happen.

  1. close
    • The modal was closed whether by error or intentional.
  1. enrollmentError
    • The payment method added was invalid and not usable.
    • You may generate another Enrollment Intent and try again instructing the end user to use another payment method.
  1. bankAccountAdded
    • The payment method was added and now require processing.
    • This is where the backend call to process the Enrollment Intent is required.

If the event (bankAccountAdded) was emitted. The SDK will poll awaiting the server side completion of processing an Enrollment. It will poll up to 5 minutes providing feedback to the end user. Once completed, it will then fire a regular close event.

Paying (Transactions)

When you are ready to securely pay for an item. You can first prepare an Transaction Intent and pass along that intentId.

sdk.transact(intentId);

This will launch a modal and begin the service fee approval process. Now, it is possible for 2 events to happen.

  1. close
    • The modal was closed whether by error or intentional.
  1. acceptedTransactionIntentServiceFee
    • The service fee was accepted and now requires processing.
    • This is where the backend call to authorize the Transaction Intent is required.

At this point, if authorized and completed the end user will trigger the close event.