Components

Overview

The SDK provides individual components that can be used to build custom payment experiences. Access them via client.components.*.


Available Components

Component
Description

Show detailed invoice information

List and select payment methods

Add new card or bank account

Review and confirm payment

Display payment outcome


Using Components

All components share a common pattern:

// 1. Initialize the client
const client = new AlternativeClient({
  clientId: 'your-client-id',
  clientSecret: 'your-client-secret',
});

// 2. Create a component
const component = client.components.invoiceList({
  containerId: 'my-container',
  customerId: 'cus_xxx',
  onSelect: (invoice) => {
    console.log('Selected:', invoice);
  },
});

// 3. Later: cleanup
component.unmount();

Common Configuration

All components accept these base properties:

Property
Type
Required
Description

containerId

string

Yes

ID of the HTML element to mount into

theme

ThemeConfig

No

Custom theme (overrides client default)


Component Instance

Each component returns a ComponentInstance with these methods:


Building Custom Flows

Compose components to create custom payment experiences:


Next Steps

Explore individual component documentation for detailed configuration options and examples.

Last updated

Was this helpful?