PaySightSDK.createWidget({
targetId: 'checkout-widget',
config: {
productId: YOUR_PRODUCT_ID,
sessionId: 'checkout-' + Date.now(),
environment: 'sandbox',
amount: 0,
savePaymentMethod: true,
shopify: {
showCart: true,
cart: [
{
quantity: 1,
variant: YOUR_VARIANT_ID,
product: YOUR_SHOPIFY_PRODUCT_ID,
price: 29.99,
name: 'Main product',
},
],
shipping: {
product: YOUR_SHIPPING_PRODUCT_ID,
name: 'Standard shipping',
price: 4.95,
},
},
customer: {
email: 'customer@example.com',
firstName: 'Jane',
lastName: 'Doe',
country: 'US',
},
},
onMessage: (msg) => {
if (msg.type === 'CART_READY') {
console.log('Cart total:', msg.payload.total);
}
if (msg.type === 'PAYMENT_SUCCESS') {
sessionStorage.setItem('paysightSession', msg.payload?.paysightSession ?? '');
window.location.href = '/upsell';
}
},
});