Elements & advanced APIs
Compose your own layout with Elements, post-mount APIs, express buttons and going live.
Elements — compose your own layout
When you want DRUO's data handling but your own layout, mount individual elements instead of the whole component. Each element owns its input, validation and encryption; your page never touches the value.
<div id="bank"></div>
<div id="fields"></div>
<div id="alias"></div>
<script>
const els = Druo.elements({ componentId: "cmp_9f2" });
const institution = els.create("institution-selector").mount("#bank");
const fields = els.create("account-fields", { verificationCode: "auto" }).mount("#fields");
const alias = els.create("alias").mount("#alias");
els.on("change", (s) => (payBtn.disabled = !s.complete));
</script>| Element | Renders | Notes |
|---|---|---|
institution-selector | Search + result list | Debounced 220 ms, six results, country tag |
account-fields | The selected institution's dynamic fields | Comes from institution_fields: label, placeholder, instructions, length, input mode, validator |
account-fields verification code | Extra 6-digit field | Appears only when the institution or account requires it — same idea as a card CVV |
alias (payment-key) | Payment key input | Live resolution, Key found · Chase ••••4821 |
logo, reward-badge, trust, security | Trust chrome | Same markup as the slots in the section above |
The account-fields element re-renders automatically when institution-selector changes. Element groups terminate through the same tokenize contract as the full component, returning resultToken and intentUuid.
See every element and layout live at /elements in the demo app.
Post-mount and out-of-band APIs
| Call | Purpose |
|---|---|
Druo.retrieveIntent({ intentUuid }) or (resultToken) | Reads the current intent status. Use after a reload, a redirect return, or before confirming server-side. |
handle.resume(intentUuid) | Re-enters a pending authentication on a mounted component: the outstanding next action (passkey, code, hosted frame) is presented again and the flow finishes through the normal success / error events. |
Druo.handleNextAction(ref) | Same lookup without a mounted component; returns the pending nextAction so the merchant can decide where to present it. |
Druo.verifyMicrodeposits(intentUuid, { amounts: [12, 47] }) | Completes a brand-new-account verification on a later visit; { descriptorCode: "SM11AA" } is also accepted. |
handle.open() | Opens the modal/drawer presentation programmatically in button mode. |
Express buttons
Druo.expressButtons(target, options) renders up to maxButtons (default 2) of the payer's known accounts as one-tap buttons, DRUO's counterpart to wallet express checkout. A click opens the full component in a modal with that account preselected; if no account is known it falls back to the standard DRUO button.
const express = Druo.expressButtons("#express", {
intent: "buy_now", amount: 4820, currency: "USD",
componentId: "cmp_live_9f2", merchantCustomerRef: "cust_8891", maxButtons: 2,
});
express.on("success", (p) => post("/orders", p));Script versions and going live
| URL | Use |
|---|---|
https://js.druo.com/v1/components.js | Recommended. Tracks the latest 1.x release, cached 5 minutes. |
https://js.druo.com/v1.2.0/components.js | Pinned, immutable build. Use with integrity= when your CSP requires SRI. |
Going live from sandbox:
- 1Swap
pk_test_…for yourpk_live_…publishable key — nothing else in the snippet changes. - 2Send us the exact origins of your checkout pages; publishable keys only work on allowlisted origins.
- 3Add
https://js.druo.comto your CSPscript-src, and toframe-src/connect-srcif you usesecureFields, the modal auth presentation, or express buttons. - 4Confirm the intent server-side with the
resultTokenand anIdempotency-Keybefore fulfilling the order — never treat the browsersuccessevent as settlement. - 5Handle the returning-payer paths:
Druo.retrieveIntentafter a reload or redirect, andDruo.verifyMicrodepositsfor brand-new accounts.

