Skip to content

collana pay JS Docs v0.1.0


collana pay JS Docs / ExpressButtonsConfig

Interface: ExpressButtonsConfig

Defined in: types.ts:1250

Top-level configuration object passed to ExpressButtons().

Remarks

Combines the list of provider button configurations with lifecycle callbacks and environment settings. The SDK renders all configured providers in parallel via Promise.allSettled.

Example

ts
const config: ExpressButtonsConfig = {
  environment: 'sandbox',
  locale: 'en-US',
  providers: [
    {
      providerProtocolType: 'PayPal',
      paymentMethodType: 'PayPalExpress',
      container: '#paypal-container',
      style: { color: 'gold', shape: 'rect' },
      options: { intent: 'capture', currencyCode: 'USD' },
    },
  ],
  onClick: async (identity) => {
    const order = await createOrder(identity);
    return { orderId: order.id, checkoutData: { id: order.checkoutId } };
  },
  onApprove: (data) => { window.location.href = `/confirm?order=${data.orderId}`; },
  onCancel: (identity) => { console.log('Cancelled', identity); },
  onError: (error) => { console.error(error); },
};

Extends

Properties

environment?

optional environment?: Environment

Defined in: types.ts:1257

Target environment.

Default Value

'sandbox'


locale?

optional locale?: string

Defined in: types.ts:1259

IETF locale tag applied to all provider SDKs (e.g. 'en-US').


onApprove

onApprove: (data) => void

Defined in: types.ts:1196

Called when the payment is approved by the shopper.

Parameters

data

ApprovalData

Approval details including order ID and optional payer info.

Returns

void

Inherited from

CallbackHandlers.onApprove


onCancel

onCancel: (identity) => void

Defined in: types.ts:1202

Called when the shopper cancels the payment flow.

Parameters

identity

ProviderIdentity

Identifies which provider was cancelled.

Returns

void

Inherited from

CallbackHandlers.onCancel


onClick

onClick: (identity, paymentMethodData?) => Promise<OrderResult>

Defined in: types.ts:1190

Called when the shopper clicks a payment button.

Parameters

identity

ProviderIdentity

Identifies which provider button was clicked.

paymentMethodData?

unknown

Provider-specific payment method data (Adyen state.data).

Returns

Promise<OrderResult>

A promise resolving to the created order result.

Remarks

The integrator should create an order on their backend and return an OrderResult. For Adyen providers, paymentMethodData contains the Adyen state.data which should be forwarded to the backend API call.

Inherited from

CallbackHandlers.onClick


onError

onError: (error) => void

Defined in: types.ts:1213

Called when an error occurs during the payment flow.

Parameters

error

PaymentError

Structured error with code, message, and provider identity.

Returns

void

Remarks

Provider rendering uses Promise.allSettled, so one provider's failure does not prevent other providers from rendering. Each failure triggers a separate onError call.

Inherited from

CallbackHandlers.onError


providers

providers: ProviderButtonConfig<ProviderKey>[]

Defined in: types.ts:1252

One or more provider button configurations to render.

CollanaPay SDK Documentation