@amos.com/react-amos-js 0.11.13 → 0.11.15
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 +81 -14
- package/dist/index.d.ts +14 -0
- package/package.json +2 -2
- package/src/index.tsx +14 -0
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install @amos.com/react-amos-js @amos.com/node
|
|
|
16
16
|
|
|
17
17
|
- React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`, `AmosApplePayButton`.
|
|
18
18
|
- React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPayment({ iframeRef, token })`, `confirmSetup({ iframeRef, token })`, `resetForm({ iframeRef })`, `focusField({ iframeRef, field })`.
|
|
19
|
-
- Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `resetForm`, `focusField`, `ConfirmPaymentResult`, `ConfirmSetupResult`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, etc.
|
|
19
|
+
- Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `resetForm`, `focusField`, `ConfirmPaymentResult`, `ConfirmSetupResult`, `FormattedGooglePayPaymentData`, `Appearance`, `FontSource`, `AppearanceRuleSelector`, `Message`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, etc.
|
|
20
20
|
|
|
21
21
|
> **Note:** `@amos.com/react-amos-js` is the client-side half of the Amos integration. For end-to-end payment processing you also need `@amos.com/node` on your server (creating payment intents, handling webhooks, etc.). The same `@amos.com/node` package is listed as a peer dependency so you can import its OpenAPI types in client-side TypeScript code.
|
|
22
22
|
|
|
@@ -43,8 +43,8 @@ The following flow is for credit card and bank account payment method types only
|
|
|
43
43
|
3. **User clicks "Pay now" or presses Enter in the iframe**: call `validateForm({ iframeRef })`, which returns `Promise<true>` if the embedded form is valid and `Promise<false>` otherwise.
|
|
44
44
|
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.
|
|
45
45
|
5. **Return the payment intent token to the browser**: your backend responds with the embed token (`components["schemas"]["EmbedToken"]`) needed for confirmation.
|
|
46
|
-
6. **Confirm the payment intent from the client**: `await confirmPayment({ iframeRef, token })`. It resolves `{ status: "succeeded", paymentIntent }` or `{ status: "failed",
|
|
47
|
-
7. **Handle UX**: show the user a "processing" state while awaiting `confirmPayment`. Do not treat `{ status: "succeeded" }` as settlement proof — verify payment success on your backend via webhooks. Recoverable field errors stay in the iframe;
|
|
46
|
+
6. **Confirm the payment intent from the client**: `await confirmPayment({ iframeRef, token })`. It resolves `{ status: "succeeded", paymentIntent }`, `{ status: "failed", paymentIntent? }` on decline, or `{ status: "failed", error: "timeout" }` if the iframe does not respond within 15 seconds (`isConfirmTimeout(result)`).
|
|
47
|
+
7. **Handle UX**: show the user a "processing" state while awaiting `confirmPayment`. Do not treat `{ status: "succeeded" }` as settlement proof — verify payment success on your backend via webhooks. Recoverable field errors stay in the iframe; a processor decline still resolves `{ status: "failed" }` (with `paymentIntent` when the confirm API returned a body, including `last_payment_error`). A timeout is **not** a decline — the charge may still settle; do not retry as a new payment.
|
|
48
48
|
|
|
49
49
|
### Google Pay & Apple Pay
|
|
50
50
|
|
|
@@ -82,16 +82,20 @@ In short, your app orchestrates the payment flow, while sensitive payment data s
|
|
|
82
82
|
|
|
83
83
|
## Appearance
|
|
84
84
|
|
|
85
|
-
Card and bank components accept 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,
|
|
85
|
+
Card and bank components accept 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, an optional `labels` setting for field label placement, and optional `fonts` to load webfonts inside the iframe. You can update this prop after page load to update the iframe appearance. Wallet buttons do not take `appearance`.
|
|
86
86
|
|
|
87
87
|
```tsx
|
|
88
88
|
<AmosCreditCardPaymentMethodForm
|
|
89
89
|
renderToken="..."
|
|
90
90
|
appearance={{
|
|
91
91
|
labels: "floating",
|
|
92
|
+
fonts: [
|
|
93
|
+
{ cssSrc: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" },
|
|
94
|
+
],
|
|
92
95
|
themeVariables: {
|
|
93
96
|
"--primary": "oklch(0.5 0.2 240)",
|
|
94
97
|
"--radius": "0.25rem",
|
|
98
|
+
"--font-family": "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
95
99
|
},
|
|
96
100
|
}}
|
|
97
101
|
/>
|
|
@@ -99,6 +103,64 @@ Card and bank components accept an optional `appearance` prop that controls the
|
|
|
99
103
|
|
|
100
104
|
`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.
|
|
101
105
|
|
|
106
|
+
`fonts` uses the same replace model: omit `fonts` to keep the previous set; pass a new array to replace it (`[]` clears the webfont). The iframe does not wait for webfonts before revealing — custom faces use `font-display: swap`.
|
|
107
|
+
|
|
108
|
+
### Fonts
|
|
109
|
+
|
|
110
|
+
When you omit `fonts` and `--font-family`, the SDK sends Google Fonts Inter on the first `UPDATE_APPEARANCE` (same stylesheet the embed used to load globally) and sets `--font-family` to `Inter, ui-sans-serif, system-ui, sans-serif`. That is what lets js.amos.com drop its own Inter `<link>` once every client is on this SDK.
|
|
111
|
+
|
|
112
|
+
Pass Stripe-style font sources on `appearance.fonts` to replace that default. Pair them with `--font-family` so the iframe uses the loaded face (see the example above). A custom `@font-face` source looks like `{ family: "MyFont", src: 'url(https://cdn.example.com/my.woff2)', display: "swap" }`.
|
|
113
|
+
|
|
114
|
+
Pass `fonts: []` to skip the webfont. If you also omit `--font-family` on that payload, the SDK uses `ui-sans-serif, system-ui, sans-serif` instead of Inter.
|
|
115
|
+
|
|
116
|
+
- **`cssSrc`** — an `https:` stylesheet URL that declares `@font-face` (Google Fonts CSS, a self-hosted CSS file). The iframe injects `<link rel="stylesheet">`; it does not fetch and inline the CSS.
|
|
117
|
+
- **Custom source** — `family` plus a CSS `src` list of `url("https://…")` / `url(https://…)` and optional `format(…)`. Optional `display` (default `"swap"`), `style`, `weight`, and `unicodeRange`.
|
|
118
|
+
|
|
119
|
+
### Rules
|
|
120
|
+
|
|
121
|
+
Per-part CSS, keyed by Stripe-style class names. The iframe maps these onto its own slots; you cannot target the iframe DOM from the host page. Pair `fontFamily` with `appearance.fonts` so the face is loaded.
|
|
122
|
+
|
|
123
|
+
```tsx
|
|
124
|
+
appearance={{
|
|
125
|
+
fonts: [
|
|
126
|
+
{ cssSrc: "https://fonts.googleapis.com/css2?family=Inter:wght@400;500&display=swap" },
|
|
127
|
+
{ cssSrc: "https://fonts.googleapis.com/css2?family=Source+Serif+4&display=swap" },
|
|
128
|
+
],
|
|
129
|
+
themeVariables: {
|
|
130
|
+
"--font-family": "Inter, ui-sans-serif, system-ui, sans-serif",
|
|
131
|
+
},
|
|
132
|
+
rules: {
|
|
133
|
+
".Label": { fontFamily: "Source Serif 4, ui-serif, serif" },
|
|
134
|
+
".Input": { fontFamily: "Inter, ui-sans-serif, system-ui, sans-serif" },
|
|
135
|
+
".Input--invalid": { boxShadow: "0 0 0 2px oklch(0.55 0.245 27.325)" },
|
|
136
|
+
},
|
|
137
|
+
}}
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
`rules` uses the same **replace** model as `themeVariables` and `fonts`: omit `rules` to keep the previous set; pass a new object to replace it (`{}` clears). Unknown class names and properties are ignored.
|
|
141
|
+
|
|
142
|
+
Rules override `themeVariables` for the properties they set (Stripe). `--input-height` / `--floating-input-height` are a **minimum**; `.Input` `padding`, `fontSize`, and `lineHeight` can grow the field. Rule values may reference allowlisted tokens as `var(--primary)` (no fallback argument).
|
|
143
|
+
|
|
144
|
+
The host skeleton (shown until `UPDATED_APPEARANCE`, or 1.5s after `IFRAME_READY` if appearance never acks) copies `themeVariables` and resting **`.Input` / `.Label`** declarations (the same allowlisted properties as iframe rules). It does not inject webfonts: it uses `--font-family` / `fontFamily` when that face is already on the host page, and falls back to `ui-sans-serif, system-ui, sans-serif`. Hover, invalid, placeholder, dropdown, and radio rules have no skeleton equivalent. Floating labels sit inside the control, so `.Label` / `.Label--floating` do not change skeleton height.
|
|
145
|
+
|
|
146
|
+
| Selector | Targets |
|
|
147
|
+
| --- | --- |
|
|
148
|
+
| `.Input` | Text fields, country select, state trigger |
|
|
149
|
+
| `.Input:hover`, `.Input:focus`, `.Input:disabled` | Those controls in the given state |
|
|
150
|
+
| `.Input--invalid` | Invalid text fields / selects |
|
|
151
|
+
| `.Input::placeholder` | Input placeholders |
|
|
152
|
+
| `.Label` | All labels (above, floating, radio option text, group titles) |
|
|
153
|
+
| `.Label--floating` | Extra styles on floating labels (overrides `.Label`) |
|
|
154
|
+
| `.Error` | Field-level error text |
|
|
155
|
+
| `.Dropdown` | State list panel |
|
|
156
|
+
| `.DropdownItem` | State list rows |
|
|
157
|
+
| `.DropdownItem--highlight` | Highlighted state row |
|
|
158
|
+
| `.RadioIcon` | Bank radio circle |
|
|
159
|
+
| `.RadioIcon--checked` | Checked radio circle |
|
|
160
|
+
| `.RadioIconInner` | Radio filled dot |
|
|
161
|
+
|
|
162
|
+
Allowed declaration keys (camelCase): `fontFamily`, `fontSize`, `fontWeight`, `fontStyle`, `lineHeight`, `letterSpacing`, `textTransform`, `color`, `backgroundColor`, `border`, `borderColor`, `borderWidth`, `borderStyle`, `borderRadius`, `boxShadow`, `outline`, `padding`, `margin`, `opacity`. Values cannot include `url()`, `@font-face`, `<`, `>`, `\`, or `var()` except `var(--token)` for an allowlisted theme variable (`--primary`, `--input-height`, …).
|
|
163
|
+
|
|
102
164
|
### Label placement
|
|
103
165
|
|
|
104
166
|
Set `labels` to control how field labels are rendered in card and bank account forms:
|
|
@@ -154,6 +216,7 @@ Radio groups (e.g. account type) always use an above-style group label regardles
|
|
|
154
216
|
| `--ring` | Focus ring and outline color (inputs) | `oklch(0.708 0 0)` |
|
|
155
217
|
| `--ring-width` | Focus ring width | `3px` |
|
|
156
218
|
| `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
|
|
219
|
+
| `--font-family` | Font stack for the iframe UI | `Inter, ui-sans-serif, system-ui, sans-serif` |
|
|
157
220
|
|
|
158
221
|
## Examples
|
|
159
222
|
|
|
@@ -445,7 +508,7 @@ Validates the embedded card/bank iframe form before payment confirmation.
|
|
|
445
508
|
|
|
446
509
|
### `confirmPayment({ iframeRef, token, defaultValues? })`
|
|
447
510
|
|
|
448
|
-
Confirms a payment intent in the embedded iframe flow. Resolves `{ status: "succeeded", paymentIntent }` or `{ status: "failed",
|
|
511
|
+
Confirms a payment intent in the embedded iframe flow. Resolves `{ status: "succeeded", paymentIntent }`, `{ status: "failed", paymentIntent? }` on decline, or `{ status: "failed", error: "timeout" }` if the iframe does not respond within 15 seconds (`CONFIRM_TIMEOUT_MS`). Optional `defaultValues` are applied immediately before building the payment method (including hidden name and extra billing fields) and do not replace the last `defaultValues` prop used by `resetForm`.
|
|
449
512
|
|
|
450
513
|
**Parameters:**
|
|
451
514
|
|
|
@@ -453,11 +516,11 @@ Confirms a payment intent in the embedded iframe flow. Resolves `{ status: "succ
|
|
|
453
516
|
- `token` (typed as `Pick<components["schemas"]["EmbedToken"], "token">` — the embed JWT string returned by your server)
|
|
454
517
|
- `defaultValues` (`PaymentMethodFormDefaultValues`, optional)
|
|
455
518
|
|
|
456
|
-
**Returns:** `Promise<ConfirmPaymentResult>`
|
|
519
|
+
**Returns:** `Promise<ConfirmPaymentResult>` — use `isConfirmTimeout(result)` to treat a timeout as uncertain (do not retry). Embed aborts hung `/confirm` at 10s and posts the same timeout result; the SDK wait is strictly above that.
|
|
457
520
|
|
|
458
521
|
### `confirmSetup({ iframeRef, token, defaultValues? })`
|
|
459
522
|
|
|
460
|
-
Confirms a setup intent in the embedded iframe flow. Use this when saving a payment method for future use. Optional `defaultValues` behave the same as on `confirmPayment`.
|
|
523
|
+
Confirms a setup intent in the embedded iframe flow. Use this when saving a payment method for future use. Optional `defaultValues` behave the same as on `confirmPayment`. Same 15-second timeout window and `isConfirmTimeout` rule as `confirmPayment`.
|
|
461
524
|
|
|
462
525
|
**Parameters:**
|
|
463
526
|
|
|
@@ -492,7 +555,7 @@ Focus a named control inside the card or bank iframe. No-op if the field is not
|
|
|
492
555
|
|
|
493
556
|
### `AmosCreditCardPaymentMethodForm`
|
|
494
557
|
|
|
495
|
-
Renders the secure credit card iframe form. A field-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
|
|
558
|
+
Renders the secure credit card iframe form. A field-shaped skeleton is shown immediately (sized from `appearance`, including resting `.Input` / `.Label` rules) and replaced by the iframe once appearance is applied.
|
|
496
559
|
|
|
497
560
|
**Required props:**
|
|
498
561
|
|
|
@@ -500,7 +563,7 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
|
|
|
500
563
|
|
|
501
564
|
**Optional props:**
|
|
502
565
|
|
|
503
|
-
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`) — appearance overrides for the iframe UI (see [Appearance](#appearance))
|
|
566
|
+
- `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder"; fonts?: FontSource[]; rules?: Partial<Record<AppearanceRuleSelector, AppearanceRuleDeclarations>> }`) — appearance overrides for the iframe UI (see [Appearance](#appearance))
|
|
504
567
|
|
|
505
568
|
- `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
|
|
506
569
|
- `billingAddressRequirement` (`"country" | "full"`, defaults to `"country"`) — how much billing address the iframe collects. `country` collects country / region and, for CA / PR / GB / US, a postal code (labeled ZIP for the United States). `full` shows a full street address form with Smarty autocomplete.
|
|
@@ -515,7 +578,7 @@ Enter in a card or bank iframe field submits the enclosing host `<form>` via `re
|
|
|
515
578
|
|
|
516
579
|
### `AmosBankAccountPaymentMethodForm`
|
|
517
580
|
|
|
518
|
-
Renders the secure bank account iframe form. A field-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
|
|
581
|
+
Renders the secure bank account iframe form. A field-shaped skeleton is shown immediately (sized from `appearance`, including resting `.Input` / `.Label` rules) and replaced by the iframe once appearance is applied.
|
|
519
582
|
|
|
520
583
|
When `requireAchVerification` is true (or `intent` is `"setup"`), and the render token allows verification, the SDK hides the routing/account iframe and mounts [Plaid Embedded Institution Search](https://plaid.com/docs/link/embedded-institution-search/) in the parent. Hosts do not proxy Pay API (`GET /merchants`, `POST /plaid_link_tokens`); embed does that with `PAY_API_KEY`. Do not put Plaid secrets in the browser.
|
|
521
584
|
|
|
@@ -615,24 +678,28 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
615
678
|
|
|
616
679
|
Re-exports from `@amos.com/amos-js`. Build the iframe `src` URL for each form type. The React components call these for you.
|
|
617
680
|
|
|
618
|
-
Each URL includes the embed's canonical search params (`token`, `additionalFields`, `billingAddressRequirement`, `intent`) so the embed router does not 307 to fill in defaults. After the iframe `load` event, if `IFRAME_READY` never arrives (stale HTML, missing JS chunk), the SDK rewrites `src` once with `amosReload` so the next document is a real navigation.
|
|
681
|
+
Each URL includes the embed's canonical search params (`token`, `additionalFields`, `billingAddressRequirement`, `intent`) so the embed router does not 307 to fill in defaults. After the iframe `load` event, if `IFRAME_READY` never arrives (stale HTML, missing JS chunk), the SDK rewrites `src` once with `amosReload` so the next document is a real navigation. Appearance is applied after handshake via `UPDATE_APPEARANCE` (the iframe stays hidden until then, or for 1.5s after `IFRAME_READY` if appearance never acks).
|
|
619
682
|
|
|
620
683
|
### `updateDefaultValues({ iframe, defaultValues })`
|
|
621
684
|
|
|
622
685
|
Re-export from `@amos.com/amos-js`. Push name and billing-address defaults into a mounted form. Passing a new `defaultValues` prop on the React component does the same.
|
|
623
686
|
|
|
687
|
+
### `appearanceWithDefaults(appearance, { initial })`
|
|
688
|
+
|
|
689
|
+
Re-export from `@amos.com/amos-js`. Fills omitted Inter `fonts` / `--font-family` (or a system stack when `fonts` is `[]`). The React components call this for you via the mount helpers. Only call it yourself if you are wiring `UPDATE_APPEARANCE` by hand: pass `initial: true` only for the first update after `IFRAME_READY`, and pass the merchant's last `appearance` (so a previous `fonts: []` is not overwritten).
|
|
690
|
+
|
|
624
691
|
### Exported types
|
|
625
692
|
|
|
626
|
-
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmPaymentResult`, `ConfirmSetupResult`, `PaymentMethodFormValidityChangeEvent`, `CardBrand`, `PaymentMethodFormCardBrandChangeEvent`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
693
|
+
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmPaymentResult`, `ConfirmSetupResult`, `PaymentMethodFormValidityChangeEvent`, `CardBrand`, `PaymentMethodFormCardBrandChangeEvent`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, `FontSource`, `CssFontSource`, `CustomFontSource`, `AppearanceRuleSelector`, `AppearanceRuleDeclarations`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
627
694
|
|
|
628
695
|
## Notes and potential gotchas
|
|
629
696
|
|
|
630
697
|
- **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPayment`, `confirmSetup`, `resetForm`, or `focusField`. The component forwards the ref to the inner iframe.
|
|
631
|
-
- **`confirmPayment` / `confirmSetup` are not settlement proof**: `{ status: "succeeded" }` means authorization succeeded (capture may still finish asynchronously). Verify payment or setup success on your backend via webhooks. Recoverable field errors stay in the iframe;
|
|
698
|
+
- **`confirmPayment` / `confirmSetup` are not settlement proof**: `{ status: "succeeded" }` means authorization succeeded (capture may still finish asynchronously). Verify payment or setup success on your backend via webhooks. Recoverable field errors stay in the iframe; a processor decline still resolves `{ status: "failed" }`. Declined confirms include the intent so you can read `last_payment_error` without a follow-up GET. If the iframe never answers, the Promise resolves `{ status: "failed", error: "timeout" }` after 15 seconds (`CONFIRM_TIMEOUT_MS`, `isConfirmTimeout`) — that is uncertain, not a decline; do not retry as a new payment.
|
|
632
699
|
- **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 (`confirmPayment` vs `confirmSetup`).
|
|
633
700
|
- **Amount format**: for `AmosGooglePayButton` and `AmosApplePayButton`, `amount` is a major-currency decimal string (e.g. `"50.00"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server (card/bank create, and the object the wallet iframe sends to `onConfirm`), `amount` is a number in cents (e.g. `5000`).
|
|
634
701
|
- **Embed host / CSP**: iframes load from `https://js.amos.com` (production) and `https://js-sandbox.amos.com` (sandbox) via `getEmbedOrigin`. Parent pages that pin CSP must allow `frame-src https://js.amos.com https://js-sandbox.amos.com` (and `Permissions-Policy payment=` for those origins) **before** upgrading this package. Older SDK versions still load `embed.amos.com` / `embed-sandbox.amos.com`.
|
|
635
|
-
- **Iframe handshake**: iframe URLs include canonical search params so the embed does not 307. If the document loads but never posts `IFRAME_READY`, the SDK rewrites `src` once with `amosReload`.
|
|
702
|
+
- **Iframe handshake**: iframe URLs include canonical search params so the embed does not 307. If the document loads but never posts `IFRAME_READY`, the SDK rewrites `src` once with `amosReload`. Appearance is applied after handshake; the iframe stays hidden until `UPDATED_APPEARANCE`, or for 1.5s after `IFRAME_READY` if appearance never acks.
|
|
636
703
|
- **Plaid Embedded Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe mints link tokens. Pass `requireAchVerification` when the host wants Plaid, or `intent="setup"` to always show it, unless the render token disables verification. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method.
|
|
637
704
|
- **Apple Pay waiting overlay**: on browsers where Apple's QR handoff opens in a popup (non-Safari), `AmosApplePayButton` shows a fixed full-viewport overlay on the host page. **Cancel payment** is available until the buyer authorizes; after that the overlay shows **Completing your payment…** with no Cancel, then hides when `onConfirm` settles. Avoid stacking other fixed UI above it.
|
|
638
705
|
- **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.
|
package/dist/index.d.ts
CHANGED
|
@@ -19,6 +19,14 @@ export declare function validateForm({ iframeRef, }: {
|
|
|
19
19
|
*
|
|
20
20
|
* Pass the embed JWT (`token`) returned by your server's
|
|
21
21
|
* `POST /payment_intents` call.
|
|
22
|
+
*
|
|
23
|
+
* Resolves `{ status: "succeeded", paymentIntent }` after authorization,
|
|
24
|
+
* `{ status: "failed", paymentIntent? }` on decline, or
|
|
25
|
+
* `{ status: "failed", error: "timeout" }` if the iframe does not post
|
|
26
|
+
* `CONFIRMATION_RESULT` within 15 seconds (`CONFIRM_TIMEOUT_MS`). Use
|
|
27
|
+
* `isConfirmTimeout(result)` — a timeout is not a decline; the charge
|
|
28
|
+
* may still settle. Embed `/confirm` aborts at 10s and posts the same
|
|
29
|
+
* timeout result.
|
|
22
30
|
*/
|
|
23
31
|
export declare function confirmPayment({ iframeRef, token, defaultValues, }: {
|
|
24
32
|
iframeRef: IframeRef;
|
|
@@ -30,6 +38,12 @@ export declare function confirmPayment({ iframeRef, token, defaultValues, }: {
|
|
|
30
38
|
*
|
|
31
39
|
* Pass the embed JWT (`token`) returned by your server's
|
|
32
40
|
* `POST /setup_intents` call.
|
|
41
|
+
*
|
|
42
|
+
* Resolves `{ status: "succeeded", setupIntent }` after verification,
|
|
43
|
+
* `{ status: "failed", setupIntent? }` on decline, or
|
|
44
|
+
* `{ status: "failed", error: "timeout" }` if the iframe does not
|
|
45
|
+
* respond within 15 seconds. Same `isConfirmTimeout` rule as
|
|
46
|
+
* {@link confirmPayment}.
|
|
33
47
|
*/
|
|
34
48
|
export declare function confirmSetup({ iframeRef, token, defaultValues, }: {
|
|
35
49
|
iframeRef: IframeRef;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"vite-plugin-dts": "5.0.3"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@amos.com/amos-js": "0.11.
|
|
60
|
+
"@amos.com/amos-js": "0.11.16",
|
|
61
61
|
"@types/googlepay": "0.7.12"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -63,6 +63,14 @@ export function validateForm({
|
|
|
63
63
|
*
|
|
64
64
|
* Pass the embed JWT (`token`) returned by your server's
|
|
65
65
|
* `POST /payment_intents` call.
|
|
66
|
+
*
|
|
67
|
+
* Resolves `{ status: "succeeded", paymentIntent }` after authorization,
|
|
68
|
+
* `{ status: "failed", paymentIntent? }` on decline, or
|
|
69
|
+
* `{ status: "failed", error: "timeout" }` if the iframe does not post
|
|
70
|
+
* `CONFIRMATION_RESULT` within 15 seconds (`CONFIRM_TIMEOUT_MS`). Use
|
|
71
|
+
* `isConfirmTimeout(result)` — a timeout is not a decline; the charge
|
|
72
|
+
* may still settle. Embed `/confirm` aborts at 10s and posts the same
|
|
73
|
+
* timeout result.
|
|
66
74
|
*/
|
|
67
75
|
export function confirmPayment({
|
|
68
76
|
iframeRef,
|
|
@@ -88,6 +96,12 @@ export function confirmPayment({
|
|
|
88
96
|
*
|
|
89
97
|
* Pass the embed JWT (`token`) returned by your server's
|
|
90
98
|
* `POST /setup_intents` call.
|
|
99
|
+
*
|
|
100
|
+
* Resolves `{ status: "succeeded", setupIntent }` after verification,
|
|
101
|
+
* `{ status: "failed", setupIntent? }` on decline, or
|
|
102
|
+
* `{ status: "failed", error: "timeout" }` if the iframe does not
|
|
103
|
+
* respond within 15 seconds. Same `isConfirmTimeout` rule as
|
|
104
|
+
* {@link confirmPayment}.
|
|
91
105
|
*/
|
|
92
106
|
export function confirmSetup({
|
|
93
107
|
iframeRef,
|