NewRegister your business and get a corporate bank account, fast
Support
Log inOpen an account
← Developer docs

JavaScript SDK

Guides

  • Introduction
  • Payment widget
  • JavaScript SDK
  • API reference

JavaScript SDK

The @supa/pay-sdk is the easiest way to integrate Supapay into your web application. It handles the payment iframe, security handshakes, and event handling.

Installation

Via NPM

pnpm add @supa/pay-sdk

Via CDN

<script src="https://js.supa.pay/v1/sdk.js"></script>

Usage (token-based, recommended)

Create a payment intent on your backend (via the Supapay API), then open the hosted experience for the returned token. No amount or keys are passed from the browser.

import { SupaPay } from '@supa/pay-sdk';

// `token` comes from your backend after creating a payment intent.
const handle = SupaPay.open({
  token: 'pay_xxxxxxxxxxxxxxxx',
  // payUrl: 'https://pay.yourhost.com', // optional; defaults to NEXT_PUBLIC_PAY_URL
  onSuccess: ({ token, reference }) => {
    console.log('Paid:', token, reference);
    // Settlement is also confirmed server-side via webhook. This is just UX.
  },
  onClose: () => console.log('User dismissed the modal'),
  onError: (err) => console.error(err),
});

// Programmatically close if needed:
// handle.close();

SupaPay.open renders ${payUrl}/pay/{token} in a modal iframe and bridges PAYMENT_SUCCESS / WIDGET_CLOSE / PAYMENT_ERROR messages to your callbacks. It returns a handle with a close() method. The backdrop click and Escape also close it.

Usage (legacy key/amount widget)

1. Setup

Initialize the SDK with your Public Key. You can find your keys in the Supapay dashboard.

import { SupaPay } from '@supa/pay-sdk';

const pay = SupaPay.setup({
  key: 'pk_test_your_key_here',
  amount: 15000, // Amount in NGN
  currency: 'NGN',
  email: 'customer@example.com',
  onSuccess: (reference) => {
    console.log('Transaction Complete:', reference);
    // Verify transaction on your backend
  },
  onClose: () => {
    console.log('User closed the widget');
  }
});

2. Trigger Checkout

Call the .open() method when your user is ready to pay.

document.getElementById('checkout-btn').addEventListener('click', () => {
  pay.open();
});

Configuration Options

OptionTypeDescription
keystringYour Supapay public key.
amountnumberThe amount to charge in kobo (or major unit depending on config).
currencystringCurrency code (e.g., NGN).
emailstringCustomer email address.
onSuccessfunctionCallback triggered after successful payment.
onClosefunctionCallback triggered when the widget is closed.

Event Handling

The SDK uses window.postMessage internally to communicate with the iframe. You do not need to handle this manually unless you are building a custom wrapper.

PreviousPayment widgetNextAPI reference

For Business

  • Business account
  • Collect
  • Payouts
  • Multi-currency
  • Checkout

For Personal

  • Collect
  • Personal account
  • Send
  • Payment links
  • Cash out

Company

  • About
  • Blog
  • Contact

Resources

  • Developer docs
  • Pricing
  • Help centre
  • FAQ

12 Adetokunbo Ademola Street,Victoria Island, Lagos State.

support@supastore.app

+234 800 000 0000

Connect with us

Copyright © 2026, Supapay

Privacy PolicyTerms of Service

© 2026. Supapay is a financial technology company. Banking and payment services are provided through licensed institutions regulated by the Central Bank of Nigeria. Supapay web and mobile applications are properties of SUPA SYSTEMS LIMITED, a company registered with the Corporate Affairs Commission with RC 9428799. Unauthorised reproduction or redistribution of copyrighted materials on this website and Supapay's digital channels is strictly prohibited. By following links on this site that leave Supapay, you may visit third-party websites. The privacy practices of those parties may differ from Supapay's. We recommend you review their privacy statements, as Supapay is not responsible for their privacy or security practices.