DRUO
Get started
Components

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.

html
<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>
ElementRendersNotes
institution-selectorSearch + result listDebounced 220 ms, six results, country tag
account-fieldsThe selected institution's dynamic fieldsComes from institution_fields: label, placeholder, instructions, length, input mode, validator
account-fields verification codeExtra 6-digit fieldAppears only when the institution or account requires it — same idea as a card CVV
alias (payment-key)Payment key inputLive resolution, Key found · Chase ••••4821
logo, reward-badge, trust, securityTrust chromeSame 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

CallPurpose
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.

javascript
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

URLUse
https://js.druo.com/v1/components.jsRecommended. Tracks the latest 1.x release, cached 5 minutes.
https://js.druo.com/v1.2.0/components.jsPinned, immutable build. Use with integrity= when your CSP requires SRI.

Going live from sandbox:

  1. 1Swap pk_test_… for your pk_live_… publishable key — nothing else in the snippet changes.
  2. 2Send us the exact origins of your checkout pages; publishable keys only work on allowlisted origins.
  3. 3Add https://js.druo.com to your CSP script-src, and to frame-src / connect-src if you use secureFields, the modal auth presentation, or express buttons.
  4. 4Confirm the intent server-side with the resultToken and an Idempotency-Key before fulfilling the order — never treat the browser success event as settlement.
  5. 5Handle the returning-payer paths: Druo.retrieveIntent after a reload or redirect, and Druo.verifyMicrodeposits for brand-new accounts.