Skip to main content

Installation

npm / yarn

npm install @ozura/elements
Then import in your JavaScript or TypeScript:
import { OzVault, OzError } from '@ozura/elements';
For React components:
import { OzElements, useOzElements, OzCardNumber, OzExpiry, OzCvv, OzCard } from '@ozura/elements/react';

CDN (Script Tag)

If you’re not using a bundler, load the UMD build directly from the Ozura CDN:
<script src="https://elements.ozura.com/oz-elements.umd.js"></script>
<script>
  const { OzVault } = window.OzElements;
  const vault = new OzVault('YOUR_API_KEY', { pubKey: 'YOUR_PUB_KEY' });
</script>
Or use the ESM build with a native module script:
<script type="module">
  import { OzVault } from 'https://elements.ozura.com/oz-elements.esm.js';
  const vault = new OzVault('YOUR_API_KEY', { pubKey: 'YOUR_PUB_KEY' });
</script>

TypeScript

The package ships with full TypeScript definitions — no @types package needed. Import types directly:
import {
  OzVault,
  OzElement,
  OzError,
  ElementType,
  BankElementType,
  ElementOptions,
  ElementStyleConfig,
  ElementChangeEvent,
  VaultOptions,
  TokenizeOptions,
  TokenResponse,
  BankTokenizeOptions,
  BankTokenResponse,
  BillingDetails,
  BillingAddress,
  FontSource,
  Appearance,
  AppearanceVariables,
  OzTheme,
} from '@ozura/elements';

Credentials

You need both values from the Ozura Dashboard. Both must be passed to initialize the SDK — tokenization will fail if either is missing.
CredentialNotes
Vault API KeyClient-side key passed as the first argument to OzVault. Use an environment variable.
Vault Pub KeyAuthenticates the tokenize request. Passed via options.pubKey. Use an environment variable — do not hardcode it in source code.
const vault = new OzVault(process.env.VAULT_API_KEY, {
  pubKey: process.env.VAULT_PUB_KEY,
});
Do not hardcode credentials directly in source code or commit them to version control. Use environment variables to inject them at build time.

Constructor Options

new OzVault(apiKey: string, options: VaultOptions)
OptionTypeRequiredDefaultDescription
apiKeystringYour Vault API key (server-side)
options.pubKeystringYour Vault pub key (client-safe)
options.apiUrlstringhttps://api.ozuravault.comOverride the Vault API base URL
options.frameBaseUrlstringhttps://elements.ozura.comOverride where iframe assets are served from
options.fontsFontSource[][]Custom web fonts to load inside iframes
options.appearanceAppearanceGlobal theme and CSS variable overrides. See Styling.
options.onLoadError() => voidCalled if the tokenizer iframe fails to load
options.loadTimeoutMsnumber10000Timeout in ms before onLoadError fires

Next Steps