Experience the complete ProBuy checkout flow with our interactive demo. This demo demonstrates the proper architecture using @probuy/backend-sdk on your server.
HTML/JS merchant store
Secure API with SDK
Payment processing
Important: This demo requires a backend server. The API token must NEVER be exposed in frontend code.
# Create a new backend servermkdir probuy-demo-backendcd probuy-demo-backendnpm init -y
# Install dependenciesnpm install @probuy/backend-sdk express cors dotenvCreate server.js:
import express from 'express';import cors from 'cors';import { ProBuyBackendSDK } from '@probuy/backend-sdk';
const app = express();app.use(cors());app.use(express.json());
// Initialize SDKconst probuy = new ProBuyBackendSDK({ apiToken: process.env.PROBUY_API_TOKEN, environment: 'sandbox'});
// Create checkout endpointapp.post('/api/checkout/create', async (req, res) => { try { const session = await probuy.createCheckoutWithRedirectUrl(req.body); res.json({ success: true, checkout_id: session.checkout_id, redirect_url: session.redirect_url }); } catch (error) { res.status(500).json({ success: false, error: error.message }); }});
app.listen(3001, () => { console.log('Backend server running on http://localhost:3001');});Create .env file:
# Get your API token from https://supplier.probuy.devPROBUY_API_TOKEN=your-api-token-herePROBUY_ENVIRONMENT=sandboxThe frontend demo should call your backend server instead of ProBuy directly:
// Frontend code (runs in browser)async function createCheckout(orderData) { // Call YOUR backend, not ProBuy const response = await fetch('http://localhost:3001/api/checkout/create', { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(orderData) });
const result = await response.json();
if (result.success) { // Redirect to ProBuy checkout window.location.href = result.redirect_url; }}# Terminal 1: Run backend servercd probuy-demo-backendnode server.js
# Terminal 2: Run frontend (if using local server)cd integration-docsnpm run dev
# Open http://localhost:3000/store/index.htmlPure HTML/JS that can be deployed anywhere. Calls your backend API for checkout.
Node.js server with @probuy/backend-sdk. API token never exposed to users.
This architecture is secure and ready for production deployment.
Here's the complete order data structure your backend needs to send:
const orderData = { order_reference_id: 'ref-' + Date.now(), order_number: 'ORD-' + Date.now(), currency: 'SAR', total_amount: 1500, shipping_amount: 50, tax_amount: 225,
item: { name: 'iPhone 15 Pro', description: '256GB Space Black', type: 'Physical', reference_id: 'iphone-15-pro-256', sku: 'IPH15P256SB', quantity: 1, unit_price: 1225, tax_amount: 225, discount_amount: 0, total_amount: 1500 },
consumer: { first_name: 'Ahmed', last_name: 'Ali', phone_number: '+966501234567' },
country_code: 'SA',
merchant_url: { success: 'http://localhost:3000/store/success.html', failure: 'http://localhost:3000/store/failure.html', cancel: 'http://localhost:3000/store/cancel.html' },
billing_address: { city: 'Riyadh', country_code: 'SA', first_name: 'Ahmed', last_name: 'Ali', line1: '123 King Fahd Road', phone_number: '+966501234567', region: 'Riyadh' },
shipping_address: { // Same as billing or different }};After testing the demo, you're ready to integrate ProBuy into your own website. Check out our comprehensive documentation: