Skip to main content

Configuration

Odus Elements is configured at two levels:

  • Global — via the ElementsConfig object passed to the OdusElements constructor.
  • Per-element — via MountOptions passed to update() after mounting individual elements.

ElementsConfig

OptionTypeRequiredDescription
apiKeystringYour Odus publishable key
environment'test' | 'live'API environment
returnUrlstringURL to redirect to after 3DS authentication or other redirect flows
localeLocaleLanguage for all elements (auto-detected by default)
callbacksCallbacksPayment lifecycle event handlers
additionalPaymentMethodsAdditionalPaymentMethodsExpress payment method config (e.g., Apple Pay)
const checkout = new OdusElements({
apiKey: 'pk_test_your_publishable_key',
environment: 'test',
returnUrl: 'https://your-website.com/checkout/return',
locale: 'en',
callbacks: {
onPaymentSucceeded: (result) => console.log('Succeeded', result),
onPaymentFailed: (error) => console.error('Failed', error),
onActionRequired: (url) => {
window.location.href = url;
},
},
});

Callbacks

Handle payment lifecycle events by passing callback functions in the callbacks option.

onPaymentSucceeded

Fires when a payment is successfully authorized. Does not fire for redirect-based flows (PayPal, 3DS).

onPaymentSucceeded: (result) => {
// result is the payment status: 'authorized'
window.location.href = '/checkout/success';
};

onPaymentFailed

Fires when a payment fails. Does not fire for redirect-based flows.

onPaymentFailed: (result) => {
// result is a user-friendly error message
console.error('Payment failed:', result);
};

onActionRequired

Fires when a payment requires a redirect (e.g., 3DS authentication, PayPal authorization).

onActionRequired: (redirectUrl) => {
window.location.href = redirectUrl;
};
info

Unlike Drop-in Checkout, Elements has no manualActionHandling toggle — onActionRequired always fires when a redirect is needed. Handle the URL however you like (navigate, open in a modal, etc.).

Localization

Elements auto-detects the customer's browser language by default. Override this globally in ElementsConfig:

const checkout = new OdusElements({
// ...other options
locale: 'fr',
});

Supported Locales

CodeLanguage
enEnglish
frFrench
deGerman
esSpanish
itItalian
plPolish
ptPortuguese
trTurkish
csCzech
nlDutch
skSlovak

Additional Payment Methods

Configure express payment methods through the additionalPaymentMethods option.

Apple Pay

const checkout = new OdusElements({
// ...other options
additionalPaymentMethods: {
applePay: {
displayName: 'My Store',
countries: ['US', 'GB'],
requiredBillingContactFields: ['postalAddress'],
requiredShippingContactFields: ['email', 'name'],
},
},
});
OptionTypeDescription
displayNamestringName shown in the Apple Pay payment sheet
countriesstring[]ISO country codes where Apple Pay is available
requiredBillingContactFieldsApplePayContactField[]Billing fields to request (Apple docs)
requiredShippingContactFieldsApplePayContactField[]Shipping fields to request (Apple docs)

ApplePayContactField values: email, name, phone, postalAddress, phoneticName

note

PayPal requires no additional configuration — simply mount the express.payPal element and it renders automatically after associatePayment() is called, provided the payment supports PayPal.

Per-Element Options (MountOptions)

Customize individual elements via update() after mounting:

checkout.elements.contact.email.mount('#email-container');
checkout.elements.contact.email.update({
locale: 'fr',
disabled: true,
initialValue: 'user@example.com',
});
OptionTypeDescription
localestringOverride the global locale for this element
disabledbooleanRender the element in a disabled state
initialValuevariesPre-fill the element (type depends on the element)
callbacksobjectPer-element event callbacks

Per-Element Events

Register event callbacks using on():

checkout.elements.contact.email.on('change', (data) => console.log('changed', data)).on('blur', () => console.log('blurred'));
EventDescription
changeElement value changed
blurElement lost focus
focusElement gained focus
errorElement encountered a validation error
readyElement finished rendering and is interactive