Pay Checkout
The 100Pay Checkout SDK (@100pay-hq/checkout) is a drop-in JavaScript library for accepting crypto payments directly in the browser. It renders a secure, hosted payment modal — no backend required for the checkout itself.
- Supports 90+ fiat currencies with automatic crypto conversion
- Works with React, Vue, vanilla JS, and any web framework
- Zero blockchain knowledge required
Before integrating, make sure you have set up your account and obtained your API keys.
Installation
npm
npm install @100pay-hq/checkoutImport
// ES module
import { shop100Pay } from "@100pay-hq/checkout";
// CommonJS
const { shop100Pay } = require("@100pay-hq/checkout");Quick Start
import { shop100Pay } from "@100pay-hq/checkout";
shop100Pay.setup({
ref_id: "TXN_" + Date.now(),
api_key: "your_public_api_key", // Public key — safe to use in browser
customer: {
name: "Jane Doe",
email: "[email protected]",
phone: "+1234567890",
},
billing: {
amount: 49.99,
currency: "USD",
description: "Monthly subscription",
country: "US",
pricing_type: "fixed_price",
},
metadata: {
order_id: "ORD_001",
},
call_back_url: "https://yourapp.com/payment/success",
onPayment: (reference) => {
// Send reference to your backend for server-side verification
verifyOnBackend(reference);
},
onClose: () => console.log("Modal closed"),
onError: (error) => console.error("Payment error:", error),
});Use your Public API Key — never your Secret Key — in client-side code. The onPayment callback is client-side only. Always verify payments on your server before fulfilling orders.
Framework Examples
React
import { shop100Pay } from "@100pay-hq/checkout";
function CheckoutButton({ amount, user }) {
const handlePayment = () => {
shop100Pay.setup({
ref_id: "REF_" + Date.now(),
api_key: process.env.REACT_APP_100PAY_API_KEY,
customer: {
name: user.name,
email: user.email,
phone: user.phone,
},
billing: {
amount,
currency: "USD",
description: "Product purchase",
country: "US",
pricing_type: "fixed_price",
},
metadata: { source: "react-app" },
call_back_url: `${window.location.origin}/payment/success`,
onPayment: async (reference) => {
const res = await fetch("/api/verify-payment", {
method: "POST",
body: JSON.stringify({ reference }),
headers: { "Content-Type": "application/json" },
});
if ((await res.json()).success) {
window.location.href = "/payment/success";
}
},
onClose: () => console.log("Closed"),
onError: (err) => alert("Payment failed: " + err),
}, { maxWidth: "500px" });
};
return <button onClick={handlePayment}>Pay ${amount}</button>;
}Parameters
CHARGE_DATA
| Field | Type | Required | Description |
|---|---|---|---|
api_key | string | ✅ | Your 100Pay Public API key |
ref_id | string | ✅ | Unique transaction reference — use a UUID or timestamp |
customer.name | string | ✅ | Customer’s full name |
customer.email | string | ✅ | Customer’s email address |
customer.phone | string | ✅ | Customer’s phone number |
customer.user_id | string | — | Your internal user ID |
billing.amount | number | ✅ | Payment amount |
billing.currency | CURRENCIES | ✅ | Currency code (e.g. "USD", "NGN", "GHS") |
billing.country | COUNTRIES | ✅ | ISO country code (e.g. "US", "NG") |
billing.description | string | ✅ | Short payment description |
billing.pricing_type | "fixed_price" | "partial" | ✅ | "fixed_price" for exact amount, "partial" allows underpayment |
billing.vat | number | — | VAT/tax percentage to add |
metadata | object | ✅ | Custom key/value data attached to the transaction |
call_back_url | string | ✅ | Redirect URL after payment completes |
onPayment | (ref: string) => void | ✅ | Called when payment is detected — send ref to backend to verify |
onClose | () => void | ✅ | Called when the user closes the modal |
onError | (err: string | Error) => void | ✅ | Called on checkout error |
DISPLAY_OPTIONS
| Field | Type | Default | Description |
|---|---|---|---|
maxWidth | string | "400px" | Maximum width of the modal |
maxHeight | string | "unset" | Maximum height of the modal |
Supported Currencies
90+ fiat currencies are supported, including:
USD EUR GBP NGN GHS KES ZAR CAD AUD JPY INR BRL CNY MXN EGP MAD TZS UGX and many more.
TypeScript Types
import { shop100Pay, CHARGE_DATA, DISPLAY_OPTIONS, CURRENCIES, COUNTRIES } from "@100pay-hq/checkout";
const charge: CHARGE_DATA = {
api_key: "your_key",
ref_id: "TXN_001",
customer: { name: "Jane", email: "[email protected]", phone: "+1234567890" },
billing: {
amount: 100,
currency: "USD",
country: "US",
description: "Test",
pricing_type: "fixed_price",
},
metadata: {},
call_back_url: "https://yourapp.com/success",
onPayment: (ref) => console.log(ref),
onClose: () => {},
onError: (err) => console.error(err),
};
shop100Pay.setup(charge, { maxWidth: "500px" });Next Steps
- Verify Payments — confirm transactions on your server before fulfilling orders
- Webhooks — receive real-time payment events on your backend
- 100pay.js SDK — server-side SDK for transfers, subaccounts, and more
Last updated on