Skip to main content
Hosted fields let you build a completely custom card form while keeping raw card numbers out of your DOM. Each field — card number, expiry, and CVV — renders inside a Therius-hosted iframe. Your JavaScript never sees the PAN; it only receives a one-time nonce that your server uses to complete the charge.

Set up the field containers

Add empty container elements to your form. Therius replaces each container with a secure iframe at runtime.

Initialize hosted fields

After the SDK is initialized, call sdk.hostedFields() with a map of field names to CSS selectors.
Each selector points to one of the container <div> elements above. The SDK injects an iframe into each container and the shopper types directly into it.

Collect a nonce on form submit

When the shopper submits the form, call sdk.createNonce() to tokenize the card data held in the iframes. The SDK returns a short-lived nonce — not the card number.
The nonce is single-use and expires after a short period. Create a new nonce for each payment attempt — do not reuse nonces from failed or abandoned attempts.

Charge the nonce on your server

Your server passes the nonce as card.nonceData.nonce when calling POST /payment/purchase.

Save the card for future payments

To vault the card during payment, add tokenize: true and a shopper.id to the server-side charge request:
The response includes a token the shopper can use for future one-click checkouts. See Saved Cards for the full returning-shopper flow.

Handle 3DS challenges

Some cards require a 3DS challenge before the payment can be authorized. Call sdk.authorize(nonce) in the browser instead of sending the nonce directly to your server, then handle any required action:
sdk.handleAction is the single entry point for all out-of-band steps — 3DS challenges, redirects, and voucher displays. You do not need separate code paths for different action types.