SDKs
checkout.js (website)
Open the RazCrypto checkout as a popup on your own website. The customer never leaves your page. Works with plain HTML, React, Vue, Next.js, Angular and any other framework.
- Script:
https://razcryptogateway.com/v1/checkout.js(always the latest 1.x) - npm:
@razcrypto/checkout1.0.4 · TypeScript types included - Size: about 3 KB gzip
- Key in the browser: publishable key
pk_…, or thecheckout_urlfrom your server - Download: razcrypto-js-checkout-sdk.zip · Source on GitHub · MIT
Building a mobile app? checkout.js is for web pages. Use the Flutter,
Android or React Native SDK instead.
1. Install
Script tag (no build step)
HTML
<script src="https://razcryptogateway.com/v1/checkout.js"></script>npm (React, Vue, Next.js, any bundler)
Shell
npm install @razcrypto/checkoutJavaScript
import { open, preload } from '@razcrypto/checkout';From the download (local / self-hosted copy)
Shell
curl -L -o razcrypto-js-checkout-sdk.zip https://razcryptogateway.com/downloads/razcrypto-js-checkout-sdk.zip
mkdir razcrypto-checkout && unzip razcrypto-js-checkout-sdk.zip -d razcrypto-checkout
cd razcrypto-checkout && npm install && npm run build # outputs dist/The checkout itself still opens on https://razcryptogateway.com; only the small loader script is served from your copy.
Pin a version (Subresource Integrity)
HTML
<script src="https://razcryptogateway.com/v1/checkout.1.0.4.js"
integrity="sha384-9IcZWrTDISi9b0R6/UiT0nnZe+oIXIw/yniql5sEgyjb+iPo+0uXuNIdu7VpNMCH"
crossorigin="anonymous"></script>Versioned files never change. The unversioned /v1/checkout.js cannot carry an integrity hash.
2. Server: create the payment
Your server creates the payment with the secret key and sends payment_id (or checkout_url) to the page. See
PHP / Laravel, Node.js or Python.
JavaScript
// Node.js example: POST /api/pay
const p = await rc.payments.create({ amount: '49.00', currency: 'USD', reference_id: order.id }, { idempotencyKey: order.id });
res.json({ payment_id: p.id, checkout_url: p.checkout_url });3. Open the checkout
HTML
<button id="pay">Pay with crypto</button>
<script src="https://razcryptogateway.com/v1/checkout.js"></script>
<script>
document.getElementById('pay').onclick = async () => {
const r = await fetch('/api/pay', { method: 'POST' }).then((x) => x.json());
RazCrypto.open({
checkout_url: r.checkout_url, // or: key: 'pk_live_…', payment_id: r.payment_id
locale: 'en', // or 'hi'
async onSuccess(res) {
// res = { payment_id, reference_id, status, signature } → verify on your server
await fetch('/api/pay/verify', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(res) });
location.href = '/thank-you';
},
onPending(res) { /* on-chain, waiting for confirmations */ },
onClose() { /* closed without paying */ },
onError(err) { console.error(err.code, err.message); },
});
};
</script>React
tsx
import { open, preload } from '@razcrypto/checkout';
import { useEffect } from 'react';
export function PayButton({ orderId }: { orderId: string }) {
useEffect(() => preload(), []); // opens instantly on click
const pay = async () => {
const r = await api.createPayment(orderId);
open({ checkout_url: r.checkout_url, onSuccess: (res) => api.verify(res) });
};
return <button onClick={pay}>Pay with crypto</button>;
}Pay button without code
Create a Pay button in the dashboard and paste:
HTML
<script src="https://razcryptogateway.com/v1/checkout.js"></script>
<button data-razcrypto-button="BUTTON_ID">Pay</button>4. Verify and fulfil on the server
- Check
res.signaturewithCheckoutSignature::isValid(PHP),isValidCheckoutSignature(Node) oris_valid_checkout_signature(Python), using your webhook signing secret. - Ship only after
payments.retrieve(id)returnspaidor the verifiedpayment.paidwebhook.
What the customer sees
- Desktop: a two-column window: your brand and amount on the left, the steps on the right.
- Phone: full screen with your brand header and a sticky action bar.
- Network → coin → QR, amount and address (or "Open in MetaMask / Trust").
- On success the window turns green,
onSuccessruns, and about 2.6 seconds later it closes by itself (onCloseis not called after a success). - Esc asks before closing an unfinished payment.
Options
| Option | Use |
|---|---|
checkout_url | The URL from your server (recommended) |
key + payment_id | Publishable key + payment id. open() refuses secret keys. |
locale | 'en' or 'hi' |
onSuccess(res) · onPending(res) · onClose() · onError(err) | Callbacks |
payHost / data-pay-host | Only for staging or a self-hosted gateway |
data-preload="false" | Turn off the automatic warm-up on the script tag |
Full checkout guide (hosted page, popup, custom UI): Checkout.