Skip to main content
The payx-js SDK allows you to accept payments directly on your website using a secure, modal checkout experience without redirecting your customers.

How It Works (Scoped Token Model)

To protect your account, never embed secret API keys in client-side code. PayX uses a secure 2-step token flow:
  1. Server-Side Token Generation: Your backend server calls POST /api/v1/checkout using your secret API key (px_live_v2_... or px_test_v2_...) to create a 30-minute scoped checkout token (px_checkout_...).
  2. Client-Side Initialization: Your frontend receives the scoped token and initializes PayX.checkout({ token }) to render the payment modal.

Installation

Include the PayX JS script tag before the closing </body> tag or in the <head> of your page:

Via NPM


Usage Example

Step 1: Generate Scoped Token on Backend (Node.js)

Step 2: Launch Checkout in Frontend


Configuration Options

string
required
The 30-minute scoped checkout token (px_checkout_...) generated server-side by POST /api/v1/checkout.

Callbacks

function
required
Callback triggered when the transaction is completed successfully. Receives a response object containing reference and transaction metadata.
function
Callback triggered when the customer dismisses or closes the modal without completing payment.
function
Callback triggered if an unexpected error occurs during initialization or processing.

Security Rule: Never pass your px_live_v2_... or px_test_v2_... secret API keys into PayX.checkout(). Only pass short-lived scoped tokens (px_checkout_...).