@ozura/elements 1.1.0 β 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1340 -1338
- package/dist/frame/element-frame.html +22 -22
- package/dist/frame/tokenizer-frame.html +11 -11
- package/dist/oz-elements.esm.js +262 -243
- package/dist/oz-elements.esm.js.map +1 -1
- package/dist/oz-elements.umd.js +263 -243
- package/dist/oz-elements.umd.js.map +1 -1
- package/dist/react/index.cjs.js +138 -112
- package/dist/react/index.cjs.js.map +1 -1
- package/dist/react/index.esm.js +137 -112
- package/dist/react/index.esm.js.map +1 -1
- package/dist/react/react/index.d.ts +50 -29
- package/dist/react/sdk/OzVault.d.ts +6 -5
- package/dist/react/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/react/sdk/index.d.ts +6 -26
- package/dist/react/server/index.d.ts +126 -74
- package/dist/react/types/index.d.ts +56 -31
- package/dist/server/index.cjs.js +165 -76
- package/dist/server/index.cjs.js.map +1 -1
- package/dist/server/index.esm.js +164 -77
- package/dist/server/index.esm.js.map +1 -1
- package/dist/server/sdk/OzVault.d.ts +6 -5
- package/dist/server/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/server/sdk/index.d.ts +6 -26
- package/dist/server/server/index.d.ts +126 -74
- package/dist/server/types/index.d.ts +56 -31
- package/dist/types/sdk/OzVault.d.ts +6 -5
- package/dist/types/sdk/createSessionFetcher.d.ts +29 -0
- package/dist/types/sdk/index.d.ts +6 -26
- package/dist/types/server/index.d.ts +126 -74
- package/dist/types/types/index.d.ts +56 -31
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,1338 +1,1340 @@
|
|
|
1
|
-
# @ozura/elements
|
|
2
|
-
|
|
3
|
-
PCI-isolated card and bank account tokenization SDK for the Ozura Vault.
|
|
4
|
-
|
|
5
|
-
Card data is collected inside Ozura-hosted iframes so raw numbers never touch your JavaScript bundle, your server logs, or your network traffic. The tokenizer communicates directly with the vault using `MessageChannel` port transfers β the merchant page acts as a layout host only.
|
|
6
|
-
|
|
7
|
-
> **π Full documentation:** [docs.ozura.com/sdks/elements/overview](https://docs.ozura.com/sdks/elements/overview)
|
|
8
|
-
>
|
|
9
|
-
> The docs include step-by-step guides, interactive examples, a complete API reference, and styling walkthroughs. If you are starting a new integration, the docs are the best place to begin.
|
|
10
|
-
|
|
11
|
-
---
|
|
12
|
-
|
|
13
|
-
## Table of contents
|
|
14
|
-
|
|
15
|
-
- [Full documentation](#full-documentation)
|
|
16
|
-
- [How it works](#how-it-works)
|
|
17
|
-
- [Installation](#installation)
|
|
18
|
-
- [Quick start β React](#quick-start--react)
|
|
19
|
-
- [Quick start β Vanilla JS](#quick-start--vanilla-js)
|
|
20
|
-
- [Server setup](#server-setup)
|
|
21
|
-
- [
|
|
22
|
-
- [Card sale endpoint](#card-sale-endpoint)
|
|
23
|
-
- [Vanilla JS API](#vanilla-js-api)
|
|
24
|
-
- [OzVault.create()](#ozvaultcreate)
|
|
25
|
-
- [vault.createElement()](#vaultcreateelementtypeoptions)
|
|
26
|
-
- [vault.createToken()](#vaultcreatetokenoptions)
|
|
27
|
-
- [vault.createBankElement()](#vaultcreatebankelement)
|
|
28
|
-
- [vault.createBankToken()](#vaultcreatebanktokenoptions)
|
|
29
|
-
- [vault.reset()](#vaultreset)
|
|
30
|
-
- [vault.destroy()](#vaultdestroy)
|
|
31
|
-
- [vault.debugState()](#vaultdebugstate)
|
|
32
|
-
- [OzElement events](#ozelement-events)
|
|
33
|
-
- [React API](#react-api)
|
|
34
|
-
- [OzElements provider](#ozelements-provider)
|
|
35
|
-
- [OzCard](#ozcard)
|
|
36
|
-
- [Individual field components](#individual-field-components)
|
|
37
|
-
- [OzBankCard](#ozbankcard)
|
|
38
|
-
- [useOzElements()](#useozelements)
|
|
39
|
-
- [Styling](#styling)
|
|
40
|
-
- [Per-element styles](#per-element-styles)
|
|
41
|
-
- [Global appearance](#global-appearance)
|
|
42
|
-
- [Custom fonts](#custom-fonts)
|
|
43
|
-
- [Billing details](#billing-details)
|
|
44
|
-
- [Error handling](#error-handling)
|
|
45
|
-
- [Debug mode](#debug-mode)
|
|
46
|
-
- [Server utilities](#server-utilities)
|
|
47
|
-
- [Ozura class](#ozura-class)
|
|
48
|
-
- [Route handler factories](#route-handler-factories)
|
|
49
|
-
- [Local development](#local-development)
|
|
50
|
-
- [Content Security Policy](#content-security-policy)
|
|
51
|
-
- [TypeScript reference](#typescript-reference)
|
|
52
|
-
|
|
53
|
-
---
|
|
54
|
-
|
|
55
|
-
## Full documentation
|
|
56
|
-
|
|
57
|
-
The README covers the most common integration patterns. The hosted docs at **[docs.ozura.com/sdks/elements](https://docs.ozura.com/sdks/elements/overview)** go deeper on every topic:
|
|
58
|
-
|
|
59
|
-
| Page | URL |
|
|
60
|
-
|---|---|
|
|
61
|
-
| Overview | [docs.ozura.com/sdks/elements/overview](https://docs.ozura.com/sdks/elements/overview) |
|
|
62
|
-
| Installation & setup | [docs.ozura.com/sdks/elements/installation](https://docs.ozura.com/sdks/elements/installation) |
|
|
63
|
-
| Card elements | [docs.ozura.com/sdks/elements/card-elements](https://docs.ozura.com/sdks/elements/card-elements) |
|
|
64
|
-
| Bank elements | [docs.ozura.com/sdks/elements/bank-elements](https://docs.ozura.com/sdks/elements/bank-elements) |
|
|
65
|
-
| React integration | [docs.ozura.com/sdks/elements/react](https://docs.ozura.com/sdks/elements/react) |
|
|
66
|
-
| Styling | [docs.ozura.com/sdks/elements/styling](https://docs.ozura.com/sdks/elements/styling) |
|
|
67
|
-
| Error handling | [docs.ozura.com/sdks/elements/error-handling](https://docs.ozura.com/sdks/elements/error-handling) |
|
|
68
|
-
| Server SDK | [docs.ozura.com/sdks/elements/server](https://docs.ozura.com/sdks/elements/server) |
|
|
69
|
-
| API reference | [docs.ozura.com/sdks/elements/api-reference](https://docs.ozura.com/sdks/elements/api-reference) |
|
|
70
|
-
|
|
71
|
-
---
|
|
72
|
-
|
|
73
|
-
## How it works
|
|
74
|
-
|
|
75
|
-
```
|
|
76
|
-
Merchant page
|
|
77
|
-
βββ OzVault (manages tokenizer iframe + element iframes)
|
|
78
|
-
βββ [hidden] tokenizer-frame.html β Ozura origin
|
|
79
|
-
βββ [visible] element-frame.html β card number ββ MessageChannel
|
|
80
|
-
βββ [visible] element-frame.html β expiry ββ port transfer
|
|
81
|
-
βββ [visible] element-frame.html β CVV ββ
|
|
82
|
-
```
|
|
83
|
-
|
|
84
|
-
1. `OzVault.create()` mounts a hidden tokenizer iframe and fetches a short-lived **
|
|
85
|
-
2. Calling `vault.createElement()` mounts a visible input iframe for each field.
|
|
86
|
-
3. `vault.createToken()` opens a direct `MessageChannel` between each element iframe and the tokenizer iframe. Raw values travel over those ports β they never pass through your JavaScript.
|
|
87
|
-
4. The tokenizer POSTs directly to the vault API over HTTPS and returns a token to your page.
|
|
88
|
-
|
|
89
|
-
Your server only ever sees a token, never card data.
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
## Credentials
|
|
94
|
-
|
|
95
|
-
| Credential | Format | Where it lives | Required for |
|
|
96
|
-
|---|---|---|---|
|
|
97
|
-
| **Vault pub key** | `pk_live_β¦` or `pk_prod_β¦` | Frontend env var (safe to expose) | All integrations |
|
|
98
|
-
| **Vault API key** | `key_β¦` | Server env var β **never in the browser** |
|
|
99
|
-
| **Pay API key** | `ak_β¦` | Server env var only | OzuraPay merchants (card charging) |
|
|
100
|
-
| **Merchant ID** | `ozu_β¦` | Server env var only | OzuraPay merchants (card charging) |
|
|
101
|
-
|
|
102
|
-
If you are not routing payments through OzuraPay you only need the vault pub key (frontend) and vault API key (backend).
|
|
103
|
-
|
|
104
|
-
---
|
|
105
|
-
|
|
106
|
-
## Installation
|
|
107
|
-
|
|
108
|
-
> π [Installation guide](https://docs.ozura.com/sdks/elements/installation) β npm, yarn, CDN setup, and TypeScript configuration.
|
|
109
|
-
|
|
110
|
-
```bash
|
|
111
|
-
npm install @ozura/elements
|
|
112
|
-
```
|
|
113
|
-
|
|
114
|
-
React and React DOM are peer dependencies (optional β only needed for `@ozura/elements/react`):
|
|
115
|
-
|
|
116
|
-
```bash
|
|
117
|
-
npm install react react-dom # if not already installed
|
|
118
|
-
```
|
|
119
|
-
|
|
120
|
-
**Requirements:** Node β₯ 18, React β₯ 17 (React peer).
|
|
121
|
-
|
|
122
|
-
---
|
|
123
|
-
|
|
124
|
-
## Quick start β React
|
|
125
|
-
|
|
126
|
-
> π [React integration guide](https://docs.ozura.com/sdks/elements/react) β provider setup, pre-built components, hook reference, and full examples.
|
|
127
|
-
|
|
128
|
-
```tsx
|
|
129
|
-
// 1. Wrap your checkout in <OzElements>
|
|
130
|
-
import { OzElements, OzCard, useOzElements
|
|
131
|
-
|
|
132
|
-
function CheckoutPage() {
|
|
133
|
-
return (
|
|
134
|
-
<OzElements
|
|
135
|
-
pubKey="pk_live_..."
|
|
136
|
-
|
|
137
|
-
>
|
|
138
|
-
<CheckoutForm />
|
|
139
|
-
</OzElements>
|
|
140
|
-
);
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
// 2. Collect card data and tokenize
|
|
144
|
-
function CheckoutForm() {
|
|
145
|
-
const { createToken, reset, ready } = useOzElements();
|
|
146
|
-
|
|
147
|
-
const handleSubmit = async (e: React.FormEvent) => {
|
|
148
|
-
e.preventDefault();
|
|
149
|
-
try {
|
|
150
|
-
const { token, cvcSession, billing } = await createToken({
|
|
151
|
-
billing: {
|
|
152
|
-
firstName: 'Jane',
|
|
153
|
-
lastName: 'Smith',
|
|
154
|
-
email: 'jane@example.com',
|
|
155
|
-
address: { line1: '123 Main St', city: 'Austin', state: 'TX', zip: '78701', country: 'US' },
|
|
156
|
-
},
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
// Send token to your server
|
|
160
|
-
await fetch('/api/charge', {
|
|
161
|
-
method: 'POST',
|
|
162
|
-
headers: { 'Content-Type': 'application/json' },
|
|
163
|
-
body: JSON.stringify({ token, cvcSession, billing }),
|
|
164
|
-
});
|
|
165
|
-
} catch (err) {
|
|
166
|
-
reset(); // clear fields so the customer can re-enter
|
|
167
|
-
console.error(err);
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
|
|
171
|
-
return (
|
|
172
|
-
<form onSubmit={handleSubmit}>
|
|
173
|
-
<OzCard onChange={(state) => console.log(state.cardBrand)} />
|
|
174
|
-
<button type="submit" disabled={!ready}>Pay</button>
|
|
175
|
-
</form>
|
|
176
|
-
);
|
|
177
|
-
}
|
|
178
|
-
```
|
|
179
|
-
|
|
180
|
-
---
|
|
181
|
-
|
|
182
|
-
## Quick start β Vanilla JS
|
|
183
|
-
|
|
184
|
-
> π [Card elements guide](https://docs.ozura.com/sdks/elements/card-elements) β full end-to-end example, field events, submit-button gating, and auto-advance behaviour.
|
|
185
|
-
|
|
186
|
-
```ts
|
|
187
|
-
import { OzVault
|
|
188
|
-
|
|
189
|
-
// Declare state BEFORE OzVault.create(). The onReady callback fires when the
|
|
190
|
-
// tokenizer iframe loads β this can happen before create() resolves because the
|
|
191
|
-
// iframe loads concurrently with fetchWaxKey. At that moment, `vault` is still
|
|
192
|
-
// undefined. Do not reference `vault` inside onReady.
|
|
193
|
-
let readyCount = 0;
|
|
194
|
-
let tokenizerIsReady = false;
|
|
195
|
-
|
|
196
|
-
function checkReady() {
|
|
197
|
-
if (readyCount === 3 && tokenizerIsReady) enablePayButton();
|
|
198
|
-
}
|
|
199
|
-
|
|
200
|
-
const vault = await OzVault.create({
|
|
201
|
-
pubKey: 'pk_live_...',
|
|
202
|
-
|
|
203
|
-
onReady: () => { tokenizerIsReady = true; checkReady(); }, // tokenizer iframe loaded
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
const cardNumberEl = vault.createElement('cardNumber');
|
|
207
|
-
const expiryEl = vault.createElement('expirationDate');
|
|
208
|
-
const cvvEl = vault.createElement('cvv');
|
|
209
|
-
|
|
210
|
-
cardNumberEl.mount('#card-number');
|
|
211
|
-
expiryEl.mount('#expiry');
|
|
212
|
-
cvvEl.mount('#cvv');
|
|
213
|
-
|
|
214
|
-
[cardNumberEl, expiryEl, cvvEl].forEach(el => {
|
|
215
|
-
el.on('ready', () => { readyCount++; checkReady(); });
|
|
216
|
-
});
|
|
217
|
-
|
|
218
|
-
async function pay() {
|
|
219
|
-
try {
|
|
220
|
-
const { token, cvcSession, card } = await vault.createToken({
|
|
221
|
-
billing: { firstName: 'Jane', lastName: 'Smith' },
|
|
222
|
-
});
|
|
223
|
-
// POST { token, cvcSession } to your server
|
|
224
|
-
} catch (err) {
|
|
225
|
-
vault.reset(); // clear fields; let customer re-enter
|
|
226
|
-
console.error(err);
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
// Clean up when done
|
|
231
|
-
vault.destroy();
|
|
232
|
-
```
|
|
233
|
-
|
|
234
|
-
> **Gating the submit button in vanilla JS** requires checking both `vault.isReady` (tokenizer iframe loaded) **and** every element's `ready` event (input iframes loaded). In React, `useOzElements().ready` combines both automatically.
|
|
235
|
-
|
|
236
|
-
---
|
|
237
|
-
|
|
238
|
-
## Server setup
|
|
239
|
-
|
|
240
|
-
> π [Server SDK guide](https://docs.ozura.com/sdks/elements/server) β
|
|
241
|
-
|
|
242
|
-
###
|
|
243
|
-
|
|
244
|
-
The SDK calls your
|
|
245
|
-
|
|
246
|
-
**Next.js App Router (recommended)**
|
|
247
|
-
|
|
248
|
-
```ts
|
|
249
|
-
// app/api/
|
|
250
|
-
import { Ozura,
|
|
251
|
-
|
|
252
|
-
const ozura = new Ozura({
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
```
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
```
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
|
355
|
-
|
|
356
|
-
| `
|
|
357
|
-
| `
|
|
358
|
-
| `
|
|
359
|
-
| `
|
|
360
|
-
| `
|
|
361
|
-
| `
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
`
|
|
401
|
-
|
|
402
|
-
|
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
|
412
|
-
|
|
413
|
-
| `.
|
|
414
|
-
| `.
|
|
415
|
-
| `.
|
|
416
|
-
| `.
|
|
417
|
-
| `.
|
|
418
|
-
| `.
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
`
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
- The
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
```
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
interface
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
//
|
|
597
|
-
//
|
|
598
|
-
//
|
|
599
|
-
//
|
|
600
|
-
//
|
|
601
|
-
//
|
|
602
|
-
//
|
|
603
|
-
//
|
|
604
|
-
//
|
|
605
|
-
//
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
`
|
|
628
|
-
|
|
629
|
-
|
|
|
630
|
-
|
|
631
|
-
| `
|
|
632
|
-
| `
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
`
|
|
695
|
-
|
|
696
|
-
|
|
|
697
|
-
|
|
698
|
-
| `
|
|
699
|
-
| `
|
|
700
|
-
| `
|
|
701
|
-
| `
|
|
702
|
-
| `
|
|
703
|
-
| `
|
|
704
|
-
| `
|
|
705
|
-
| `
|
|
706
|
-
| `
|
|
707
|
-
| `
|
|
708
|
-
| `
|
|
709
|
-
| `
|
|
710
|
-
| `
|
|
711
|
-
| `
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
|
735
|
-
|
|
736
|
-
| `
|
|
737
|
-
| `
|
|
738
|
-
| `
|
|
739
|
-
| `
|
|
740
|
-
| `
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
```
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
|
782
|
-
|
|
783
|
-
| `
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
},
|
|
813
|
-
|
|
814
|
-
borderColor: '#
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
//
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
>
|
|
867
|
-
>
|
|
868
|
-
> | `
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
case '
|
|
938
|
-
case '
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
`
|
|
954
|
-
|
|
955
|
-
|
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
```
|
|
990
|
-
|
|
991
|
-
<
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
|
999
|
-
|
|
1000
|
-
| `
|
|
1001
|
-
| `
|
|
1002
|
-
| `
|
|
1003
|
-
| `
|
|
1004
|
-
| `
|
|
1005
|
-
| `
|
|
1006
|
-
| `
|
|
1007
|
-
| `
|
|
1008
|
-
| `
|
|
1009
|
-
| `
|
|
1010
|
-
| `
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
"
|
|
1032
|
-
"
|
|
1033
|
-
"
|
|
1034
|
-
"
|
|
1035
|
-
"
|
|
1036
|
-
"
|
|
1037
|
-
"
|
|
1038
|
-
"
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
//
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
//
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
//
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
}
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
});
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
err.
|
|
1143
|
-
err.
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
|
1161
|
-
|
|
1162
|
-
| `
|
|
1163
|
-
| `
|
|
1164
|
-
|
|
1165
|
-
`
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
```
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
```
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
```
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
//
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
```
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
|
1332
|
-
|
|
1333
|
-
|
|
|
1334
|
-
|
|
|
1335
|
-
|
|
|
1336
|
-
|
|
|
1337
|
-
|
|
|
1338
|
-
|
|
|
1
|
+
# @ozura/elements
|
|
2
|
+
|
|
3
|
+
PCI-isolated card and bank account tokenization SDK for the Ozura Vault.
|
|
4
|
+
|
|
5
|
+
Card data is collected inside Ozura-hosted iframes so raw numbers never touch your JavaScript bundle, your server logs, or your network traffic. The tokenizer communicates directly with the vault using `MessageChannel` port transfers β the merchant page acts as a layout host only.
|
|
6
|
+
|
|
7
|
+
> **π Full documentation:** [docs.ozura.com/sdks/elements/overview](https://docs.ozura.com/sdks/elements/overview)
|
|
8
|
+
>
|
|
9
|
+
> The docs include step-by-step guides, interactive examples, a complete API reference, and styling walkthroughs. If you are starting a new integration, the docs are the best place to begin.
|
|
10
|
+
|
|
11
|
+
---
|
|
12
|
+
|
|
13
|
+
## Table of contents
|
|
14
|
+
|
|
15
|
+
- [Full documentation](#full-documentation)
|
|
16
|
+
- [How it works](#how-it-works)
|
|
17
|
+
- [Installation](#installation)
|
|
18
|
+
- [Quick start β React](#quick-start--react)
|
|
19
|
+
- [Quick start β Vanilla JS](#quick-start--vanilla-js)
|
|
20
|
+
- [Server setup](#server-setup)
|
|
21
|
+
- [Session endpoint](#session-endpoint)
|
|
22
|
+
- [Card sale endpoint](#card-sale-endpoint)
|
|
23
|
+
- [Vanilla JS API](#vanilla-js-api)
|
|
24
|
+
- [OzVault.create()](#ozvaultcreate)
|
|
25
|
+
- [vault.createElement()](#vaultcreateelementtypeoptions)
|
|
26
|
+
- [vault.createToken()](#vaultcreatetokenoptions)
|
|
27
|
+
- [vault.createBankElement()](#vaultcreatebankelement)
|
|
28
|
+
- [vault.createBankToken()](#vaultcreatebanktokenoptions)
|
|
29
|
+
- [vault.reset()](#vaultreset)
|
|
30
|
+
- [vault.destroy()](#vaultdestroy)
|
|
31
|
+
- [vault.debugState()](#vaultdebugstate)
|
|
32
|
+
- [OzElement events](#ozelement-events)
|
|
33
|
+
- [React API](#react-api)
|
|
34
|
+
- [OzElements provider](#ozelements-provider)
|
|
35
|
+
- [OzCard](#ozcard)
|
|
36
|
+
- [Individual field components](#individual-field-components)
|
|
37
|
+
- [OzBankCard](#ozbankcard)
|
|
38
|
+
- [useOzElements()](#useozelements)
|
|
39
|
+
- [Styling](#styling)
|
|
40
|
+
- [Per-element styles](#per-element-styles)
|
|
41
|
+
- [Global appearance](#global-appearance)
|
|
42
|
+
- [Custom fonts](#custom-fonts)
|
|
43
|
+
- [Billing details](#billing-details)
|
|
44
|
+
- [Error handling](#error-handling)
|
|
45
|
+
- [Debug mode](#debug-mode)
|
|
46
|
+
- [Server utilities](#server-utilities)
|
|
47
|
+
- [Ozura class](#ozura-class)
|
|
48
|
+
- [Route handler factories](#route-handler-factories)
|
|
49
|
+
- [Local development](#local-development)
|
|
50
|
+
- [Content Security Policy](#content-security-policy)
|
|
51
|
+
- [TypeScript reference](#typescript-reference)
|
|
52
|
+
|
|
53
|
+
---
|
|
54
|
+
|
|
55
|
+
## Full documentation
|
|
56
|
+
|
|
57
|
+
The README covers the most common integration patterns. The hosted docs at **[docs.ozura.com/sdks/elements](https://docs.ozura.com/sdks/elements/overview)** go deeper on every topic:
|
|
58
|
+
|
|
59
|
+
| Page | URL |
|
|
60
|
+
|---|---|
|
|
61
|
+
| Overview | [docs.ozura.com/sdks/elements/overview](https://docs.ozura.com/sdks/elements/overview) |
|
|
62
|
+
| Installation & setup | [docs.ozura.com/sdks/elements/installation](https://docs.ozura.com/sdks/elements/installation) |
|
|
63
|
+
| Card elements | [docs.ozura.com/sdks/elements/card-elements](https://docs.ozura.com/sdks/elements/card-elements) |
|
|
64
|
+
| Bank elements | [docs.ozura.com/sdks/elements/bank-elements](https://docs.ozura.com/sdks/elements/bank-elements) |
|
|
65
|
+
| React integration | [docs.ozura.com/sdks/elements/react](https://docs.ozura.com/sdks/elements/react) |
|
|
66
|
+
| Styling | [docs.ozura.com/sdks/elements/styling](https://docs.ozura.com/sdks/elements/styling) |
|
|
67
|
+
| Error handling | [docs.ozura.com/sdks/elements/error-handling](https://docs.ozura.com/sdks/elements/error-handling) |
|
|
68
|
+
| Server SDK | [docs.ozura.com/sdks/elements/server](https://docs.ozura.com/sdks/elements/server) |
|
|
69
|
+
| API reference | [docs.ozura.com/sdks/elements/api-reference](https://docs.ozura.com/sdks/elements/api-reference) |
|
|
70
|
+
|
|
71
|
+
---
|
|
72
|
+
|
|
73
|
+
## How it works
|
|
74
|
+
|
|
75
|
+
```
|
|
76
|
+
Merchant page
|
|
77
|
+
βββ OzVault (manages tokenizer iframe + element iframes)
|
|
78
|
+
βββ [hidden] tokenizer-frame.html β Ozura origin
|
|
79
|
+
βββ [visible] element-frame.html β card number ββ MessageChannel
|
|
80
|
+
βββ [visible] element-frame.html β expiry ββ port transfer
|
|
81
|
+
βββ [visible] element-frame.html β CVV ββ
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
1. `OzVault.create()` mounts a hidden tokenizer iframe and fetches a short-lived **session key** from your server.
|
|
85
|
+
2. Calling `vault.createElement()` mounts a visible input iframe for each field.
|
|
86
|
+
3. `vault.createToken()` opens a direct `MessageChannel` between each element iframe and the tokenizer iframe. Raw values travel over those ports β they never pass through your JavaScript.
|
|
87
|
+
4. The tokenizer POSTs directly to the vault API over HTTPS and returns a token to your page.
|
|
88
|
+
|
|
89
|
+
Your server only ever sees a token, never card data.
|
|
90
|
+
|
|
91
|
+
---
|
|
92
|
+
|
|
93
|
+
## Credentials
|
|
94
|
+
|
|
95
|
+
| Credential | Format | Where it lives | Required for |
|
|
96
|
+
|---|---|---|---|
|
|
97
|
+
| **Vault pub key** | `pk_live_β¦` or `pk_prod_β¦` | Frontend env var (safe to expose) | All integrations |
|
|
98
|
+
| **Vault API key** | `key_β¦` | Server env var β **never in the browser** | Creating sessions (all integrations) |
|
|
99
|
+
| **Pay API key** | `ak_β¦` | Server env var only | OzuraPay merchants (card charging) |
|
|
100
|
+
| **Merchant ID** | `ozu_β¦` | Server env var only | OzuraPay merchants (card charging) |
|
|
101
|
+
|
|
102
|
+
If you are not routing payments through OzuraPay you only need the vault pub key (frontend) and vault API key (backend).
|
|
103
|
+
|
|
104
|
+
---
|
|
105
|
+
|
|
106
|
+
## Installation
|
|
107
|
+
|
|
108
|
+
> π [Installation guide](https://docs.ozura.com/sdks/elements/installation) β npm, yarn, CDN setup, and TypeScript configuration.
|
|
109
|
+
|
|
110
|
+
```bash
|
|
111
|
+
npm install @ozura/elements
|
|
112
|
+
```
|
|
113
|
+
|
|
114
|
+
React and React DOM are peer dependencies (optional β only needed for `@ozura/elements/react`):
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm install react react-dom # if not already installed
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Requirements:** Node β₯ 18, React β₯ 17 (React peer).
|
|
121
|
+
|
|
122
|
+
---
|
|
123
|
+
|
|
124
|
+
## Quick start β React
|
|
125
|
+
|
|
126
|
+
> π [React integration guide](https://docs.ozura.com/sdks/elements/react) β provider setup, pre-built components, hook reference, and full examples.
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
// 1. Wrap your checkout in <OzElements>
|
|
130
|
+
import { OzElements, OzCard, useOzElements } from '@ozura/elements/react';
|
|
131
|
+
|
|
132
|
+
function CheckoutPage() {
|
|
133
|
+
return (
|
|
134
|
+
<OzElements
|
|
135
|
+
pubKey="pk_live_..."
|
|
136
|
+
sessionUrl="/api/oz-session"
|
|
137
|
+
>
|
|
138
|
+
<CheckoutForm />
|
|
139
|
+
</OzElements>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
// 2. Collect card data and tokenize
|
|
144
|
+
function CheckoutForm() {
|
|
145
|
+
const { createToken, reset, ready } = useOzElements();
|
|
146
|
+
|
|
147
|
+
const handleSubmit = async (e: React.FormEvent) => {
|
|
148
|
+
e.preventDefault();
|
|
149
|
+
try {
|
|
150
|
+
const { token, cvcSession, billing } = await createToken({
|
|
151
|
+
billing: {
|
|
152
|
+
firstName: 'Jane',
|
|
153
|
+
lastName: 'Smith',
|
|
154
|
+
email: 'jane@example.com',
|
|
155
|
+
address: { line1: '123 Main St', city: 'Austin', state: 'TX', zip: '78701', country: 'US' },
|
|
156
|
+
},
|
|
157
|
+
});
|
|
158
|
+
|
|
159
|
+
// Send token to your server
|
|
160
|
+
await fetch('/api/charge', {
|
|
161
|
+
method: 'POST',
|
|
162
|
+
headers: { 'Content-Type': 'application/json' },
|
|
163
|
+
body: JSON.stringify({ token, cvcSession, billing }),
|
|
164
|
+
});
|
|
165
|
+
} catch (err) {
|
|
166
|
+
reset(); // clear fields so the customer can re-enter
|
|
167
|
+
console.error(err);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
return (
|
|
172
|
+
<form onSubmit={handleSubmit}>
|
|
173
|
+
<OzCard onChange={(state) => console.log(state.cardBrand)} />
|
|
174
|
+
<button type="submit" disabled={!ready}>Pay</button>
|
|
175
|
+
</form>
|
|
176
|
+
);
|
|
177
|
+
}
|
|
178
|
+
```
|
|
179
|
+
|
|
180
|
+
---
|
|
181
|
+
|
|
182
|
+
## Quick start β Vanilla JS
|
|
183
|
+
|
|
184
|
+
> π [Card elements guide](https://docs.ozura.com/sdks/elements/card-elements) β full end-to-end example, field events, submit-button gating, and auto-advance behaviour.
|
|
185
|
+
|
|
186
|
+
```ts
|
|
187
|
+
import { OzVault } from '@ozura/elements';
|
|
188
|
+
|
|
189
|
+
// Declare state BEFORE OzVault.create(). The onReady callback fires when the
|
|
190
|
+
// tokenizer iframe loads β this can happen before create() resolves because the
|
|
191
|
+
// iframe loads concurrently with fetchWaxKey. At that moment, `vault` is still
|
|
192
|
+
// undefined. Do not reference `vault` inside onReady.
|
|
193
|
+
let readyCount = 0;
|
|
194
|
+
let tokenizerIsReady = false;
|
|
195
|
+
|
|
196
|
+
function checkReady() {
|
|
197
|
+
if (readyCount === 3 && tokenizerIsReady) enablePayButton();
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
const vault = await OzVault.create({
|
|
201
|
+
pubKey: 'pk_live_...',
|
|
202
|
+
sessionUrl: '/api/oz-session',
|
|
203
|
+
onReady: () => { tokenizerIsReady = true; checkReady(); }, // tokenizer iframe loaded
|
|
204
|
+
});
|
|
205
|
+
|
|
206
|
+
const cardNumberEl = vault.createElement('cardNumber');
|
|
207
|
+
const expiryEl = vault.createElement('expirationDate');
|
|
208
|
+
const cvvEl = vault.createElement('cvv');
|
|
209
|
+
|
|
210
|
+
cardNumberEl.mount('#card-number');
|
|
211
|
+
expiryEl.mount('#expiry');
|
|
212
|
+
cvvEl.mount('#cvv');
|
|
213
|
+
|
|
214
|
+
[cardNumberEl, expiryEl, cvvEl].forEach(el => {
|
|
215
|
+
el.on('ready', () => { readyCount++; checkReady(); });
|
|
216
|
+
});
|
|
217
|
+
|
|
218
|
+
async function pay() {
|
|
219
|
+
try {
|
|
220
|
+
const { token, cvcSession, card } = await vault.createToken({
|
|
221
|
+
billing: { firstName: 'Jane', lastName: 'Smith' },
|
|
222
|
+
});
|
|
223
|
+
// POST { token, cvcSession } to your server
|
|
224
|
+
} catch (err) {
|
|
225
|
+
vault.reset(); // clear fields; let customer re-enter
|
|
226
|
+
console.error(err);
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
// Clean up when done
|
|
231
|
+
vault.destroy();
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
> **Gating the submit button in vanilla JS** requires checking both `vault.isReady` (tokenizer iframe loaded) **and** every element's `ready` event (input iframes loaded). In React, `useOzElements().ready` combines both automatically.
|
|
235
|
+
|
|
236
|
+
---
|
|
237
|
+
|
|
238
|
+
## Server setup
|
|
239
|
+
|
|
240
|
+
> π [Server SDK guide](https://docs.ozura.com/sdks/elements/server) β session creation, card sale handler factories, IP extraction, and manual implementation patterns.
|
|
241
|
+
|
|
242
|
+
### Session endpoint
|
|
243
|
+
|
|
244
|
+
The SDK calls your session endpoint whenever it needs to start or refresh a payment session. Your backend creates a short-lived session key from the vault using your vault API key β the key never touches the browser.
|
|
245
|
+
|
|
246
|
+
**Next.js App Router (recommended)**
|
|
247
|
+
|
|
248
|
+
```ts
|
|
249
|
+
// app/api/oz-session/route.ts
|
|
250
|
+
import { Ozura, createSessionHandler } from '@ozura/elements/server';
|
|
251
|
+
|
|
252
|
+
const ozura = new Ozura({ vaultKey: process.env.VAULT_API_KEY! });
|
|
253
|
+
|
|
254
|
+
export const POST = createSessionHandler(ozura);
|
|
255
|
+
```
|
|
256
|
+
|
|
257
|
+
**Express**
|
|
258
|
+
|
|
259
|
+
```ts
|
|
260
|
+
import express from 'express';
|
|
261
|
+
import { Ozura, createSessionMiddleware } from '@ozura/elements/server';
|
|
262
|
+
|
|
263
|
+
const ozura = new Ozura({ vaultKey: process.env.VAULT_API_KEY! });
|
|
264
|
+
const app = express();
|
|
265
|
+
|
|
266
|
+
app.use(express.json());
|
|
267
|
+
app.post('/api/oz-session', createSessionMiddleware(ozura));
|
|
268
|
+
```
|
|
269
|
+
|
|
270
|
+
**Manual implementation** (for custom logic or auth checks)
|
|
271
|
+
|
|
272
|
+
```ts
|
|
273
|
+
// POST /api/oz-session
|
|
274
|
+
const { sessionId } = await req.json();
|
|
275
|
+
const { sessionKey } = await ozura.createSession({ sessionId });
|
|
276
|
+
return Response.json({ sessionKey });
|
|
277
|
+
```
|
|
278
|
+
|
|
279
|
+
### Card sale endpoint
|
|
280
|
+
|
|
281
|
+
After `createToken()` resolves on the frontend, POST `{ token, cvcSession, billing }` to your server to charge the card.
|
|
282
|
+
|
|
283
|
+
**Next.js App Router**
|
|
284
|
+
|
|
285
|
+
```ts
|
|
286
|
+
// app/api/charge/route.ts
|
|
287
|
+
import { Ozura, createCardSaleHandler } from '@ozura/elements/server';
|
|
288
|
+
|
|
289
|
+
const ozura = new Ozura({ merchantId: '...', apiKey: '...', vaultKey: '...' });
|
|
290
|
+
|
|
291
|
+
export const POST = createCardSaleHandler(ozura, {
|
|
292
|
+
getAmount: async (body) => {
|
|
293
|
+
const order = await db.orders.findById(body.orderId as string);
|
|
294
|
+
return order.total; // decimal string, e.g. "49.00"
|
|
295
|
+
},
|
|
296
|
+
// getCurrency: async (body) => 'USD', // optional, defaults to "USD"
|
|
297
|
+
});
|
|
298
|
+
```
|
|
299
|
+
|
|
300
|
+
**Express**
|
|
301
|
+
|
|
302
|
+
```ts
|
|
303
|
+
app.post('/api/charge', createCardSaleMiddleware(ozura, {
|
|
304
|
+
getAmount: async (body) => {
|
|
305
|
+
const order = await db.orders.findById(body.orderId as string);
|
|
306
|
+
return order.total; // decimal string, e.g. "49.00"
|
|
307
|
+
},
|
|
308
|
+
// getCurrency: async (body) => 'USD', // optional, defaults to "USD"
|
|
309
|
+
}));
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
> `createCardSaleMiddleware` always terminates the request β it does not call `next()` and cannot be composed in a middleware chain.
|
|
313
|
+
|
|
314
|
+
**Manual implementation**
|
|
315
|
+
|
|
316
|
+
```ts
|
|
317
|
+
const { token, cvcSession, billing } = await req.json();
|
|
318
|
+
const result = await ozura.cardSale({
|
|
319
|
+
token,
|
|
320
|
+
cvcSession,
|
|
321
|
+
amount: '49.00',
|
|
322
|
+
currency: 'USD',
|
|
323
|
+
billing,
|
|
324
|
+
// Take the first IP from the forwarded-for chain; fall back to socket address.
|
|
325
|
+
// req is a Fetch API Request (Next.js App Router / Vercel Edge).
|
|
326
|
+
clientIpAddress: req.headers.get('x-forwarded-for')?.split(',')[0].trim()
|
|
327
|
+
?? req.headers.get('x-real-ip')
|
|
328
|
+
?? '',
|
|
329
|
+
});
|
|
330
|
+
// result.transactionId, result.amount, result.cardLastFour, result.cardBrand
|
|
331
|
+
```
|
|
332
|
+
|
|
333
|
+
---
|
|
334
|
+
|
|
335
|
+
## Vanilla JS API
|
|
336
|
+
|
|
337
|
+
> π [API reference](https://docs.ozura.com/sdks/elements/api-reference) β complete type definitions and method signatures for every class.
|
|
338
|
+
|
|
339
|
+
### OzVault.create(options)
|
|
340
|
+
|
|
341
|
+
```ts
|
|
342
|
+
const vault = await OzVault.create(options: VaultOptions): Promise<OzVault>
|
|
343
|
+
```
|
|
344
|
+
|
|
345
|
+
Mounts the hidden tokenizer iframe and fetches a session key concurrently. Both happen in parallel β by the time `create()` resolves, the iframe may already be ready.
|
|
346
|
+
|
|
347
|
+
| Option | Type | Required | Description |
|
|
348
|
+
|---|---|---|---|
|
|
349
|
+
| `pubKey` | `string` | β | Your public key from the Ozura admin. |
|
|
350
|
+
| `sessionUrl` | `string` | β ΒΉ | URL of your session endpoint. The simplest option β pass the path and the SDK handles everything. |
|
|
351
|
+
| `getSessionKey` | `(sessionId: string) => Promise<string>` | β ΒΉ | Custom async callback for obtaining the session key. Use when you need custom headers or auth logic. |
|
|
352
|
+
| `fetchWaxKey` | `(sessionId: string) => Promise<string>` | β ΒΉ | **Deprecated.** Use `sessionUrl` or `getSessionKey` instead. |
|
|
353
|
+
| `frameBaseUrl` | `string` | β | Base URL for iframe assets. Defaults to production CDN. Override for local dev (see [Local development](#local-development)). |
|
|
354
|
+
| `fonts` | `FontSource[]` | β | Custom fonts to inject into all element iframes. |
|
|
355
|
+
| `appearance` | `Appearance` | β | Global theme and variable overrides. |
|
|
356
|
+
| `loadTimeoutMs` | `number` | β | Tokenizer iframe load timeout in ms. Default: `10000`. Only takes effect when `onLoadError` is also provided. |
|
|
357
|
+
| `onLoadError` | `() => void` | β | Called if the tokenizer iframe fails to load within `loadTimeoutMs`. |
|
|
358
|
+
| `onSessionRefresh` | `() => void` | β | Called when the SDK silently refreshes the session mid-tokenization (key expired or consumed). |
|
|
359
|
+
| `onReady` | `() => void` | β | Called once when the tokenizer iframe has loaded and is ready. Use in vanilla JS to re-check submit-button readiness. In React, `useOzElements().ready` handles this automatically. |
|
|
360
|
+
| `sessionLimit` | `number` | β | Card submissions allowed per session before the SDK refreshes automatically. Default: `3`. Must match `sessionLimit` in your server-side `createSession` call. |
|
|
361
|
+
| `debug` | `boolean` | β | Enables structured `[OzVault]`-prefixed `console.log` output at every lifecycle event. Safe to use in production β no sensitive data is ever logged. Default: `false`. See [Debug mode](#debug-mode) for details. |
|
|
362
|
+
|
|
363
|
+
ΒΉ Exactly one of `sessionUrl`, `getSessionKey`, or `fetchWaxKey` is required.
|
|
364
|
+
|
|
365
|
+
Throws `OzError` if the session fetch rejects, returns an empty string, or returns a non-string value.
|
|
366
|
+
|
|
367
|
+
> **`sessionUrl` retry behavior:** The SDK enforces a **10-second per-attempt timeout** and retries **once after 750 ms on pure network failures** (connection refused, DNS failure, offline). HTTP 4xx/5xx errors are never retried β they signal endpoint misconfiguration or invalid credentials and require developer action. Errors are thrown as `OzError` instances so you can inspect `err.errorCode`.
|
|
368
|
+
|
|
369
|
+
---
|
|
370
|
+
|
|
371
|
+
### vault.createElement(type, options?)
|
|
372
|
+
|
|
373
|
+
```ts
|
|
374
|
+
vault.createElement(type: ElementType, options?: ElementOptions): OzElement
|
|
375
|
+
```
|
|
376
|
+
|
|
377
|
+
Creates and returns an element iframe. Call `.mount(target)` to attach it to the DOM.
|
|
378
|
+
|
|
379
|
+
`ElementType`: `'cardNumber'` | `'cvv'` | `'expirationDate'`
|
|
380
|
+
|
|
381
|
+
```ts
|
|
382
|
+
const cardEl = vault.createElement('cardNumber', {
|
|
383
|
+
placeholder: '1234 5678 9012 3456',
|
|
384
|
+
style: {
|
|
385
|
+
base: { color: '#1a1a1a', fontSize: '16px' },
|
|
386
|
+
focus: { borderColor: '#6366f1' },
|
|
387
|
+
invalid: { color: '#dc2626' },
|
|
388
|
+
complete: { color: '#16a34a' },
|
|
389
|
+
},
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
cardEl.mount('#card-number-container');
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
`ElementOptions`:
|
|
396
|
+
|
|
397
|
+
| Option | Type | Description |
|
|
398
|
+
|---|---|---|
|
|
399
|
+
| `style` | `ElementStyleConfig` | Per-state style overrides. See [Styling](#styling). |
|
|
400
|
+
| `placeholder` | `string` | Placeholder text (max 100 characters). |
|
|
401
|
+
| `disabled` | `boolean` | Disables the input. |
|
|
402
|
+
| `loadTimeoutMs` | `number` | Iframe load timeout in ms. Default: `10000`. |
|
|
403
|
+
|
|
404
|
+
**OzElement methods:**
|
|
405
|
+
|
|
406
|
+
| Method | Description |
|
|
407
|
+
|---|---|
|
|
408
|
+
| `.mount(target)` | Mount the iframe. Accepts a CSS selector string or `HTMLElement`. |
|
|
409
|
+
| `.unmount()` | Remove the iframe from the DOM. The element can be re-mounted. |
|
|
410
|
+
| `.destroy()` | Permanently destroy the element. Cannot be re-mounted. |
|
|
411
|
+
| `.update(options)` | Update placeholder, style, or disabled state without re-mounting. **Merge semantics** β only provided keys are applied; omitted keys retain their values. To reset a property, pass it with an empty string (e.g. `{ style: { base: { color: '' } } }`). To fully reset all styles, destroy and recreate the element. |
|
|
412
|
+
| `.clear()` | Clear the field value. |
|
|
413
|
+
| `.focus()` | Programmatically focus the input. |
|
|
414
|
+
| `.blur()` | Programmatically blur the input. |
|
|
415
|
+
| `.on(event, fn)` | Subscribe to an event. Returns `this` for chaining. |
|
|
416
|
+
| `.off(event, fn)` | Remove an event handler. |
|
|
417
|
+
| `.once(event, fn)` | Subscribe for a single invocation. |
|
|
418
|
+
| `.isReady` | `true` once the iframe has loaded and signalled ready. |
|
|
419
|
+
|
|
420
|
+
---
|
|
421
|
+
|
|
422
|
+
### vault.createToken(options?)
|
|
423
|
+
|
|
424
|
+
```ts
|
|
425
|
+
vault.createToken(options?: TokenizeOptions): Promise<TokenResponse>
|
|
426
|
+
```
|
|
427
|
+
|
|
428
|
+
Tokenizes all mounted and ready card elements. Raw values travel directly from element iframes to the tokenizer iframe via `MessageChannel` β they never pass through your page's JavaScript.
|
|
429
|
+
|
|
430
|
+
Returns a `TokenResponse`:
|
|
431
|
+
|
|
432
|
+
```ts
|
|
433
|
+
interface TokenResponse {
|
|
434
|
+
token: string; // Vault token β pass to cardSale
|
|
435
|
+
cvcSession: string; // CVC session β always present; pass to cardSale
|
|
436
|
+
card?: { // Card metadata β present when vault returns all four fields
|
|
437
|
+
last4: string; // e.g. "4242"
|
|
438
|
+
brand: string; // e.g. "visa"
|
|
439
|
+
expMonth: string; // e.g. "09"
|
|
440
|
+
expYear: string; // e.g. "2027"
|
|
441
|
+
};
|
|
442
|
+
billing?: BillingDetails; // Normalized billing β only present if billing was passed in
|
|
443
|
+
}
|
|
444
|
+
```
|
|
445
|
+
|
|
446
|
+
`TokenizeOptions`:
|
|
447
|
+
|
|
448
|
+
| Option | Type | Description |
|
|
449
|
+
|---|---|---|
|
|
450
|
+
| `billing` | `BillingDetails` | Validated and normalized billing details. Returned in `TokenResponse.billing`. |
|
|
451
|
+
| `firstName` | `string` | **Deprecated.** Pass inside `billing` instead. |
|
|
452
|
+
| `lastName` | `string` | **Deprecated.** Pass inside `billing` instead. |
|
|
453
|
+
|
|
454
|
+
Throws `OzError` if:
|
|
455
|
+
- The vault is not ready (`errorCode: 'unknown'`)
|
|
456
|
+
- A tokenization is already in progress
|
|
457
|
+
- Billing validation fails (`errorCode: 'validation'`)
|
|
458
|
+
- No elements are mounted
|
|
459
|
+
- The vault returns an error (`errorCode` reflects the HTTP status)
|
|
460
|
+
- The request times out after 30 seconds (`errorCode: 'timeout'`) β this timeout is separate from `loadTimeoutMs` and is not configurable
|
|
461
|
+
|
|
462
|
+
**`vault.tokenizeCount`**
|
|
463
|
+
|
|
464
|
+
```ts
|
|
465
|
+
vault.tokenizeCount: number // read-only getter
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
Returns the number of successful `createToken()` / `createBankToken()` calls made in the current session. Resets to `0` each time the session is refreshed (proactively or reactively). Use this in vanilla JS to display "attempts remaining" feedback or gate the submit button:
|
|
469
|
+
|
|
470
|
+
```ts
|
|
471
|
+
const MAX = 3; // matches maxTokenizeCalls
|
|
472
|
+
const remaining = MAX - vault.tokenizeCount;
|
|
473
|
+
payButton.textContent = `Pay (${remaining} attempt${remaining === 1 ? '' : 's'} remaining)`;
|
|
474
|
+
```
|
|
475
|
+
|
|
476
|
+
In React, use `tokenizeCount` from `useOzElements()` instead β it is a reactive state value and will trigger re-renders automatically.
|
|
477
|
+
|
|
478
|
+
---
|
|
479
|
+
|
|
480
|
+
### vault.createBankElement()
|
|
481
|
+
|
|
482
|
+
```ts
|
|
483
|
+
vault.createBankElement(type: BankElementType, options?: ElementOptions): OzElement
|
|
484
|
+
```
|
|
485
|
+
|
|
486
|
+
Creates a bank account element. `BankElementType`: `'accountNumber'` | `'routingNumber'`.
|
|
487
|
+
|
|
488
|
+
```ts
|
|
489
|
+
const accountEl = vault.createBankElement('accountNumber');
|
|
490
|
+
const routingEl = vault.createBankElement('routingNumber');
|
|
491
|
+
accountEl.mount('#account-number');
|
|
492
|
+
routingEl.mount('#routing-number');
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
---
|
|
496
|
+
|
|
497
|
+
### vault.createBankToken(options)
|
|
498
|
+
|
|
499
|
+
```ts
|
|
500
|
+
vault.createBankToken(options: BankTokenizeOptions): Promise<BankTokenResponse>
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
Tokenizes the mounted `accountNumber` and `routingNumber` elements. Both must be mounted and ready.
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
interface BankTokenizeOptions {
|
|
507
|
+
firstName: string; // Account holder first name (required, max 50 chars)
|
|
508
|
+
lastName: string; // Account holder last name (required, max 50 chars)
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
interface BankTokenResponse {
|
|
512
|
+
token: string;
|
|
513
|
+
bank?: {
|
|
514
|
+
last4: string; // Last 4 digits of account number
|
|
515
|
+
routingNumberLast4: string;
|
|
516
|
+
};
|
|
517
|
+
}
|
|
518
|
+
```
|
|
519
|
+
|
|
520
|
+
> **Note:** OzuraPay does not currently support bank account payments. Use the bank token with your own ACH processor. Bank tokens can be passed to any ACH-capable processor directly.
|
|
521
|
+
|
|
522
|
+
> **Card tokens and processors:** Card tokenization returns a `cvcSession` alongside the `token`. OzuraPay's charge API requires `cvcSession`. If you are routing to a non-Ozura processor, pass the `token` directly β your processor's documentation will tell you whether a CVC session token is required.
|
|
523
|
+
|
|
524
|
+
---
|
|
525
|
+
|
|
526
|
+
### vault.destroy()
|
|
527
|
+
|
|
528
|
+
```ts
|
|
529
|
+
vault.destroy(): void
|
|
530
|
+
```
|
|
531
|
+
|
|
532
|
+
Tears down the vault: removes all element and tokenizer iframes, clears the `message` event listener, rejects any pending `createToken()` / `createBankToken()` promises, and cancels active timeout handles. Call this when the checkout component unmounts.
|
|
533
|
+
|
|
534
|
+
```ts
|
|
535
|
+
// React useEffect cleanup β the cancel flag prevents a vault from leaking
|
|
536
|
+
// if the component unmounts before OzVault.create() resolves.
|
|
537
|
+
useEffect(() => {
|
|
538
|
+
let cancelled = false;
|
|
539
|
+
let vault: OzVault | null = null;
|
|
540
|
+
OzVault.create(options).then(v => {
|
|
541
|
+
if (cancelled) { v.destroy(); return; }
|
|
542
|
+
vault = v;
|
|
543
|
+
});
|
|
544
|
+
return () => {
|
|
545
|
+
cancelled = true;
|
|
546
|
+
vault?.destroy();
|
|
547
|
+
};
|
|
548
|
+
}, []);
|
|
549
|
+
```
|
|
550
|
+
|
|
551
|
+
---
|
|
552
|
+
|
|
553
|
+
### vault.reset()
|
|
554
|
+
|
|
555
|
+
```ts
|
|
556
|
+
vault.reset(): void
|
|
557
|
+
```
|
|
558
|
+
|
|
559
|
+
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 payment to let the customer re-enter their card details on the same checkout screen.
|
|
560
|
+
|
|
561
|
+
The session key, its remaining budget, and all iframes are fully preserved β no network calls are made.
|
|
562
|
+
|
|
563
|
+
**Session model:** One session covers the full checkout. The default `sessionLimit: 3` is enough for two declines and a final attempt. Use `vault.reset()` between declines β not `vault.destroy()` + recreate, which would waste the remaining budget and cause iframe flicker.
|
|
564
|
+
|
|
565
|
+
```ts
|
|
566
|
+
try {
|
|
567
|
+
const { token, cvcSession } = await vault.createToken({ billing });
|
|
568
|
+
await fetch('/api/charge', {
|
|
569
|
+
method: 'POST',
|
|
570
|
+
headers: { 'Content-Type': 'application/json' },
|
|
571
|
+
body: JSON.stringify({ token, cvcSession }),
|
|
572
|
+
});
|
|
573
|
+
} catch (err) {
|
|
574
|
+
vault.reset(); // clear fields; let customer re-enter
|
|
575
|
+
showError(err instanceof OzError ? err.message : 'Payment failed.');
|
|
576
|
+
}
|
|
577
|
+
```
|
|
578
|
+
|
|
579
|
+
---
|
|
580
|
+
|
|
581
|
+
### vault.debugState()
|
|
582
|
+
|
|
583
|
+
```ts
|
|
584
|
+
vault.debugState(): Record<string, unknown>
|
|
585
|
+
```
|
|
586
|
+
|
|
587
|
+
Returns a structured snapshot of the vault's internal state. Always available regardless of whether `debug: true` is set. Useful for attaching to support tickets or dumping on error.
|
|
588
|
+
|
|
589
|
+
```ts
|
|
590
|
+
console.log(vault.debugState());
|
|
591
|
+
// {
|
|
592
|
+
// vaultId: 'vault_abc12...',
|
|
593
|
+
// isReady: true,
|
|
594
|
+
// tokenizing: null,
|
|
595
|
+
// destroyed: false,
|
|
596
|
+
// waxKeyPresent: true,
|
|
597
|
+
// tokenizeSuccessCount: 1,
|
|
598
|
+
// maxTokenizeCalls: 3,
|
|
599
|
+
// resetCount: 0,
|
|
600
|
+
// elements: ['cardNumber', 'expirationDate', 'cvv'],
|
|
601
|
+
// bankElements: [],
|
|
602
|
+
// completionState: { 'a1b2c3d4': true, 'e5f6a7b8': true, '...' : false },
|
|
603
|
+
// pendingTokenizations: 0,
|
|
604
|
+
// pendingBankTokenizations: 0,
|
|
605
|
+
// }
|
|
606
|
+
```
|
|
607
|
+
|
|
608
|
+
No sensitive data is returned: wax keys, tokens, CVC sessions, and billing fields are never included.
|
|
609
|
+
|
|
610
|
+
---
|
|
611
|
+
|
|
612
|
+
### OzElement events
|
|
613
|
+
|
|
614
|
+
```ts
|
|
615
|
+
element.on('change', (event: ElementChangeEvent) => { ... });
|
|
616
|
+
element.on('focus', () => { ... });
|
|
617
|
+
element.on('blur', () => { ... });
|
|
618
|
+
element.on('ready', () => { ... });
|
|
619
|
+
element.on('loaderror', (payload: { elementType: string; error: string }) => { ... });
|
|
620
|
+
```
|
|
621
|
+
|
|
622
|
+
`ElementChangeEvent`:
|
|
623
|
+
|
|
624
|
+
| Field | Type | Description |
|
|
625
|
+
|---|---|---|
|
|
626
|
+
| `empty` | `boolean` | `true` when the field is empty. |
|
|
627
|
+
| `complete` | `boolean` | `true` when the field has enough digits to be complete. |
|
|
628
|
+
| `valid` | `boolean` | `true` when the value passes all validation (Luhn, expiry date, etc.). |
|
|
629
|
+
| `error` | `string \| undefined` | User-facing error message when `valid` is `false` and the field has been touched. |
|
|
630
|
+
| `cardBrand` | `string \| undefined` | Detected brand β only on `cardNumber` fields (e.g. `"visa"`, `"amex"`). |
|
|
631
|
+
| `month` | `string \| undefined` | Parsed 2-digit month β only on `expirationDate` fields. |
|
|
632
|
+
| `year` | `string \| undefined` | Parsed 2-digit year β only on `expirationDate` fields. |
|
|
633
|
+
|
|
634
|
+
> **Expiry data and PCI scope:** The expiry `onChange` event delivers parsed `month` and `year` to your handler for display purposes (e.g. "Card expires MM/YY"). These are not PANs or CVVs, but they are cardholder data. If your PCI scope requires zero cardholder data on the merchant page, do not read, log, or store these fields.
|
|
635
|
+
|
|
636
|
+
Auto-advance is built in: the vault automatically moves focus from card number β expiry β CVV when each field completes. No additional code required.
|
|
637
|
+
|
|
638
|
+
---
|
|
639
|
+
|
|
640
|
+
## React API
|
|
641
|
+
|
|
642
|
+
> π [React guide](https://docs.ozura.com/sdks/elements/react) β `OzElements` provider, `useOzElements` hook, pre-built `OzCard` and `OzBankCard` components, and StrictMode behaviour.
|
|
643
|
+
|
|
644
|
+
### OzElements provider
|
|
645
|
+
|
|
646
|
+
```tsx
|
|
647
|
+
import { OzElements } from '@ozura/elements/react';
|
|
648
|
+
|
|
649
|
+
<OzElements
|
|
650
|
+
pubKey="pk_live_..."
|
|
651
|
+
sessionUrl="/api/oz-session"
|
|
652
|
+
appearance={{ theme: 'flat', variables: { colorPrimary: '#6366f1' } }}
|
|
653
|
+
onLoadError={() => setPaymentUnavailable(true)}
|
|
654
|
+
>
|
|
655
|
+
{children}
|
|
656
|
+
</OzElements>
|
|
657
|
+
```
|
|
658
|
+
|
|
659
|
+
All `VaultOptions` are accepted as props. The provider creates a single `OzVault` instance and destroys it on unmount.
|
|
660
|
+
|
|
661
|
+
> **Prop changes and vault lifecycle:** Changing `pubKey`, `sessionUrl`, `frameBaseUrl`, `loadTimeoutMs`, `appearance`, `fonts`, or `sessionLimit` destroys the current vault and creates a new one β all field iframes will remount. Changing `getSessionKey`, `fetchWaxKey`, `onLoadError`, `onSessionRefresh`, or `onReady` updates the callback in place via refs without recreating the vault.
|
|
662
|
+
|
|
663
|
+
> **One card form per provider:** A vault holds one element per field type (`cardNumber`, `expiry`, `cvv`, etc.). Rendering two `<OzCard>` components under the same `<OzElements>` provider will cause the second to silently replace the first's iframes, breaking the first form. If you genuinely need two independent card forms on the same page, wrap each in its own `<OzElements>` provider with separate `pubKey` / `sessionUrl` configurations.
|
|
664
|
+
|
|
665
|
+
---
|
|
666
|
+
|
|
667
|
+
### OzCard
|
|
668
|
+
|
|
669
|
+
Drop-in combined card component. Renders card number, expiry, and CVV with a configurable layout.
|
|
670
|
+
|
|
671
|
+
```tsx
|
|
672
|
+
import { OzCard } from '@ozura/elements/react';
|
|
673
|
+
|
|
674
|
+
<OzCard
|
|
675
|
+
layout="default" // "default" (number on top, expiry+CVV below) | "rows" (stacked)
|
|
676
|
+
onChange={(state) => {
|
|
677
|
+
// state.complete β all three fields complete + valid
|
|
678
|
+
// state.cardBrand β detected brand
|
|
679
|
+
// state.error β first error across all fields
|
|
680
|
+
// state.fields β per-field ElementChangeEvent objects
|
|
681
|
+
}}
|
|
682
|
+
onReady={() => console.log('all card fields loaded')}
|
|
683
|
+
disabled={isSubmitting}
|
|
684
|
+
labels={{ cardNumber: 'Card Number', expiry: 'Expiry', cvv: 'CVV' }}
|
|
685
|
+
placeholders={{ cardNumber: '1234 5678 9012 3456', expiry: 'MM/YY', cvv: 'Β·Β·Β·' }}
|
|
686
|
+
/>
|
|
687
|
+
```
|
|
688
|
+
|
|
689
|
+
`OzCardProps` (full):
|
|
690
|
+
|
|
691
|
+
| Prop | Type | Description |
|
|
692
|
+
|---|---|---|
|
|
693
|
+
| `layout` | `'default' \| 'rows'` | `'default'`: number full-width, expiry+CVV side by side. `'rows'`: all stacked. |
|
|
694
|
+
| `gap` | `number \| string` | Gap between fields. Default: `8` (px). |
|
|
695
|
+
| `style` | `ElementStyleConfig` | Shared style applied to all three inputs. |
|
|
696
|
+
| `styles` | `{ cardNumber?, expiry?, cvv? }` | Per-field overrides merged on top of `style`. |
|
|
697
|
+
| `classNames` | `{ cardNumber?, expiry?, cvv?, row? }` | CSS class names for field wrappers and the expiry+CVV row. |
|
|
698
|
+
| `labels` | `{ cardNumber?, expiry?, cvv? }` | Optional label text above each field. |
|
|
699
|
+
| `labelStyle` | `React.CSSProperties` | Style applied to all `<label>` elements. |
|
|
700
|
+
| `labelClassName` | `string` | Class applied to all `<label>` elements. |
|
|
701
|
+
| `placeholders` | `{ cardNumber?, expiry?, cvv? }` | Custom placeholder text per field. |
|
|
702
|
+
| `hideErrors` | `boolean` | Suppress the built-in error display. Handle via `onChange`. |
|
|
703
|
+
| `errorStyle` | `React.CSSProperties` | Style for the built-in error container. |
|
|
704
|
+
| `errorClassName` | `string` | Class for the built-in error container. |
|
|
705
|
+
| `renderError` | `(error: string) => ReactNode` | Custom error renderer. |
|
|
706
|
+
| `onChange` | `(state: OzCardState) => void` | Fires on any field change. |
|
|
707
|
+
| `onReady` | `() => void` | Fires once all three iframes have loaded. |
|
|
708
|
+
| `onFocus` | `(field: 'cardNumber' \| 'expiry' \| 'cvv') => void` | |
|
|
709
|
+
| `onBlur` | `(field: 'cardNumber' \| 'expiry' \| 'cvv') => void` | |
|
|
710
|
+
| `disabled` | `boolean` | Disable all inputs. |
|
|
711
|
+
| `className` | `string` | Class for the outer wrapper. |
|
|
712
|
+
|
|
713
|
+
---
|
|
714
|
+
|
|
715
|
+
### Individual field components
|
|
716
|
+
|
|
717
|
+
For custom layouts where `OzCard` is too opinionated:
|
|
718
|
+
|
|
719
|
+
```tsx
|
|
720
|
+
import { OzCardNumber, OzExpiry, OzCvv } from '@ozura/elements/react';
|
|
721
|
+
|
|
722
|
+
<OzCardNumber onChange={handleChange} placeholder="Card number" />
|
|
723
|
+
<OzExpiry onChange={handleChange} />
|
|
724
|
+
<OzCvv onChange={handleChange} />
|
|
725
|
+
```
|
|
726
|
+
|
|
727
|
+
All accept `OzFieldProps`:
|
|
728
|
+
|
|
729
|
+
| Prop | Type | Description |
|
|
730
|
+
|---|---|---|
|
|
731
|
+
| `style` | `ElementStyleConfig` | Input styles. |
|
|
732
|
+
| `placeholder` | `string` | Placeholder text. |
|
|
733
|
+
| `disabled` | `boolean` | Disables the input. |
|
|
734
|
+
| `loadTimeoutMs` | `number` | Iframe load timeout in ms. |
|
|
735
|
+
| `onChange` | `(event: ElementChangeEvent) => void` | |
|
|
736
|
+
| `onFocus` | `() => void` | |
|
|
737
|
+
| `onBlur` | `() => void` | |
|
|
738
|
+
| `onReady` | `() => void` | |
|
|
739
|
+
| `onLoadError` | `(error: string) => void` | |
|
|
740
|
+
| `className` | `string` | Class for the outer wrapper div. |
|
|
741
|
+
|
|
742
|
+
---
|
|
743
|
+
|
|
744
|
+
### OzBankCard
|
|
745
|
+
|
|
746
|
+
```tsx
|
|
747
|
+
import { OzBankCard } from '@ozura/elements/react';
|
|
748
|
+
|
|
749
|
+
<OzBankCard
|
|
750
|
+
onChange={(state) => {
|
|
751
|
+
// state.complete, state.error, state.fields.accountNumber, state.fields.routingNumber
|
|
752
|
+
}}
|
|
753
|
+
labels={{ accountNumber: 'Account Number', routingNumber: 'Routing Number' }}
|
|
754
|
+
/>
|
|
755
|
+
```
|
|
756
|
+
|
|
757
|
+
Or use individual bank components:
|
|
758
|
+
|
|
759
|
+
```tsx
|
|
760
|
+
import { OzBankAccountNumber, OzBankRoutingNumber } from '@ozura/elements/react';
|
|
761
|
+
|
|
762
|
+
<OzBankAccountNumber onChange={handleChange} />
|
|
763
|
+
<OzBankRoutingNumber onChange={handleChange} />
|
|
764
|
+
```
|
|
765
|
+
|
|
766
|
+
---
|
|
767
|
+
|
|
768
|
+
### useOzElements()
|
|
769
|
+
|
|
770
|
+
```ts
|
|
771
|
+
const { createToken, createBankToken, reset, ready, initError, tokenizeCount } = useOzElements();
|
|
772
|
+
```
|
|
773
|
+
|
|
774
|
+
Must be called from inside an `<OzElements>` provider tree.
|
|
775
|
+
|
|
776
|
+
| Return | Type | Description |
|
|
777
|
+
|---|---|---|
|
|
778
|
+
| `createToken` | `(options?: TokenizeOptions) => Promise<TokenResponse>` | Tokenize mounted card elements. |
|
|
779
|
+
| `createBankToken` | `(options: BankTokenizeOptions) => Promise<BankTokenResponse>` | Tokenize mounted bank elements. |
|
|
780
|
+
| `reset` | `() => void` | Clear all mounted element fields without destroying the vault or refreshing the session. Call after a declined payment so the customer can re-enter their details. |
|
|
781
|
+
| `ready` | `boolean` | `true` when the tokenizer **and** all mounted element iframes are ready. Gate your submit button on this. See note below. |
|
|
782
|
+
| `initError` | `Error \| null` | Non-null if `OzVault.create()` failed (e.g. session endpoint unreachable). Render a fallback UI. |
|
|
783
|
+
| `tokenizeCount` | `number` | Number of successful tokenizations in the current session. Resets on session refresh or provider re-init. Useful for tracking calls against `sessionLimit`. |
|
|
784
|
+
|
|
785
|
+
> **`ready` vs `vault.isReady`:** `ready` from `useOzElements()` is a composite β it combines `vault.isReady` (tokenizer loaded) with element readiness (all mounted input iframes loaded). `vault.isReady` alone is insufficient for gating a submit button. Always use `ready` from `useOzElements()` in React.
|
|
786
|
+
|
|
787
|
+
---
|
|
788
|
+
|
|
789
|
+
## Styling
|
|
790
|
+
|
|
791
|
+
> π [Styling guide](https://docs.ozura.com/sdks/elements/styling) β full property allowlist, theme variables, `appearance` options, custom fonts, and `var()` limitations.
|
|
792
|
+
|
|
793
|
+
### Per-element styles
|
|
794
|
+
|
|
795
|
+
Styles apply inside each iframe's `<input>` element. Only an explicit allowlist of CSS properties is accepted (typography, spacing, borders, box-shadow, cursor, transitions). Values containing `url()`, `var()`, `expression()`, `javascript:`, or CSS breakout characters are blocked on both the SDK and iframe sides. Use literal values instead of CSS custom properties (`var(--token)` is rejected). When a value is stripped, the browser falls back to the element's default (unstyled) appearance for that property β the failure is silent with no error or console warning. Resolve design tokens to literal values before passing them in.
|
|
796
|
+
|
|
797
|
+
```ts
|
|
798
|
+
const style: ElementStyleConfig = {
|
|
799
|
+
base: {
|
|
800
|
+
color: '#1a1a1a',
|
|
801
|
+
fontSize: '16px',
|
|
802
|
+
fontFamily: '"Inter", sans-serif',
|
|
803
|
+
padding: '10px 12px',
|
|
804
|
+
backgroundColor: '#ffffff',
|
|
805
|
+
borderRadius: '6px',
|
|
806
|
+
border: '1px solid #d1d5db',
|
|
807
|
+
},
|
|
808
|
+
focus: {
|
|
809
|
+
borderColor: '#6366f1',
|
|
810
|
+
boxShadow: '0 0 0 3px rgba(99,102,241,0.15)',
|
|
811
|
+
outline: 'none',
|
|
812
|
+
},
|
|
813
|
+
invalid: {
|
|
814
|
+
borderColor: '#ef4444',
|
|
815
|
+
color: '#dc2626',
|
|
816
|
+
},
|
|
817
|
+
complete: {
|
|
818
|
+
borderColor: '#22c55e',
|
|
819
|
+
},
|
|
820
|
+
placeholder: {
|
|
821
|
+
color: '#9ca3af',
|
|
822
|
+
},
|
|
823
|
+
};
|
|
824
|
+
```
|
|
825
|
+
|
|
826
|
+
State precedence: `placeholder` applies to the `::placeholder` pseudo-element. `focus`, `invalid`, and `complete` merge on top of `base`.
|
|
827
|
+
|
|
828
|
+
### Global appearance
|
|
829
|
+
|
|
830
|
+
Apply a preset theme and/or variable overrides to all elements at once:
|
|
831
|
+
|
|
832
|
+
```ts
|
|
833
|
+
// OzVault.create
|
|
834
|
+
const vault = await OzVault.create({
|
|
835
|
+
pubKey: '...',
|
|
836
|
+
sessionUrl: '/api/oz-session',
|
|
837
|
+
appearance: {
|
|
838
|
+
theme: 'flat', // 'default' | 'night' | 'flat'
|
|
839
|
+
variables: {
|
|
840
|
+
colorText: '#1a1a1a',
|
|
841
|
+
colorBackground: '#ffffff',
|
|
842
|
+
colorPrimary: '#6366f1', // focus caret + color
|
|
843
|
+
colorDanger: '#dc2626', // invalid state
|
|
844
|
+
colorSuccess: '#16a34a', // complete state
|
|
845
|
+
colorPlaceholder: '#9ca3af',
|
|
846
|
+
fontFamily: '"Inter", sans-serif',
|
|
847
|
+
fontSize: '15px',
|
|
848
|
+
fontWeight: '400',
|
|
849
|
+
padding: '10px 14px',
|
|
850
|
+
letterSpacing: '0.01em',
|
|
851
|
+
},
|
|
852
|
+
},
|
|
853
|
+
});
|
|
854
|
+
|
|
855
|
+
// React provider
|
|
856
|
+
<OzElements pubKey="..." sessionUrl="..." appearance={{ theme: 'night' }}>
|
|
857
|
+
```
|
|
858
|
+
|
|
859
|
+
Per-element `style` takes precedence over `appearance` variables.
|
|
860
|
+
|
|
861
|
+
> **`appearance: {}` is not "no theme":** Passing `appearance: {}` or `appearance: { variables: { ... } }` without a `theme` key applies the `'default'` preset as a base. To render elements with no preset styling, omit `appearance` entirely and use per-element `style` overrides.
|
|
862
|
+
>
|
|
863
|
+
> | `appearance` value | Result |
|
|
864
|
+
> |---|---|
|
|
865
|
+
> | *(omitted entirely)* | No preset β element uses minimal built-in defaults |
|
|
866
|
+
> | `{}` | Equivalent to `{ theme: 'default' }` β full default theme applied |
|
|
867
|
+
> | `{ theme: 'night' }` | Night theme |
|
|
868
|
+
> | `{ variables: { colorText: '#333' } }` | Default theme + variable overrides |
|
|
869
|
+
|
|
870
|
+
### Custom fonts
|
|
871
|
+
|
|
872
|
+
Fonts are injected into each iframe so they render inside the input fields:
|
|
873
|
+
|
|
874
|
+
```ts
|
|
875
|
+
fonts: [
|
|
876
|
+
// Google Fonts or any HTTPS CSS URL
|
|
877
|
+
{ cssSrc: 'https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap' },
|
|
878
|
+
|
|
879
|
+
// Custom @font-face
|
|
880
|
+
{
|
|
881
|
+
family: 'BrandFont',
|
|
882
|
+
src: 'url(https://cdn.example.com/brand-font.woff2)',
|
|
883
|
+
weight: '400',
|
|
884
|
+
style: 'normal',
|
|
885
|
+
display: 'swap',
|
|
886
|
+
},
|
|
887
|
+
]
|
|
888
|
+
```
|
|
889
|
+
|
|
890
|
+
Font `src` values must start with `url(https://...)`. HTTP and data URIs are rejected.
|
|
891
|
+
|
|
892
|
+
---
|
|
893
|
+
|
|
894
|
+
## Billing details
|
|
895
|
+
|
|
896
|
+
```ts
|
|
897
|
+
interface BillingDetails {
|
|
898
|
+
firstName: string; // 1β50 characters
|
|
899
|
+
lastName: string; // 1β50 characters
|
|
900
|
+
email?: string; // Valid email, max 50 characters
|
|
901
|
+
phone?: string; // E.164 format, e.g. "+15551234567", max 50 characters
|
|
902
|
+
address?: {
|
|
903
|
+
line1: string; // 1β50 characters
|
|
904
|
+
line2?: string; // Optional, omitted from cardSale if blank
|
|
905
|
+
city: string; // 1β50 characters
|
|
906
|
+
state: string; // For US/CA: normalized to 2-letter abbreviation
|
|
907
|
+
zip: string; // 1β50 characters
|
|
908
|
+
country: string; // ISO 3166-1 alpha-2, e.g. "US"
|
|
909
|
+
};
|
|
910
|
+
}
|
|
911
|
+
```
|
|
912
|
+
|
|
913
|
+
Billing is validated and normalized by both `vault.createToken()` and the server-side handler factories. `TokenResponse.billing` contains the normalized result ready to spread into a `cardSale` call.
|
|
914
|
+
|
|
915
|
+
---
|
|
916
|
+
|
|
917
|
+
## Error handling
|
|
918
|
+
|
|
919
|
+
> π [Error handling guide](https://docs.ozura.com/sdks/elements/error-handling) β `OzError` fields, every `errorCode` value, retry guidance, and session expiry behaviour.
|
|
920
|
+
|
|
921
|
+
All SDK errors are instances of `OzError`:
|
|
922
|
+
|
|
923
|
+
```ts
|
|
924
|
+
import { OzError } from '@ozura/elements';
|
|
925
|
+
|
|
926
|
+
try {
|
|
927
|
+
const { token } = await vault.createToken({ billing });
|
|
928
|
+
} catch (err) {
|
|
929
|
+
if (err instanceof OzError) {
|
|
930
|
+
switch (err.errorCode) {
|
|
931
|
+
case 'network': // Connection failure β show retry UI
|
|
932
|
+
case 'timeout': // 30s deadline exceeded β safe to retry
|
|
933
|
+
case 'server': // 5xx from vault β transient, safe to retry
|
|
934
|
+
if (err.retryable) showRetryPrompt();
|
|
935
|
+
break;
|
|
936
|
+
|
|
937
|
+
case 'auth': // Bad pub key / API key β configuration issue
|
|
938
|
+
case 'validation': // Bad card data β show field-level error
|
|
939
|
+
case 'config': // frameBaseUrl not in permitted allowlist
|
|
940
|
+
case 'unknown':
|
|
941
|
+
showError(err.message);
|
|
942
|
+
break;
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
}
|
|
946
|
+
```
|
|
947
|
+
|
|
948
|
+
`OzError` fields:
|
|
949
|
+
|
|
950
|
+
| Field | Type | Description |
|
|
951
|
+
|---|---|---|
|
|
952
|
+
| `message` | `string` | Human-readable, consumer-facing error message. |
|
|
953
|
+
| `errorCode` | `OzErrorCode` | `'network' \| 'timeout' \| 'auth' \| 'validation' \| 'server' \| 'config' \| 'unknown'` |
|
|
954
|
+
| `raw` | `string` | Raw error string from the vault API, if available. |
|
|
955
|
+
| `retryable` | `boolean` | `true` for `network`, `timeout`, `server`. `false` for `auth`, `validation`, `config`, `unknown`. |
|
|
956
|
+
|
|
957
|
+
> **Session expiry is handled automatically.** When a session expires or is consumed between initialization and the user clicking Pay, the SDK silently fetches a fresh session and retries the tokenization once. You will only receive an `auth` error if the session refresh itself fails β for example, if your `/api/oz-session` backend endpoint is unreachable. A healthy `auth` error in production means your session endpoint needs attention, not that the user's card is bad.
|
|
958
|
+
|
|
959
|
+
**Error normalisation helpers** (for displaying errors from `cardSale` to users):
|
|
960
|
+
|
|
961
|
+
```ts
|
|
962
|
+
import { normalizeVaultError, normalizeBankVaultError, normalizeCardSaleError } from '@ozura/elements';
|
|
963
|
+
|
|
964
|
+
// Maps vault tokenize error strings to user-facing copy
|
|
965
|
+
const display = normalizeVaultError(err.raw); // card flows
|
|
966
|
+
const display = normalizeBankVaultError(err.raw); // bank/ACH flows
|
|
967
|
+
const display = normalizeCardSaleError(err.message); // cardSale API errors
|
|
968
|
+
```
|
|
969
|
+
|
|
970
|
+
---
|
|
971
|
+
|
|
972
|
+
## Debug mode
|
|
973
|
+
|
|
974
|
+
Pass `debug: true` in `VaultOptions` (or as a prop on `<OzElements>`) to activate structured console logging at every SDK lifecycle event.
|
|
975
|
+
|
|
976
|
+
```ts
|
|
977
|
+
const vault = await OzVault.create({
|
|
978
|
+
pubKey: 'pk_live_...',
|
|
979
|
+
sessionUrl: '/api/oz-session',
|
|
980
|
+
debug: true, // enables [OzVault] console.log output
|
|
981
|
+
});
|
|
982
|
+
```
|
|
983
|
+
|
|
984
|
+
```tsx
|
|
985
|
+
// React
|
|
986
|
+
<OzElements pubKey="pk_live_..." sessionUrl="/api/oz-session" debug>
|
|
987
|
+
...
|
|
988
|
+
</OzElements>
|
|
989
|
+
```
|
|
990
|
+
|
|
991
|
+
Each log entry is a `[OzVault] <message>` prefixed `console.log` call. Events logged include:
|
|
992
|
+
|
|
993
|
+
| Event | When it fires |
|
|
994
|
+
|---|---|
|
|
995
|
+
| `vault created` | Constructor completes |
|
|
996
|
+
| `wax key received` | `fetchWaxKey` resolves |
|
|
997
|
+
| `mounting tokenizer iframe` | Tokenizer iframe creation begins |
|
|
998
|
+
| `tokenizer iframe ready` | Tokenizer iframe handshake complete |
|
|
999
|
+
| `element iframe ready` | Each card/bank input iframe loads |
|
|
1000
|
+
| `field changed` | Per-field `change` event (empty/complete/valid/auto-advance state) |
|
|
1001
|
+
| `auto-advance` | Focus moves automatically between card fields |
|
|
1002
|
+
| `createToken() called` | Entry to `createToken()` |
|
|
1003
|
+
| `OZ_TOKENIZE sent` | Tokenize request dispatched to iframe |
|
|
1004
|
+
| `token received` | Token result returned (with elapsed ms) |
|
|
1005
|
+
| `token error` | Vault or network error during tokenize |
|
|
1006
|
+
| `proactive wax key refresh triggered` | Budget exhausted; refresh starting |
|
|
1007
|
+
| `wax key refresh started/succeeded/failed` | Refresh lifecycle |
|
|
1008
|
+
| `tab hidden` / `tab visible` | `visibilitychange` events |
|
|
1009
|
+
| `reset() called` | `vault.reset()` entry |
|
|
1010
|
+
| `destroy() called` | `vault.destroy()` entry |
|
|
1011
|
+
|
|
1012
|
+
**Security:** No sensitive data is ever logged. Wax keys, tokens, CVC sessions, and billing fields appear only as boolean presence flags (`waxKeyPresent: true`). Frame IDs and request IDs are truncated.
|
|
1013
|
+
|
|
1014
|
+
### vault.debugState()
|
|
1015
|
+
|
|
1016
|
+
`vault.debugState()` is always available β regardless of whether `debug: true` was set β and returns a one-time snapshot for attaching to bug reports:
|
|
1017
|
+
|
|
1018
|
+
```ts
|
|
1019
|
+
console.log(vault.debugState());
|
|
1020
|
+
```
|
|
1021
|
+
|
|
1022
|
+
Sample output:
|
|
1023
|
+
|
|
1024
|
+
```json
|
|
1025
|
+
{
|
|
1026
|
+
"vaultId": "vault_abc12...",
|
|
1027
|
+
"isReady": true,
|
|
1028
|
+
"tokenizing": null,
|
|
1029
|
+
"destroyed": false,
|
|
1030
|
+
"waxKeyPresent": true,
|
|
1031
|
+
"tokenizeSuccessCount": 1,
|
|
1032
|
+
"maxTokenizeCalls": 3,
|
|
1033
|
+
"resetCount": 0,
|
|
1034
|
+
"elements": ["cardNumber", "expirationDate", "cvv"],
|
|
1035
|
+
"bankElements": [],
|
|
1036
|
+
"completionState": { "a1b2c3d4": true, "e5f6a7b8": true, "c9d0e1f2": false },
|
|
1037
|
+
"pendingTokenizations": 0,
|
|
1038
|
+
"pendingBankTokenizations": 0
|
|
1039
|
+
}
|
|
1040
|
+
```
|
|
1041
|
+
|
|
1042
|
+
---
|
|
1043
|
+
|
|
1044
|
+
## Server utilities
|
|
1045
|
+
|
|
1046
|
+
> π [Server SDK guide](https://docs.ozura.com/sdks/elements/server) β `Ozura` class methods, route handler factories, `getClientIp`, error types, and rate limits.
|
|
1047
|
+
|
|
1048
|
+
### Ozura class
|
|
1049
|
+
|
|
1050
|
+
```ts
|
|
1051
|
+
import { Ozura, OzuraError } from '@ozura/elements/server';
|
|
1052
|
+
|
|
1053
|
+
const ozura = new Ozura({
|
|
1054
|
+
merchantId: process.env.MERCHANT_ID!,
|
|
1055
|
+
apiKey: process.env.MERCHANT_API_KEY!,
|
|
1056
|
+
vaultKey: process.env.VAULT_API_KEY!,
|
|
1057
|
+
// apiUrl: 'https://api.ozura.com', // override Pay API URL
|
|
1058
|
+
// vaultUrl: 'https://vault.ozura.com', // override vault URL
|
|
1059
|
+
timeoutMs: 30000, // default
|
|
1060
|
+
retries: 2, // max retry attempts for 5xx/network errors (3 total attempts)
|
|
1061
|
+
});
|
|
1062
|
+
```
|
|
1063
|
+
|
|
1064
|
+
> **Tokenize-only integrations** (session creation + tokenize cards, no charging) only need `vaultKey`. The `merchantId` and `apiKey` fields are optional β they are validated lazily and only required when `cardSale()` is called.
|
|
1065
|
+
>
|
|
1066
|
+
> ```ts
|
|
1067
|
+
> const ozura = new Ozura({ vaultKey: process.env.VAULT_API_KEY! });
|
|
1068
|
+
> ```
|
|
1069
|
+
|
|
1070
|
+
**Methods:**
|
|
1071
|
+
|
|
1072
|
+
```ts
|
|
1073
|
+
// Charge a tokenized card
|
|
1074
|
+
const result = await ozura.cardSale({
|
|
1075
|
+
token: tokenResponse.token,
|
|
1076
|
+
cvcSession: tokenResponse.cvcSession,
|
|
1077
|
+
amount: '49.00',
|
|
1078
|
+
currency: 'USD', // default: 'USD'
|
|
1079
|
+
billing: tokenResponse.billing,
|
|
1080
|
+
clientIpAddress: '1.2.3.4', // fetch server-side, never from the browser
|
|
1081
|
+
// surchargePercent, tipAmount, salesTaxExempt, processor
|
|
1082
|
+
});
|
|
1083
|
+
// result.transactionId, result.amount, result.cardLastFour, result.cardBrand
|
|
1084
|
+
// result.surchargeAmount and result.tipAmount are optional β only present when non-zero
|
|
1085
|
+
const surcharge = result.surchargeAmount ?? '0.00';
|
|
1086
|
+
const tip = result.tipAmount ?? '0.00';
|
|
1087
|
+
|
|
1088
|
+
// Create a session key (for custom session endpoint implementations)
|
|
1089
|
+
const { sessionKey, expiresInSeconds } = await ozura.createSession({
|
|
1090
|
+
sessionId,
|
|
1091
|
+
sessionLimit: 3, // must match VaultOptions.sessionLimit on the client (default: 3)
|
|
1092
|
+
// pass null to remove the cap (vault default = unlimited)
|
|
1093
|
+
// Optional β stored in vault audit log for correlation with your own records:
|
|
1094
|
+
// orderId: order.id,
|
|
1095
|
+
// customerId: user.id,
|
|
1096
|
+
// cartId: cart.id,
|
|
1097
|
+
// metadata: { source: 'web' },
|
|
1098
|
+
// ttlSeconds: 600, // shorter TTL for quicker checkouts (default: 1800)
|
|
1099
|
+
});
|
|
1100
|
+
|
|
1101
|
+
// Revoke a session β call on all three session-end paths
|
|
1102
|
+
// Best-effort β never throws. Shortens the exposure window before the vault's ~30 min TTL.
|
|
1103
|
+
await ozura.revokeSession(sessionKey);
|
|
1104
|
+
|
|
1105
|
+
// Suggested pattern β wire all three exit paths:
|
|
1106
|
+
// 1. Payment success
|
|
1107
|
+
const result = await ozura.cardSale({ ... });
|
|
1108
|
+
await ozura.revokeSession(sessionKey); // session is spent; close the window immediately
|
|
1109
|
+
|
|
1110
|
+
// 2. User cancels checkout
|
|
1111
|
+
router.post('/api/cancel', async (req) => {
|
|
1112
|
+
const { sessionKey } = await db.session.get(req.sessionId);
|
|
1113
|
+
await ozura.revokeSession(sessionKey);
|
|
1114
|
+
return Response.json({ ok: true });
|
|
1115
|
+
});
|
|
1116
|
+
|
|
1117
|
+
// 3. Page/tab close (best-effort β browser may not deliver this)
|
|
1118
|
+
// Use sendBeacon so the request survives navigation / tab close.
|
|
1119
|
+
window.addEventListener('visibilitychange', () => {
|
|
1120
|
+
if (document.visibilityState === 'hidden') {
|
|
1121
|
+
navigator.sendBeacon('/api/cancel', JSON.stringify({ sessionId }));
|
|
1122
|
+
}
|
|
1123
|
+
});
|
|
1124
|
+
|
|
1125
|
+
// List transactions
|
|
1126
|
+
const { transactions, pagination } = await ozura.listTransactions({
|
|
1127
|
+
dateFrom: '2025-01-01',
|
|
1128
|
+
dateTo: '2025-12-31',
|
|
1129
|
+
transactionType: 'CreditCardSale',
|
|
1130
|
+
page: 1,
|
|
1131
|
+
limit: 50,
|
|
1132
|
+
});
|
|
1133
|
+
```
|
|
1134
|
+
|
|
1135
|
+
**`OzuraError`** (thrown by all `Ozura` methods):
|
|
1136
|
+
|
|
1137
|
+
```ts
|
|
1138
|
+
try {
|
|
1139
|
+
await ozura.cardSale(input);
|
|
1140
|
+
} catch (err) {
|
|
1141
|
+
if (err instanceof OzuraError) {
|
|
1142
|
+
err.statusCode; // HTTP status code
|
|
1143
|
+
err.message; // Normalized message
|
|
1144
|
+
err.raw; // Raw API response string
|
|
1145
|
+
err.retryAfter; // Seconds (only present on 429)
|
|
1146
|
+
}
|
|
1147
|
+
}
|
|
1148
|
+
```
|
|
1149
|
+
|
|
1150
|
+
Rate limits: `cardSale` β 100 req/min per merchant. `listTransactions` β 200 req/min per merchant.
|
|
1151
|
+
|
|
1152
|
+
> **Retry behavior:** `createSession` and `listTransactions` retry on 5xx and network errors using exponential backoff (1 s / 2 s / 4 sβ¦) up to `retries + 1` total attempts. **`cardSale` is never retried** β it is a non-idempotent financial operation and the result of a duplicate charge cannot be predicted.
|
|
1153
|
+
|
|
1154
|
+
---
|
|
1155
|
+
|
|
1156
|
+
### Route handler factories
|
|
1157
|
+
|
|
1158
|
+
The server package exports factory functions covering two runtimes Γ two endpoints:
|
|
1159
|
+
|
|
1160
|
+
| Function | Runtime | Endpoint |
|
|
1161
|
+
|---|---|---|
|
|
1162
|
+
| `createSessionHandler` | Fetch API (Next.js App Router, Cloudflare, Vercel Edge) | `POST /api/oz-session` |
|
|
1163
|
+
| `createSessionMiddleware` | Express / Connect | `POST /api/oz-session` |
|
|
1164
|
+
| `createCardSaleHandler` | Fetch API | `POST /api/charge` |
|
|
1165
|
+
| `createCardSaleMiddleware` | Express / Connect | `POST /api/charge` |
|
|
1166
|
+
|
|
1167
|
+
`createCardSaleHandler` / `createCardSaleMiddleware` accept a `CardSaleHandlerOptions` object:
|
|
1168
|
+
|
|
1169
|
+
```ts
|
|
1170
|
+
interface CardSaleHandlerOptions {
|
|
1171
|
+
/**
|
|
1172
|
+
* Required. Return the charge amount as a decimal string.
|
|
1173
|
+
* Never trust the amount from the request body β resolve it from your database.
|
|
1174
|
+
*/
|
|
1175
|
+
getAmount: (body: Record<string, unknown>) => Promise<string>;
|
|
1176
|
+
|
|
1177
|
+
/**
|
|
1178
|
+
* Optional. Return the ISO 4217 currency code. Default: "USD".
|
|
1179
|
+
*/
|
|
1180
|
+
getCurrency?: (body: Record<string, unknown>) => Promise<string>;
|
|
1181
|
+
}
|
|
1182
|
+
```
|
|
1183
|
+
|
|
1184
|
+
Both handler factories validate `Content-Type: application/json`, run `validateBilling()`, extract the client IP from standard proxy headers, and return normalized `{ transactionId, amount, cardLastFour, cardBrand }` on success.
|
|
1185
|
+
|
|
1186
|
+
---
|
|
1187
|
+
|
|
1188
|
+
## Local development
|
|
1189
|
+
|
|
1190
|
+
The repository includes a development server at `dev-server.mjs` that serves the built frame assets and proxies vault API requests:
|
|
1191
|
+
|
|
1192
|
+
```bash
|
|
1193
|
+
npm run dev # build + start dev server on http://localhost:4242
|
|
1194
|
+
```
|
|
1195
|
+
|
|
1196
|
+
Set `frameBaseUrl` to point your vault at the local server:
|
|
1197
|
+
|
|
1198
|
+
```ts
|
|
1199
|
+
const vault = await OzVault.create({
|
|
1200
|
+
pubKey: 'pk_test_...',
|
|
1201
|
+
sessionUrl: '/api/oz-session',
|
|
1202
|
+
frameBaseUrl: 'http://localhost:4242', // local dev only
|
|
1203
|
+
});
|
|
1204
|
+
```
|
|
1205
|
+
|
|
1206
|
+
Or in React:
|
|
1207
|
+
|
|
1208
|
+
```tsx
|
|
1209
|
+
<OzElements
|
|
1210
|
+
pubKey="pk_test_..."
|
|
1211
|
+
sessionUrl="/api/oz-session"
|
|
1212
|
+
frameBaseUrl="http://localhost:4242"
|
|
1213
|
+
>
|
|
1214
|
+
```
|
|
1215
|
+
|
|
1216
|
+
Configure environment variables for the dev server:
|
|
1217
|
+
|
|
1218
|
+
```bash
|
|
1219
|
+
VAULT_URL=https://vault-staging.example.com
|
|
1220
|
+
VAULT_API_KEY=vk_test_...
|
|
1221
|
+
```
|
|
1222
|
+
|
|
1223
|
+
---
|
|
1224
|
+
|
|
1225
|
+
## Content Security Policy
|
|
1226
|
+
|
|
1227
|
+
The SDK loads iframes from the Ozura frame origin. Add the following directives to your CSP:
|
|
1228
|
+
|
|
1229
|
+
```
|
|
1230
|
+
frame-src https://elements.ozura.com;
|
|
1231
|
+
```
|
|
1232
|
+
|
|
1233
|
+
If loading custom fonts via `fonts[].cssSrc`, also allow the font stylesheet origin:
|
|
1234
|
+
|
|
1235
|
+
```
|
|
1236
|
+
style-src https://fonts.googleapis.com;
|
|
1237
|
+
font-src https://fonts.gstatic.com;
|
|
1238
|
+
```
|
|
1239
|
+
|
|
1240
|
+
To verify your CSP after a build:
|
|
1241
|
+
|
|
1242
|
+
```bash
|
|
1243
|
+
npm run check:csp
|
|
1244
|
+
```
|
|
1245
|
+
|
|
1246
|
+
---
|
|
1247
|
+
|
|
1248
|
+
## TypeScript reference
|
|
1249
|
+
|
|
1250
|
+
> π [API reference](https://docs.ozura.com/sdks/elements/api-reference) β every interface, union, and enum fully annotated with JSDoc.
|
|
1251
|
+
|
|
1252
|
+
All public types are exported from `@ozura/elements`:
|
|
1253
|
+
|
|
1254
|
+
```ts
|
|
1255
|
+
import type {
|
|
1256
|
+
// Element types
|
|
1257
|
+
ElementType, // 'cardNumber' | 'cvv' | 'expirationDate'
|
|
1258
|
+
BankElementType, // 'accountNumber' | 'routingNumber'
|
|
1259
|
+
ElementOptions,
|
|
1260
|
+
ElementStyleConfig,
|
|
1261
|
+
ElementStyle,
|
|
1262
|
+
ElementChangeEvent,
|
|
1263
|
+
|
|
1264
|
+
// Vault config
|
|
1265
|
+
VaultOptions,
|
|
1266
|
+
FontSource,
|
|
1267
|
+
CssFontSource,
|
|
1268
|
+
CustomFontSource,
|
|
1269
|
+
Appearance,
|
|
1270
|
+
AppearanceVariables,
|
|
1271
|
+
OzTheme, // 'default' | 'night' | 'flat'
|
|
1272
|
+
|
|
1273
|
+
// Tokenization
|
|
1274
|
+
TokenizeOptions,
|
|
1275
|
+
BankTokenizeOptions,
|
|
1276
|
+
TokenResponse,
|
|
1277
|
+
BankTokenResponse,
|
|
1278
|
+
CardMetadata,
|
|
1279
|
+
BankAccountMetadata,
|
|
1280
|
+
|
|
1281
|
+
// Billing
|
|
1282
|
+
BillingDetails,
|
|
1283
|
+
BillingAddress,
|
|
1284
|
+
|
|
1285
|
+
// Card sale
|
|
1286
|
+
CardSaleRequest,
|
|
1287
|
+
CardSaleResponseData,
|
|
1288
|
+
CardSaleApiResponse,
|
|
1289
|
+
|
|
1290
|
+
// Transactions
|
|
1291
|
+
TransactionQueryParams,
|
|
1292
|
+
TransactionQueryPagination,
|
|
1293
|
+
TransactionQueryResponse,
|
|
1294
|
+
TransactionType,
|
|
1295
|
+
TransactionData,
|
|
1296
|
+
CardTransactionData,
|
|
1297
|
+
AchTransactionData,
|
|
1298
|
+
CryptoTransactionData,
|
|
1299
|
+
|
|
1300
|
+
// Errors
|
|
1301
|
+
OzErrorCode,
|
|
1302
|
+
} from '@ozura/elements';
|
|
1303
|
+
```
|
|
1304
|
+
|
|
1305
|
+
Server-specific types are exported from `@ozura/elements/server`:
|
|
1306
|
+
|
|
1307
|
+
```ts
|
|
1308
|
+
import type {
|
|
1309
|
+
OzuraConfig,
|
|
1310
|
+
CardSaleInput,
|
|
1311
|
+
CreateSessionOptions,
|
|
1312
|
+
CreateSessionResult,
|
|
1313
|
+
ListTransactionsInput,
|
|
1314
|
+
} from '@ozura/elements/server';
|
|
1315
|
+
```
|
|
1316
|
+
|
|
1317
|
+
React-specific types are exported from `@ozura/elements/react`:
|
|
1318
|
+
|
|
1319
|
+
```ts
|
|
1320
|
+
import type { OzFieldProps, OzCardProps, OzCardState, OzBankCardProps, OzBankCardState } from '@ozura/elements/react';
|
|
1321
|
+
```
|
|
1322
|
+
|
|
1323
|
+
---
|
|
1324
|
+
|
|
1325
|
+
## Need help?
|
|
1326
|
+
|
|
1327
|
+
The full documentation β including interactive examples, a complete API reference, and integration walkthroughs β lives at:
|
|
1328
|
+
|
|
1329
|
+
**[docs.ozura.com/sdks/elements/overview](https://docs.ozura.com/sdks/elements/overview)**
|
|
1330
|
+
|
|
1331
|
+
| I want to⦠| Go to |
|
|
1332
|
+
|---|---|
|
|
1333
|
+
| Get started from scratch | [Installation](https://docs.ozura.com/sdks/elements/installation) |
|
|
1334
|
+
| Build a card payment form | [Card elements](https://docs.ozura.com/sdks/elements/card-elements) |
|
|
1335
|
+
| Build an ACH / bank form | [Bank elements](https://docs.ozura.com/sdks/elements/bank-elements) |
|
|
1336
|
+
| Use the React components | [React guide](https://docs.ozura.com/sdks/elements/react) |
|
|
1337
|
+
| Style the input fields | [Styling](https://docs.ozura.com/sdks/elements/styling) |
|
|
1338
|
+
| Handle errors correctly | [Error handling](https://docs.ozura.com/sdks/elements/error-handling) |
|
|
1339
|
+
| Set up the server side | [Server SDK](https://docs.ozura.com/sdks/elements/server) |
|
|
1340
|
+
| Look up a type or method | [API reference](https://docs.ozura.com/sdks/elements/api-reference) |
|