Skip to content

Express Docs v0.1.0


Express Docs / ExpressButtons

Function: ExpressButtons()

ExpressButtons(config): ExpressButtonsInstance

Defined in: src/core/CollanaPay.ts:424

Creates an ExpressButtonsInstance that manages one or more express checkout button providers.

The returned instance is inert until render() is called. Provider SDK loading, telemetry initialization, and button rendering all happen lazily inside render().

Parameters

config

ExpressButtonsConfig

The full configuration object describing which providers to render and the callback handlers (onClick, onCancel, onError).

Returns

ExpressButtonsInstance

An ExpressButtonsInstance with render(), teardown(), and teardownProvider() methods.

Example

ts
const buttons = CollanaPay.ExpressButtons({
  providers: [
    {
      providerProtocolType: 'PayPal',
      paymentMethodType: 'PayPalExpress',
      container: '#paypal-btn',
    },
  ],
  onClick: async (identity) => {
    const resp = await fetch('/api/orders', { method: 'POST' });
    const data = await resp.json();
    return data.checkoutData; // base64-encoded string from backend
  },
  onCancel: (identity) => { console.log('Cancelled', identity.paymentMethodType); },
  onError: (error) => { console.error(error.code, error.message); },
});
await buttons.render();

CollanaPay SDK Documentation