Field Types
Creating and Mounting
OzVault.create() is the async static factory — call it once when your checkout loads. It resolves once the session is initialized; mount elements immediately after. The vault is ready to tokenize once onReady fires (or vault.isReady === true). Gate your submit button on both vault readiness and field readiness.
<div>. Just make sure the wrapper has visible width and is not hidden with overflow: hidden or height: 0, or the field will be invisible.
You can also pass element options at creation time:
createElement Options
Tokenizing
CallcreateToken() after the user has filled all fields. The SDK transmits the field values directly to the Ozura Vault API — raw data never passes through your code.
createToken options
TokenResponse
cvcSession is always present on a successful tokenization. The SDK validates this field before resolving createToken() — if it is absent the promise rejects with an OzError (errorCode: 'server'), which would indicate a vault misconfiguration. Always forward both token and cvcSession to your charge endpoint:cvcSession lifecycle. The cvcSession is a short-lived vault credential that allows your server to retrieve the CVC value during a cardSale call. It shares the parent session TTL (default 30 minutes). It is safe to briefly persist it server-side — e.g. in a Redis key with a short TTL, or in a signed server-session — between the tokenization call and the charge call (seconds to minutes is fine). Do not store it long-term or log it. The vault invalidates the CVC credential after it is consumed by cardSale, so it is single-use.BillingDetails
state to its standard 2-letter abbreviation for US and Canadian addresses. Full names (e.g. "California", "British Columbia") and 2-letter codes are both accepted. For country: 'US', the state must be a valid US state, territory (PR, GU, VI, AS, MP), or military address code (AE, AP, AA) — other values are rejected. For country: 'CA', the state must be a valid Canadian province code.
Events
Each element emits events you can listen to with.on():
The expiry
onChange event includes month and year values. These are parsed from the masked expiry input and delivered to your handler for display purposes (e.g. showing the detected expiry date). If your PCI scope requires zero cardholder data on the merchant page, do not read or log these fields.Gating the submit button
The vault and each field iframe load independently. Gate your submit button on both:- Vault readiness — the
onReadycallback (fires when the vault is ready to tokenize) - Field readiness — each field’s
'ready'event (fires when the iframe loaded and is interactive) pluschangeevents for completion
Teardown
When the checkout component unmounts, callvault.destroy() to remove all iframes and listeners. In vanilla JS use a cancel flag to handle the async nature of OzVault.create():
Auto-Advance Focus
Elements automatically advance focus from one field to the next on completion:- When card number is complete and valid → focus moves to expiry
- When expiry is complete and valid → focus moves to CVV
Card Brand Detection
ThecardNumber element detects the card brand as the user types and emits it via change:
Imperatively Managing Elements
Full End-to-End Example (Vanilla JS + Express)
A complete working example: HTML page with card fields, Express backend with/api/oz-session and /api/charge routes, and the full tokenize → charge flow.
Frontend (HTML + JS)
Backend (Express)
This example serves the SDK locally to avoid CDN CORS issues on localhost. In production, use the CDN URL or your bundler — remove the
/oz-elements.esm.js static route. See Installation → CDN for details.Test Cards
These cards are for testing the vault tokenization flow — they are Luhn-valid and accepted by the vault in test mode. Use them to confirm your fields mount, tokenize, and return a token correctly.Testing a full charge with OzuraPay? Use the cards on the Test Credentials page instead — those are calibrated for OzuraPay’s sandbox, where the outcome (approve / decline) is determined by the charge amount, not the card number.
Testing your integration? Use the test pub key on localhost — see Installation → Local Development for setup details and test card numbers above.
Next Steps
Styling
Customize colors, fonts, and states.
React Components
OzElements provider and pre-built components.
Error Handling
Handle tokenization errors gracefully.
Server SDK
Process the token with cardSale() on your backend.