Documentation Index
Fetch the complete documentation index at: https://docs.ozura.com/llms.txt
Use this file to discover all available pages before exploring further.
createToken() and createBankToken() both throw an OzError when tokenization fails. Wrap calls in a try/catch and inspect .errorCode to decide how to respond.
OzError
OzError properties
| Property | Type | Description |
|---|---|---|
message | string | Normalized, user-friendly error message |
errorCode | OzErrorCode | Machine-readable code (see table below) |
raw | string | Raw message returned by the Vault API (use for logging, not display) |
retryable | boolean | true for transient errors (network, timeout, server). false for permanent failures where retrying with the same input won’t help. |
Error Codes
errorCode | retryable | Meaning | What to do |
|---|---|---|---|
'network' | ✅ | Request failed due to a network error (offline, DNS failure, etc.) | Show a “check your connection” message. Retry is safe. |
'timeout' | ✅ | Tokenization took longer than 30 seconds | Show a timeout message. Retry is safe. |
'server' | ✅ | Vault returned a 5xx error | Retry after a short delay. Log for investigation. |
'auth' | ❌ | Session key invalid/expired (after automatic refresh retry), or pub key misconfigured | If you see this in production after a successful initial load, the auto-refresh failed — check that your session endpoint (/api/oz-session) is reachable. Otherwise verify credentials. |
'validation' | ❌ | Request was malformed or the vault rejected input | Check request parameters. Usually a developer error. |
'config' | ❌ | Unexpected SDK or environment issue | Log the error and contact Ozura support. |
'unknown' | ❌ | Unclassified error | Log and surface a generic message. |
Session key expiry is handled automatically. When a session key expires or is consumed between initialization and the user clicking Pay, the SDK silently fetches a fresh key and retries once. You will only receive an
auth error if the refresh itself fails (e.g. your session endpoint is down or returns an error). The proactive refresh — triggered once sessionLimit successful submissions are reached — also prevents expiry from surfacing under normal usage.Recommended Pattern
SDK-Level Errors
TheseOzError instances are thrown before any network request is made. They represent setup or usage mistakes caught during integration — fix them in code, don’t surface them to the user.
Initialization errors
These come fromOzVault.create(). If you’re using the React provider, they appear in initError.
| Condition | How to fix |
|---|---|
pubKey missing | Pass a valid pubKey to OzVault.create() / <OzElements>. |
| No session option provided | Pass sessionUrl, getSessionKey, or (deprecated) fetchWaxKey to OzVault.create() / <OzElements>. |
sessionUrl or getSessionKey returned an empty string | Check your /api/oz-session endpoint — it must return a non-empty sessionKey. |
| Session fetch threw an error | Your session endpoint failed. Check server logs. |
Tokenization errors
These come fromcreateToken() / createBankToken().
| Condition | How to fix |
|---|---|
| Vault not ready | Wait for the onReady callback (vanilla) or the ready flag (React) before submitting. |
| No elements mounted | Call mount() on at least one element before tokenizing. |
accountNumber / routingNumber not ready (bank) | Mount both bank elements before calling createBankToken(). |
| Tokenization already in progress | Disable your submit button while tokenization is pending. |
Missing firstName / lastName (bank) | Pass firstName and lastName in your createBankToken() options. |
| Name exceeds 50 characters | Truncate or validate firstName / lastName before submitting. |
| Invalid billing details | Validate billing fields before calling createToken(). Check the error message for the specific field. |
| Tokenization timed out | errorCode: 'timeout' — retryable; show a timeout message. |
Element errors
| Condition | How to fix |
|---|---|
mount() CSS selector not found | Verify the selector string targets an element that exists in the DOM at mount time. |
mount() passed null / undefined | Check your DOM reference before calling mount(). |
Load Errors
If the vault fails to load (network issue, blocked by CSP, etc.), useonLoadError in OzVault.create():
loaderror event with the element type and error message:
React: initError
In React,OzVault.create() is called inside the <OzElements> provider. If it fails (e.g. your session endpoint is unreachable or returns an error), useOzElements().initError will be non-null:
Error Normalization Helpers
The SDK exports three standalone functions that map raw API error strings to user-friendly messages.OzError.message from createToken() and createBankToken() is already normalized — the SDK calls these functions internally. You only need to call them yourself when you receive raw error strings from a different source (e.g. your backend forwarding a vault or PayAPI response).normalizeVaultError
Maps raw vault/tokenize error strings to user-facing messages for card flows.
normalizeBankVaultError
Maps raw vault/tokenize error strings to user-facing messages for bank/ACH flows.
normalizeCardSaleError
Maps raw PayAPIcardSale error strings to user-facing messages. Use this when your backend processes a charge via the Pay API and needs to display the error to the user.
normalizeVaultErrorandnormalizeBankVaultError— return the originalrawstring unchanged when no pattern matches.normalizeCardSaleError— short unrecognized strings (under 100 characters) are returned as-is; long opaque server strings (100+ characters) are replaced with"Payment processing failed. Please try again or contact support."An empty input returns"Payment processing failed. Please try again."
Next Steps
API Reference
Full OzError type definition and all SDK types.
Card Elements
createToken() full reference.