API Documentation
The Zoksh Embed.js library provides a simple and efficient way to integrate crypto payment functionality directly into your website or web application.
Integration
- Include the Embed.js script:
<script src="https://widget.zoksh.com/public/embed.js"></script>
- Create a container for the widget:
<div id="zoksh-payment-widget"></div>
- Initialize the payment widget:
window.zoksh.init({
publicKey: 'YOUR_PUBLIC_KEY',
amount: 100,
currency: 'USD',
cryptocurrency: 'BTC',
description: 'Payment for Product X',
orderId: 'order_123',
customerEmail: 'customer@example.com',
successUrl: 'https://your-website.com/success',
cancelUrl: 'https://your-website.com/cancel',
// Add other configuration options here (see below)
});
Configuration Options
- publicKey: (Required) Your unique public API key.
- amount: (Required) The amount to be paid in the specified currency.
- currency: (Required) The currency of the payment (e.g., 'USD', 'EUR', 'GBP').
- cryptocurrency: (Required) The cryptocurrency to be paid (e.g., 'BTC', 'ETH', 'USDT').
- description: (Optional) A description of the payment.
- orderId: (Optional) A unique identifier for the order.
- customerEmail: (Optional) The customer's email address.
- successUrl: (Optional) The URL to redirect the user to upon successful payment.
- cancelUrl: (Optional) The URL to redirect the user to if the payment is canceled.
- showNetworkSelector: (Optional) Whether to show the network selector for the chosen * cryptocurrency (default: true).
- showCurrencySelector: (Optional) Whether to show the cryptocurrency selector (default: true).
- locale: (Optional) The language to display the widget in (e.g., 'en', 'es', 'fr').
- theme: (Optional) Customize the color scheme of the widget (e.g., 'light', 'dark').
- customStyles: (Optional) Apply custom CSS styles to the widget.
Events
The Embed.js library provides events that you can listen to for actions such as payment success, payment failure, and widget close.
- zoksh.on('paymentSuccess', (data) => { ... });
- zoksh.on('paymentFailure', (error) => { ... });
- zoksh.on('widgetClose', () => { ... });
Example
<!DOCTYPE html>
<html>
<head>
<title>Zoksh Embed.js Example</title>
</head>
<body>
<div id="zoksh-payment-widget"></div>
<script src="https://widget.zoksh.com/public/embed.js"></script>
<script>
window.zoksh.init({
publicKey: 'YOUR_PUBLIC_KEY',
amount: 100,
currency: 'USD',
cryptocurrency: 'BTC',
description: 'Payment for Product X',
orderId: 'order_123',
customerEmail: 'customer@example.com',
successUrl: 'https://your-website.com/success',
cancelUrl: 'https://your-website.com/cancel'
});
// Handle payment success event
window.zoksh.on('paymentSuccess', (data) => {
console.log('Payment successful:', data);
// Process successful payment (e.g., update order status, send confirmation email)
});
// Handle payment failure event
window.zoksh.on('paymentFailure', (error) => {
console.error('Payment failed:', error);
// Handle payment failure (e.g., display an error message to the user)
});
</script>
</body>
</html>
Note
Replace the placeholder values (e.g., YOUR_PUBLIC_KEY) with your actual API credentials. Customize the configuration options to match your specific requirements. Refer to the official Zoksh Embed.js documentation for the most up-to-date information, including a complete list of available configuration options, advanced usage examples, and support resources. This page provides a comprehensive overview of the Zoksh Embed.js library, including basic integration, configuration options, event handling, and an example implementation.