Skip to main content

PaySightSDK.createWidget

const widget = PaySightSDK.createWidget({
  targetId: string;
  config: WidgetConfig;
  onReady?: () => void;
  onError?: (error: Error) => void;
  onMessage?: (message: WidgetMessage) => void;
  minHeight?: number;
  iframeId?: string;
  applePayContainerId?: string;   // default: 'apple-pay-slot'
  googlePayContainerId?: string;  // default: 'google-pay-slot'
});

Returns

MethodDescription
update(updates)Merge partial config at runtime
submitPayment()Trigger card/wallet checkout
submitUpsell()Trigger upsell charge (usePreviousPaymentMethod mode)
subscribe(handler)Add onMessage listener; returns unsubscribe function
destroy()Tear down iframe and listeners

submitPayment / submitUpsell

Use when hidePaymentButton: true or when you want a host-controlled CTA.
document.getElementById('pay-btn').onclick = () => widget.submitPayment();
document.getElementById('upsell-btn').onclick = () => widget.submitUpsell();
Calling submitPayment() during upsell mode (or submitUpsell() during checkout) emits ERROR with code INVALID_MODE.

update

widget.update({
  singlePurchase: true,
  amount: 39.99,
  customer: { email: 'new@example.com' },
});
Config updates are sent to the iframe as CONFIG_UPDATE. Listen for CONFIG_UPDATE_SUCCESS.

subscribe

const unsubscribe = widget.subscribe((msg) => {
  if (msg.type === 'PAYMENT_SUCCESS') handleSuccess(msg.payload);
});
// later: unsubscribe();

CDN script

<script src="https://payment.paysight.io/widget-sdk.js"></script>
Global: PaySightSDK.createWidget. Use environment: 'sandbox' or environment: 'production' in config to target the matching widget endpoint.