Skip to content

collana pay JS Docs v0.1.0


collana pay JS Docs / default

Variable: default

const default: object

Defined in: index.ts:78

Type Declaration

ExpressButtons

ExpressButtons: (config) => ExpressButtonsInstance

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, the target environment, and the callback handlers (onClick, onApprove, 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',
    },
  ],
  environment: 'sandbox',
  onClick: async (identity) => {
    // create order on backend
    return { orderId: '123' };
  },
  onApprove: (data) => { console.log('Approved', data.orderId); },
  onCancel: (identity) => { console.log('Cancelled', identity.paymentMethodType); },
  onError: (error) => { console.error(error.code, error.message); },
});
await buttons.render();

registerProvider

registerProvider: (protocolType, methodType, factory) => void

Registers a provider factory in the global provider registry.

Built-in providers (e.g. PayPal) are registered automatically when src/index.ts is imported. Integrators only need to call this function to register custom or third-party providers.

Parameters

protocolType

ProviderProtocolType

The provider protocol identifier (e.g. "PayPal").

methodType

PaymentMethodType

The payment method identifier (e.g. "PayPalExpress").

factory

ProviderFactory

The provider class constructor to associate with the given protocol/method combination.

Returns

void

Nothing.

Example

ts
import { registerProvider } from './core/CollanaPay';
import { MyCustomProvider } from './providers/MyCustomProvider';

registerProvider('CustomProtocol', 'CustomMethod', MyCustomProvider);

CollanaPay SDK Documentation