Skip to main content

OzVault

The main SDK entry point. Manages all payment fields and vault credentials.
Always create OzVault via the async static factory OzVault.create(). Never call new OzVault(...) directly.

OzVault.create

Initializes the vault, fetches a session, and loads the payment iframes. Resolves once the session is ready — you can create and mount elements immediately after. The vault is ready to tokenize once onReady fires (or vault.isReady === true). The optional signal parameter is an AbortSignal for advanced teardown scenarios. The React <OzElements> provider handles this automatically.
onReady can fire while OzVault.create() is still pending. Vault initialization runs multiple steps in parallel. The onReady callback may fire while await OzVault.create(...) is still in progress, at which point the vault variable is still undefined. Do not reference vault (or call vault.createElement()) inside onReady. Declare readiness flags before calling create() so they are accessible when the callback runs.

VaultOptions

¹ Exactly one of sessionUrl, getSessionKey, or fetchWaxKey is required. ² pubKey is required when using a production vault API key. If your vault API key was created for the test/sandbox environment, you can omit pubKey entirely.

Properties

Methods

createElement

Creates a card input element. Call .mount() on the result to attach it to the DOM. ElementType values: 'cardNumber' | 'expirationDate' | 'cvv'

getElement

Returns the existing element of the given type, or null.

createBankElement

Creates a bank account input element. BankElementType values: 'accountNumber' | 'routingNumber'

getBankElement

Returns the existing bank element of the given type, or null.

createToken

Tokenizes all mounted card elements. Throws OzError on failure.
Tokenization timeout: If the vault does not respond within 30 seconds, createToken() rejects with an OzError (errorCode: 'timeout'). This timeout is separate from the element iframe load timeout (loadTimeoutMs) and is not configurable.

createBankToken

Tokenizes all mounted bank elements. Throws OzError on failure. Same 30-second timeout applies.

destroy

Cleans up all payment field iframes and listeners. Call this when the checkout component unmounts.

reset

Clears all mounted card and bank element fields without destroying the vault, refreshing the session, or resetting the tokenization budget. Call this after a declined or failed payment so the customer can re-enter their card details on the same checkout screen. The session key, its remaining budget, and all mounted iframes are fully preserved — no network calls are made. After reset(), every mounted element emits a change event with { complete: false, valid: false, empty: true }. These events arrive asynchronously (via postMessage from the iframes), but in practice they land well before the user can interact with the cleared fields. Any submit-button gating logic that listens to change events will automatically re-disable the button — no manual state reset is required, though resetting your own flags immediately after vault.reset() is harmless defensive practice.
Session model: by design, one session covers the full checkout. The default sessionLimit: 3 gives you two declined attempts and one final attempt on the same session. Use vault.reset() between declines instead of vault.destroy() + recreate — that would unnecessarily refresh the session and discard remaining budget.

debugState

Returns a structured snapshot of the vault’s internal state. Always available regardless of whether debug: true is set. Safe to log or attach to a support ticket — no sensitive data is returned.

OzElement

Returned by createElement() and createBankElement(). Represents a single input field.

Properties

Methods

mount

Attaches the iframe to the DOM. target can be a CSS selector string or an HTMLElement.

unmount

Removes the iframe from the DOM and resets internal state, but does not destroy the element. The element can be re-mounted after calling unmount(). Use destroy() for permanent teardown.

on

Registers an event listener. Returns this for chaining.

off

Removes a previously registered event listener.

once

Registers a one-time event listener that fires once then removes itself.

update

Updates element options (style, placeholder, disabled) without re-mounting the iframe. Style update semantics:
  • Properties you include are merged into the current style — they replace their previous values.
  • Properties previously set but absent from the new style object retain their current values (no keys are cleared by omission).
  • To reset a specific property, pass it explicitly with an empty string: { base: { color: '' } }.
  • To fully reset all styles, destroy and recreate the element.
  • Vault-level appearance theme styles are always preserved underneath — per-element style merges on top.

focus

Programmatically focuses the input inside the iframe.

blur

Programmatically blurs the input.

clear

Clears the current value.

destroy

Permanently removes the iframe, clears all event handlers, and prevents future use. Distinct from unmount().

Events

change

Fired whenever the value or state changes.

focus / blur

Fired when the iframe input gains or loses focus. The blur callback receives the current field state.

ready

Fired once the iframe has fully loaded and is interactive.

loaderror

Fired if the iframe fails to load within loadTimeoutMs. Receives the element type and an error message.

TokenizeOptions

TokenResponse

BillingDetails

BankTokenizeOptions

BankTokenResponse

CardSaleApiResponse

The raw response envelope from the OzuraPay API cardSale endpoint. Only relevant when calling the API directly via fetch — the server SDK’s Ozura.cardSale() throws OzuraError on failure rather than returning this shape.

ElementOptions

ElementStyleConfig

See the Styling guide for the full list of supported ElementStyle keys.

Appearance

FontSource

OzError


React Types

OzElementsProps

UseOzElementsReturn

OzFieldProps

OzCardState

OzBankCardState


createSessionFetcher

A helper factory that creates a getSessionKey callback for a given backend URL. You rarely need to call this directly — pass sessionUrl to OzVault.create() or <OzElements> and the SDK calls it internally.
POSTs { sessionId } to the URL and reads sessionKey from the response. Useful when you need the callback form for custom headers or auth tokens:
Errors are OzError instances with a structured errorCode ('timeout' | 'network' | 'auth' | 'validation' | 'server').
createFetchWaxKey is a deprecated alias for createSessionFetcher. Both are exported and work identically.

Debug mode

Pass debug: true to VaultOptions (or as a prop on <OzElements debug>) to activate structured console logging.
Each log is a [OzVault] <event> prefixed console.log entry. Events covered: No sensitive data is ever logged. Session keys, tokens, CVC sessions, and billing fields appear only as boolean presence flags. Output is safe to paste directly into bug reports. vault.debugState() is always available regardless of this flag — see vault.debugState() above.

Exports

@ozura/elements

The browser entry. Exports everything needed to initialize the vault, mount fields, tokenize, and handle errors. The Transaction* and CardSale* types are re-exported here for TypeScript convenience but are primarily used with @ozura/elements/server.

@ozura/elements/react

@ozura/elements/server

Server-side entry — use in your Node.js / Express / Next.js backend only. Do not import in browser code.