Last updated: 27 May 2026 | Change log
Our Components SDK exposes its functionality through a global namespace and a set of core methods.
| Parameter | Type | Description |
|---|---|---|
Worldpay | Object | Global namespace attached to the window object. |
components | Object | Components product namespace. |
init | Function | Initialization method accepting a config object. |
Worldpay.components.init(config)Triggers allow you to programmatically interact with the Payment UI, such as submitting forms or selecting specific payment methods without direct user action, or displaying QR codes for supported payment methods.
| Parameter | Type | Description |
|---|---|---|
select | Function | Selects a payment method using a method parameter. |
submit | Function | Submits the payment form programmatically. |
continue | Function | Accepts method and data (generated via a server-side call to the APM service) and allows the SDK to display the next available step for the selected payment method. Note: Only applicable for QR code-specific payment methods. |
resetProcessing | Function | Resets the SDK's processing state (clears the overlay, and re-enables interactivity). |
const components = Worldpay.components.init(config)
components.select('swish')
components.submit()
// WeChat Pay QR code flow
components.continue('wechatpay', {
qrCode: 'iVBORw0KGgoAAAANSUhEUgAABbQAAAW0AQ...'
})
// Pix flow with QR and transaction code
components.continue('pix', {
qrCode: 'iVBORw0KGgoAAAANSUhEUgAABbQAAAW0AQ...',
transactionCode: '00020101021226930014br.gov.bcb.pix2571qrcode-h.pix.celcoin.com.br/...',
})
// Swish QR code flow
components.continue('swish', {
qrCode: 'iVBORw0KGgoAAAANSUhEUgAABbQAAAW0AQ...'
})
// Swish phone notification flow
components.continue('swish') Lifecycle hooks enable you to respond to various stages of the payment UI, attach custom interactivity, and handle events such as loading, selection, success, or errors.
| Parameter | Type | Description |
|---|---|---|
onLoad | Function | Called when the payment UI is loaded. |
onSelect | Function | Called when a payment method is selected (with method and selector parameters). |
onSuccess | Function | Called when the form is successfully submitted (with session and method parameters). |
onError | Function | Called when a submission fails (with error, method, selector parameters). |
Worldpay.components.init(config)
.onLoad(() => { /* hide loading animation */ }),
.onSelect((method, selector) => { /* handle selection */ }),
.onSuccess((session, method) => { /* handle success by passing the session to own endpoint via server-side call */ }),
.onError((error, method, selector) => { /* handle error */ })The config object is crucial for initializing the SDK and customizing the payment experience.
| Parameter | Type | Required? | Description |
|---|---|---|---|
id | string | Checkout merchant ID. | |
baseUrl. | string | The URL to our try/live environment. | |
selector | string | DOM selector for payment UI container. | |
transaction | Object | Transaction details. | |
theme | string | Theme: default or dark. | |
styles | Object | Custom styling configuration. | |
elements | Array Object | Controls rendering of payment elements. | |
advancedConfiguration | Object | Advanced options. | |
loadingSkeleton | boolean | Enables loading animation. |
const config = {
id: "your-checkout-id",
baseUrl: "https://try.access.worldpay-bsh.securedataplatform.com",
selector: "#checkout-container",
transaction: {
amount: 2500,
currency: "USD",
countryCode: "US"
},
theme: "default",
styles: {
':root': {
'--base-font-size': '16px',
'--font-family': 'Inter, Helvetica, Arial, sans-serif',
'--color-primary': '#1b1b6f',
'--color-background': '#ffffff',
'--color-error': '#dd1308',
'--color-content-primary': '#17171c',
'--color-content-secondary': '#6a6e87'
},
'.Item': {
'padding': '2rem 1rem',
'border': '1px solid grey'
}
},
elements: [
{
element: "accordion",
methods: [
{ name: "paypal" },
]
}
],
advancedConfiguration: {
additionalFields: ["name", "email", "shippingAddress", "billingAddress"]
},
loadingSkeleton: true
};
Worldpay.components.init(config)
.onSuccess((session) => { /* handle success */ }),
| Parameter | Type | Required? | Description |
|---|---|---|---|
element | string | Specifies the element type for this UI section. Supported values: accordion, tabs, or solitary. | |
methods | Array Object | List of payment methods for this element. Each object should specify a supported method key. |
Worldpay.init({
// ...other config
elements: [
{
element: 'accordion'
methods: [
{ name: 'paypal' },
{ name: 'sepa' },
{ name: 'klarna' }
]
}
]
})| Parameter | Type | Required? | Description |
|---|---|---|---|
amount | number | Transaction amount. | |
currency | string | ISO 4217 currency code (e.g., "USD", "EUR"). | |
countryCode | string | ISO 3166 country code (e.g., "US", "GB"). |
Worldpay.init({
// ...other config
transaction: {
amount: 10000,
currency: 'GBP',
countryCode: 'GB',
},
})Customizes appearance of the payment UI. Accepts CSS-in-JS style properties.
| Parameter | Type | Required? | Description |
|---|---|---|---|
:root | Object | CSS variables for theming and global styles. | |
Any selector | Object | Any valid CSS selector supported. |
Worldpay.init({
// ...other config
styles: {
':root': {
'--base-font-size': '16px',
'--font-family': 'Inter, Helvetica, Arial, sans-serif',
'--color-primary': '#1b1b6f',
'--color-background': '#ffffff',
'--color-error': '#dd1308',
'--color-content-primary': '#17171c',
'--color-content-secondary': '#6a6e87'
},
'.Item': {
padding: '2rem 1rem',
border: '1px solid grey',
},
},
})| Parameter | Type | Required? | Description |
|---|---|---|---|
hideSubmitButton | boolean | Renders the form without a submit button. Allows you to use submit trigger with your own custom Submit button. | |
additionalFields | Array string | Renders additional fields such as name, email, dob, phone, shippingAddress, billingAddress, identityDocuments |
Worldpay.init({
// ...other config
advancedConfiguration: {
hideSubmitButton: true,
additionalFields: ['name', 'email'],
},
})