Integrate Stablio's crypto payment widget into your website checkout flow in just a few minutes. This guide walks you through the complete integration process.
The Web Checkout integration allows you to embed our payment widget directly into your website, providing a seamless payment experience for your customers without leaving your site.
Customers don't need to connect their wallet and put their funds at risk.
Receive instant payment confirmations via events and webhooks
Works seamlessly on all devices including mobile
First, include our JavaScript SDK in your checkout page by adding this script tag to your HTML head:
<!-- Add this to your HTML head -->
<script src="https://cdn.jsdelivr.net/gh/ReasonZx/crypto-payments-widget@2.3.0/dist/crypto-payments-widget.js"></script>
Add a div with id 'payment-container' where you want the payment widget to appear. This container should have at least 400px by 400px of space:
<div id="payment-container"></div>
Initialize the payment widget with your vendor ID and payment details:
const widget = new PaymentWidget({
type: 'defaultPayment',
vendorID: 'your_vendor_id', // Your Stablio vendor ID (string)
amount: 49.99, // Payment amount (number)
currency: 'USD', // Currency: 'USD' or 'EUR' [optional] string defaults to 'USD'
userID: 'customer123', // Customer identifier [optional] string
webhook: 'https://your-site.com/webhook', // Webhook URL for server notifications [optional] string
});
Set up event listeners to track payment status changes and update your UI accordingly or receive notifications via webhooks :
document.getElementById('payment-container').addEventListener('payment_status', (event) => {
const { status, data } = event.detail;
switch(status) {
case 'payment_completed':
console.log(`Payment completed! User: ${data.userID}`);
break;
case 'payment_expired':
console.log(`Payment expired! User: ${data.userID}`);
break;
case 'payment_pending':
console.log(`Payment pending! Address: ${data.address}`);
break;
}
});
The PaymentWidget constructor accepts the following options:
| Parameter | Type | Required | Description |
|---|---|---|---|
| type | string | Yes | Set to 'defaultPayment' for web checkout |
| vendorID | string | Yes | Your unique vendor identifier from the dashboard |
| amount | number | Yes | The payment amount |
| currency | string | No | Currency code: 'USD' or 'EUR' (defaults to 'USD') |
| userID | string | No | Customer identifier for tracking payments |
| webhook | string | No | URL to receive server-side payment notifications |
| container | element | No | HTML element or element ID to render the widget (defaults to element with ID 'payment-container') |
| chains | string[] | No | Array of supported blockchains: ['solana', 'base'] | ['solana'] | ['base']. (defaults to the chains selected in Stablio's dashboard) |
The payment widget emits the following event types:
| Event Status | Description | Data Payload |
|---|---|---|
| payment_completed | Payment has been successfully completed | {userID, timestamp} |
| payment_pending | Payment has been initiated but not yet confirmed | {userID, address, timestamp} |
| payment_expired | Payment time window has expired | {address} |