collana pay JS Docs / default
Variable: default
constdefault: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
The full configuration object describing which providers to render, the target environment, and the callback handlers (onClick, onApprove, onCancel, onError).
Returns
An ExpressButtonsInstance with render(), teardown(), and teardownProvider() methods.
Example
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
The provider protocol identifier (e.g. "PayPal").
methodType
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
import { registerProvider } from './core/CollanaPay';
import { MyCustomProvider } from './providers/MyCustomProvider';
registerProvider('CustomProtocol', 'CustomMethod', MyCustomProvider);