@amos.com/react-amos-js 0.3.17 → 0.3.18
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 +28 -14
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -40,13 +40,13 @@ The following flow is for credit card and bank account payment method types only
|
|
|
40
40
|
2. **Render your checkout UI** with one of the payment method components (e.g. `AmosCreditCardPaymentMethodForm`) along with the required props (`onConfirmationFailed`) and optional callbacks (`onPaymentIntentConfirmationSucceeded`, `onSetupIntentConfirmationSucceeded`). The iframe height is auto-managed by the SDK.
|
|
41
41
|
3. **User clicks "Pay now" button**: call `validateForm({ iframeRef })`, which returns `Promise<true>` if the embedded form is valid and `Promise<false>` otherwise.
|
|
42
42
|
4. **Create payment intent on your server**: use your server-side Amos client to call `POST /payment_intents`. You may also associate this payment intent with a new or existing customer via `POST /customers`. This must be server-side because it uses your private API key.
|
|
43
|
-
5. **Return the payment intent token to the browser**: your backend responds with the `EmbedToken` needed for confirmation.
|
|
44
|
-
6. **Confirm the payment intent from the client
|
|
43
|
+
5. **Return the payment intent token to the browser**: your backend responds with the embed token (`components["schemas"]["EmbedToken"]`) needed for confirmation.
|
|
44
|
+
6. **Confirm the payment intent from the client**: call `confirmPaymentIntent({ iframeRef, token })` to continue the payment flow.
|
|
45
45
|
7. **Handle UX**: show the user a "processing" state when the "Pay now" button is clicked, and show a success or error message via `onPaymentIntentConfirmationSucceeded` and `onConfirmationFailed`.
|
|
46
46
|
|
|
47
47
|
### Google Pay
|
|
48
48
|
|
|
49
|
-
Google Pay (and soon, Apple Pay) is a form of express checkout. The Google Pay button is an alternative to the "Pay now" button in your payment forms. Users
|
|
49
|
+
Google Pay (and soon, Apple Pay) is a form of express checkout. The Google Pay button is an alternative to the "Pay now" button in your payment forms. Users can make a payment with either flow.
|
|
50
50
|
|
|
51
51
|
The key differences between the express and non-express payment flows are:
|
|
52
52
|
|
|
@@ -62,7 +62,7 @@ Setup intents are used to save payment methods for future use (e.g. recurring pa
|
|
|
62
62
|
- On the client, call `confirmSetupIntent({ iframeRef, token })` instead of `confirmPaymentIntent({ iframeRef, token })`.
|
|
63
63
|
- Use `onSetupIntentConfirmationSucceeded` instead of `onPaymentIntentConfirmationSucceeded`.
|
|
64
64
|
|
|
65
|
-
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents.
|
|
65
|
+
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call.
|
|
66
66
|
|
|
67
67
|
## Understanding PCI DSS compliance requirements
|
|
68
68
|
|
|
@@ -80,12 +80,13 @@ In short, your app orchestrates the payment flow, while sensitive payment data s
|
|
|
80
80
|
|
|
81
81
|
## Appearance
|
|
82
82
|
|
|
83
|
-
Every component accepts an optional `appearance` prop that controls the look of the iframe UI. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting
|
|
83
|
+
Every component accepts an optional `appearance` prop that controls the look of the iframe UI. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting for field label placement. You can update this prop after page load to update the iframe appearance.
|
|
84
84
|
|
|
85
85
|
```tsx
|
|
86
86
|
<AmosCreditCardPaymentMethodForm
|
|
87
87
|
renderToken="..."
|
|
88
88
|
appearance={{
|
|
89
|
+
labels: "floating",
|
|
89
90
|
themeVariables: {
|
|
90
91
|
"--primary": "oklch(0.5 0.2 240)",
|
|
91
92
|
"--radius": "0.25rem",
|
|
@@ -97,6 +98,18 @@ Every component accepts an optional `appearance` prop that controls the look of
|
|
|
97
98
|
|
|
98
99
|
`themeVariables` uses a **replace** model: each update that includes `themeVariables` sets the full override set. Only the variables you list are overridden; unlisted variables revert to iframe defaults. Omit `themeVariables` to leave existing overrides unchanged.
|
|
99
100
|
|
|
101
|
+
### Label placement
|
|
102
|
+
|
|
103
|
+
Set `labels` to control how field labels are rendered in card and bank account forms:
|
|
104
|
+
|
|
105
|
+
| Value | Behavior |
|
|
106
|
+
| ----- | -------- |
|
|
107
|
+
| `above` (default) | Label text above each input |
|
|
108
|
+
| `floating` | Label inside the control; moves up when focused or filled |
|
|
109
|
+
| `placeholder` | No visible label; placeholder and `aria-label` only |
|
|
110
|
+
|
|
111
|
+
Radio groups (e.g. account type) always use an above-style group label regardless of this setting.
|
|
112
|
+
|
|
100
113
|
### Available theme variables
|
|
101
114
|
|
|
102
115
|
| Variable | Purpose | Default |
|
|
@@ -115,6 +128,7 @@ Every component accepts an optional `appearance` prop that controls the look of
|
|
|
115
128
|
| `--input` | Input field border color | `oklch(0.922 0 0)` |
|
|
116
129
|
| `--input-background` | Input field background fill | `var(--background)` |
|
|
117
130
|
| `--input-height` | Height of text inputs and form controls | `2.25rem` |
|
|
131
|
+
| `--input-font-size` | Font size of text inputs and dropdown fields | `0.875rem` |
|
|
118
132
|
| `--ring` | Focus ring and outline color | `oklch(0.708 0 0)` |
|
|
119
133
|
| `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
|
|
120
134
|
|
|
@@ -339,7 +353,7 @@ Confirms a payment intent in the embedded iframe flow.
|
|
|
339
353
|
**Parameters:**
|
|
340
354
|
|
|
341
355
|
- `iframeRef` (`React.RefObject<HTMLIFrameElement | null> | undefined`, required)
|
|
342
|
-
- `token` (typed as `Pick<EmbedToken, "token">` — the embed JWT string returned by your server)
|
|
356
|
+
- `token` (typed as `Pick<components["schemas"]["EmbedToken"], "token">` — the embed JWT string returned by your server)
|
|
343
357
|
|
|
344
358
|
**Returns:** `void`
|
|
345
359
|
|
|
@@ -350,7 +364,7 @@ Confirms a setup intent in the embedded iframe flow. Use this when saving a paym
|
|
|
350
364
|
**Parameters:**
|
|
351
365
|
|
|
352
366
|
- `iframeRef` (`React.RefObject<HTMLIFrameElement | null> | undefined`, required)
|
|
353
|
-
- `token` (same `Pick<EmbedToken, "token">` embed JWT string as for payment confirmation)
|
|
367
|
+
- `token` (same `Pick<components["schemas"]["EmbedToken"], "token">` embed JWT string as for payment confirmation)
|
|
354
368
|
|
|
355
369
|
**Returns:** `void`
|
|
356
370
|
|
|
@@ -365,9 +379,9 @@ Renders the secure credit card iframe form.
|
|
|
365
379
|
|
|
366
380
|
**Optional props:**
|
|
367
381
|
|
|
368
|
-
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string
|
|
369
|
-
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: PaymentIntent) => void`)
|
|
370
|
-
- `onSetupIntentConfirmationSucceeded` (`(setupIntent: SetupIntent) => void`)
|
|
382
|
+
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`) — appearance overrides for the iframe UI (see [Appearance](#appearance))
|
|
383
|
+
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: components["schemas"]["PaymentIntent"]) => void`)
|
|
384
|
+
- `onSetupIntentConfirmationSucceeded` (`(setupIntent: components["schemas"]["SetupIntent"]) => void`)
|
|
371
385
|
- `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
|
|
372
386
|
|
|
373
387
|
**Also accepts:** standard iframe props (`React.ComponentProps<"iframe">`), minus `src`, `title`, `name`, and `role` (which are controlled by the SDK).
|
|
@@ -391,13 +405,13 @@ Renders the secure Google Pay iframe button (express checkout flow).
|
|
|
391
405
|
- `renderToken` (`string`)
|
|
392
406
|
- `amount` (`string`)
|
|
393
407
|
- `merchantName` (`string`)
|
|
394
|
-
- `onInitiatePaymentIntentRequest` (callback receiving `{ paymentIntentCreateAttributes: CreatePaymentIntentInput; customerCreateAttributes: CreateCustomerInput }`, returns `Promise<EmbedToken["token"]>` — the embed JWT string for confirmation)
|
|
395
|
-
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: PaymentIntent) => void`)
|
|
408
|
+
- `onInitiatePaymentIntentRequest` (callback receiving `{ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"]; customerCreateAttributes: components["schemas"]["CreateCustomerInput"] }`, returns `Promise<components["schemas"]["EmbedToken"]["token"]>` — the embed JWT string for confirmation)
|
|
409
|
+
- `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: components["schemas"]["PaymentIntent"]) => void`)
|
|
396
410
|
- `onConfirmationFailed` (`(errorMessage: string) => void`)
|
|
397
411
|
|
|
398
412
|
**Optional props:**
|
|
399
413
|
|
|
400
|
-
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string
|
|
414
|
+
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`)
|
|
401
415
|
|
|
402
416
|
**Also accepts:** standard iframe props, minus the ones controlled by the SDK (`src`, `title`, `name`, `role`, `allow`).
|
|
403
417
|
|
|
@@ -423,7 +437,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
423
437
|
|
|
424
438
|
- **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, or `confirmSetupIntent`. The component forwards the ref to the inner iframe.
|
|
425
439
|
- **Same components for payment vs setup intents**: `AmosCreditCardPaymentMethodForm` and `AmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use (`confirmPaymentIntent` vs `confirmSetupIntent`). You may optionally provide `onPaymentIntentConfirmationSucceeded` and/or `onSetupIntentConfirmationSucceeded`; the appropriate one is invoked based on the flow.
|
|
426
|
-
- **Amount format**: for `AmosGooglePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `CreatePaymentIntentInput` on the server, `amount` is a number in cents (e.g. `5000`).
|
|
440
|
+
- **Amount format**: for `AmosGooglePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server, `amount` is a number in cents (e.g. `5000`).
|
|
427
441
|
- **Going framework-free**: if you need to use Amos outside of React (vanilla JS, another framework, etc.), use [`@amos.com/amos-js`](../amos-js) directly.
|
|
428
442
|
|
|
429
443
|
---
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.18",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"vite-plugin-dts": "5.0.2"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@amos.com/amos-js": "0.3.
|
|
47
|
+
"@amos.com/amos-js": "0.3.20",
|
|
48
48
|
"@amos.com/node": "0.1.23",
|
|
49
49
|
"@types/googlepay": "0.7.11"
|
|
50
50
|
},
|