This documentation is for preview purposes only.
Customize the Components SDK's appearance, render payment methods and form fields used for data collection.
- two options:
"default"(light mode) and"dark" - assets such as payment method icons adjust according to mode setting
...
Worldpay.components.init({
// ...other config
theme: "dark"
})
...You can specify the desired payment methods and layout.
Layout options:
accordiontabssolitary
You can apply custom CSS styles to the iframe for further visual customization.
You can disable the SDK hosted button and use triggers and lifecycle hooks to understand your customer's actions.
Worldpay.components.init({
// ...other config
advancedConfiguration: {
hideSubmitButton: true
}
})You can specify what information the SDK should collect from your customer. The SDK only displays the applicable fields for the selected APM, based on both your request and the APM's requirements
Worldpay.components.init({
// ...other config
advancedConfiguration: {
additionalFields: [
"name",
"email",
"phone",
"shippingAddress",
"billingAddress",
"accountHolderName",
"dateOfBirth",
"identityDocuments"
]
}
})| Parameter | Description |
|---|---|
"name" | Displays "First Name" and "Last Name". |
"email" | Displays "Email Address". |
"phone" | Displays "Telephone Number". |
"shippingAddress" | Displays grouped fields:
|
"billingAddress" | Displays grouped fields:
|
"accountHolderName" | Displays "Account Holder Name". |
"dateOfBirth" | Displays "Date of Birth". |
"identityDocuments" | Displays "CPF/CNPJ". |
The mapping between the fields displayed to your customer in the SDK and the fields required by the APMs API is done during payment submission. This ensures that all collected information is correctly formatted and transmitted to the payment provider according to their specifications.
You can 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. |
showQRCode | Function | Accepts method and QR code data (generated via a server-side call to the APM service) and displays it in the UI. Note: Only applicable for QR code-specific payment methods. |
resetProcessing | Function | Resets the SDK's processing state (clears the overlay, and re-enables interactivity). |
Worldpay.components.select('paypal')
Worldpay.components.submit()
Worldpay.components.showQRCode('pix', {
qrCode: 'iVBORw0KGgoAAAANSUhEUgAABbQAAAW0AQ...',
ervCode: '00020101021226930014br.gov.bcb.pix2571qrcode-h.pix.celcoin.com.br/...',
})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). |
You can initialize and embed the SDK multiple times on the same webpage.
Some Alternative Payment Methods (APMs), such as Pix and WeChat Pay, require your customer to complete the payment by scanning a QR code. The following outlines how to integrate this flow using the SDK:
Receive the QR code data: When initiating a payment with an APM that uses QR codes (e.g., Pix, WeChat Pay), the APMs API payment response will include a redirect field. This field contains the necessary data to generate and display the QR code.
Send the QR code to the SDK: Pass the redirect field value to the SDK using the designated method. The SDK will then render the QR code within the hosted iframe, making it visible to your customer.
Your customer scans the QR code: The shopper uses their mobile device to scan the QR code displayed in the iframe. The payment is then processed externally by the APM provider.
Monitor payment status: While your customer completes the payment, periodically check the status of the transaction using the appropriate API endpoint or webhook notification.
Redirect your customer upon completion: Once the payment status is confirmed as successful (or failed), redirect your customer to a final merchant-hosted page (e.g., order confirmation or error page).
- The SDK is responsible for displaying the QR code only. Payment status polling and final redirection must be handled by the merchant's integration.
- Ensure that your integration securely verifies the payment status before redirecting your customer.
The Checkout SDK supports Alternative Payment Methods (APMs) that allow for recurring payments. This includes Klarna, iDEAL, and SEPA. The following steps outline how to use the SDK for both initial and subsequent recurring payment transactions:
- Initial payment data collection: Use the SDK to collect your customer's payment details and initiate the first transaction as you would for a standard payment. The SDK will securely capture all required data for the APM.
- Storing recurring payment data: After the initial transaction is processed, Worldpay generates and stores the necessary information (such as payment tokens or mandates) required for future use.
- Retrieving data for subsequent payments: For any subsequent payment, you don't need to collect your customer's payment details again. Instead, retrieve the mandatory data for the recurring payment from our Events service.
- use the Events API to listen for the
token.createdevent - the event payload contains the payment token or other details that you can use to process future payments without further customer interaction
- use the Events API to listen for the
- Processing subsequent payments: Use the retrieved data to initiate subsequent payments through our APMs API. You only use the SDK for the initial collection of payment details
The hosted iframe ensures sensitive payment data never touches your servers. All communications between the SDK, iframe, and Worldpay are encrypted.
Our components work with all recent versions of major browsers
- Chrome
- Edge
- Firefox
- Safari