Live demo
Open the interactive Shopify cart demo in the sandbox playground.
Page 1 — cart checkout
Page 2 — cart upsell
Cart events
Listen forCART_READY and CART_UPDATE to sync order summary on your host page:
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Cart checkout on page 1 and cart upsell on page 2
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';
}
},
});
PaySightSDK.createWidget({
targetId: 'upsell-widget',
config: {
productId: YOUR_PRODUCT_ID,
sessionId: 'upsell-' + Date.now(),
environment: 'sandbox',
amount: 0,
usePreviousPaymentMethod: true,
upsell: {
upsellId: 'extended-warranty',
initialPaymentSession: sessionStorage.getItem('paysightSession'),
upsellButton: { text: 'Add protection plan' },
},
shopify: {
cart: [
{
quantity: 1,
variant: YOUR_UPSELL_VARIANT_ID,
product: YOUR_UPSELL_PRODUCT_ID,
price: 9.99,
name: 'Protection plan',
},
],
},
customer: { email: 'customer@example.com' },
},
onMessage: (msg) => {
if (msg.type === 'PAYMENT_SUCCESS' && msg.payload?.mode === 'upsell') redirectToThankYou();
if (msg.type === 'DUPLICATE_TRANSACTION') redirectToThankYou();
if (msg.type === 'PAYMENT_ERROR' && msg.payload?.mode === 'upsell') {
alert(msg.payload?.message ?? 'Upsell failed');
}
},
});
CART_READY and CART_UPDATE to sync order summary on your host page:
if (msg.type === 'CART_UPDATE') {
const { subtotal, shipping, total, currency } = msg.payload;
updateOrderSummary({ subtotal, shipping, total, currency });
}