@amos.com/react-amos-js 0.11.20 → 0.11.22
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 +11 -10
- package/dist/index.d.ts +18 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +21 -11
- package/package.json +4 -4
- package/src/index.tsx +49 -2
package/README.md
CHANGED
|
@@ -60,8 +60,8 @@ The key differences between the express and non-express payment flows are:
|
|
|
60
60
|
|
|
61
61
|
Setup intents are used to save payment methods for future use (e.g. recurring payments, subscriptions) without charging the customer immediately. The flow is identical to a payment intent, except:
|
|
62
62
|
|
|
63
|
-
- On the server, call `POST /setup_intents` instead of `POST /payment_intents`.
|
|
64
|
-
- On the client, `await confirmSetup({ iframeRef, token })` instead of `confirmPayment({ iframeRef, token })`.
|
|
63
|
+
- On the server, call `POST /setup_intents` instead of `POST /payment_intents`. Setup intents are organization-scoped (`X-Account-Id` is ignored if sent). The embed JWT carries `organization_id` + `setup_intent_id` (`account_id` is null). Payment-intent tokens remain account-scoped (`account_id` + `payment_intent_id`).
|
|
64
|
+
- On the client, `await confirmSetup({ iframeRef, token })` instead of `confirmPayment({ iframeRef, token })`. `confirmSetup` reads `setup_intent_id` from the JWT; it does not need `account_id`.
|
|
65
65
|
- Both resolve with a status and the matching intent object when the confirm API returned a body (`ConfirmPaymentResult` / `ConfirmSetupResult`).
|
|
66
66
|
|
|
67
67
|
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call. For bank setup, pass `intent="setup"` so Plaid is always shown (unless the render token disables verification).
|
|
@@ -141,7 +141,7 @@ appearance={{
|
|
|
141
141
|
|
|
142
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
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.
|
|
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 covers a visible iframe (`opacity: 1`) so WebKit still runs iframe JS. 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
145
|
|
|
146
146
|
| Selector | Targets |
|
|
147
147
|
| --- | --- |
|
|
@@ -560,7 +560,7 @@ Focus a named control inside the card or bank iframe. No-op if the field is not
|
|
|
560
560
|
|
|
561
561
|
### `AmosCreditCardPaymentMethodForm`
|
|
562
562
|
|
|
563
|
-
Renders the secure credit card iframe form. A field-shaped skeleton
|
|
563
|
+
Renders the secure credit card iframe form. A field-shaped skeleton covers a visible iframe immediately (sized from `appearance`, including resting `.Input` / `.Label` rules) and is removed once appearance is applied, or 1.5s after `IFRAME_READY` if appearance never acks.
|
|
564
564
|
|
|
565
565
|
**Required props:**
|
|
566
566
|
|
|
@@ -575,6 +575,7 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
|
|
|
575
575
|
- `defaultValues` (`{ name?: string; billingAddress?: { line1?, line2?, city?, state?, postalCode?, country? } }`) — seed cardholder / account-holder name and billing address. Provided keys overwrite matching fields, including ones the customer already edited. Values are also sent on confirm even when those inputs are hidden (cardholder name off, or `country` billing mode). Never send PAN, CVC, account number, or routing number.
|
|
576
576
|
- `onValidityChange` (`(event: { isValid: boolean }) => void`) — called when form validity changes. `isValid` is true when all required fields are present and valid. Does not include PCI data. Use this to enable or disable your checkout button.
|
|
577
577
|
- `onCardBrandChanged` (`(event: { brand: CardBrand | null }) => void`) — called when the detected card brand changes. `brand` is `"visa"`, `"mastercard"`, `"amex"`, `"discover"`, `"diners"`, or `"jcb"`, or `null` when the field is empty or the number does not match a known brand. Does not include PCI data.
|
|
578
|
+
- `onPostalCodeChange` (`(event: { postalCode: string | null; country: string }) => void`) — called when the customer commits a billing postal code, or clears one. `postalCode` is a finished code, or `null` when a finished code is deleted or the country changes. Incomplete keystrokes are not reported. US and PR commit at 5 digits (ZIP+4 is reported as the first 5). Canada commits as `A1A 1A1`. The UK commits at a full postcode. Not called for `defaultValues`, so a host can copy its own postal field into the iframe until the first callback and then stop. Debounce shipping-rate requests in the host. Card and bank forms only.
|
|
578
579
|
- `onEscapeKeyPressed` (`() => void`) — called when the customer presses Escape in the iframe. PCI-safe — no field values. Use this to close a host modal that contains the iframe. Not fired while an iframe dropdown or address suggestion list is open (that Escape dismisses the overlay first), or while Plaid Embedded Institution Search is showing. The parent cannot attach a keydown listener for this itself because the iframe is cross-origin.
|
|
579
580
|
|
|
580
581
|
Enter in a card or bank iframe field submits the enclosing host `<form>` via `requestSubmit()` (same as Stripe Elements). Handle that form's `onSubmit` — the parent page cannot see keys typed in the cross-origin iframe. No-op if the component is not inside a `<form>`, or while Plaid Embedded Institution Search is showing.
|
|
@@ -583,13 +584,13 @@ Enter in a card or bank iframe field submits the enclosing host `<form>` via `re
|
|
|
583
584
|
|
|
584
585
|
### `AmosBankAccountPaymentMethodForm`
|
|
585
586
|
|
|
586
|
-
Renders the secure bank account iframe form. A field-shaped skeleton
|
|
587
|
+
Renders the secure bank account iframe form. A field-shaped skeleton covers a visible iframe immediately (sized from `appearance`, including resting `.Input` / `.Label` rules) and is removed once appearance is applied, or 1.5s after `IFRAME_READY` if appearance never acks.
|
|
587
588
|
|
|
588
589
|
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. A **350px pulse skeleton** covers that slot until Plaid's `onLoad` (1.5s fallback). Do not overlay a host loader. 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.
|
|
589
590
|
|
|
590
591
|
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`.
|
|
591
592
|
|
|
592
|
-
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `defaultValues`, `onValidityChange` (`isValid` is also true after Plaid returns credentials), `onEscapeKeyPressed` — plus:
|
|
593
|
+
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `defaultValues`, `onValidityChange` (`isValid` is also true after Plaid returns credentials), `onPostalCodeChange`, `onEscapeKeyPressed` — plus:
|
|
593
594
|
|
|
594
595
|
- `requireAchVerification` (`boolean`, defaults to `false`) — when true, show Plaid Embedded Link instead of routing/account fields. Ignored for `intent="setup"` (always Plaid) and when the render token has bank `verification: false`. Hosts that still have an ACH threshold should compute this themselves and pass a new value when the charge changes. Changing this prop hides or shows Link; it does not remount the bank form or destroy the Embedded handler.
|
|
595
596
|
- `intent` (`"payment" | "setup"`, defaults to `"payment"`) — `"setup"` always shows Plaid unless the render token disables verification. Use this when saving a bank account for later charges.
|
|
@@ -618,7 +619,7 @@ Setup (always Plaid, unless the render token disables verification):
|
|
|
618
619
|
|
|
619
620
|
### `AmosGooglePayButton`
|
|
620
621
|
|
|
621
|
-
Renders the secure Google Pay iframe button (express checkout flow). A button-shaped skeleton
|
|
622
|
+
Renders the secure Google Pay iframe button (express checkout flow). A button-shaped skeleton covers a visible iframe immediately and is removed once appearance is applied, or 1.5s after `IFRAME_READY` if appearance never acks.
|
|
622
623
|
|
|
623
624
|
**Required props:**
|
|
624
625
|
|
|
@@ -645,7 +646,7 @@ Renders the secure Google Pay iframe button (express checkout flow). A button-sh
|
|
|
645
646
|
|
|
646
647
|
### `AmosApplePayButton`
|
|
647
648
|
|
|
648
|
-
Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`. A button-shaped skeleton
|
|
649
|
+
Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`. A button-shaped skeleton covers a visible iframe immediately and is removed once appearance is applied, or 1.5s after `IFRAME_READY` if appearance never acks.
|
|
649
650
|
|
|
650
651
|
**Optional props:**
|
|
651
652
|
|
|
@@ -687,7 +688,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
687
688
|
|
|
688
689
|
Re-exports from `@amos.com/amos-js`. Build the iframe `src` URL for each form type. The React components call these for you.
|
|
689
690
|
|
|
690
|
-
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
|
|
691
|
+
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`. A host-page skeleton covers the visible iframe until then, or for 1.5s after `IFRAME_READY` if appearance never acks.
|
|
691
692
|
|
|
692
693
|
### `updateDefaultValues({ iframe, defaultValues })`
|
|
693
694
|
|
|
@@ -708,7 +709,7 @@ Re-export from `@amos.com/amos-js`. Fills omitted Inter `fonts` / `--font-family
|
|
|
708
709
|
- **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`).
|
|
709
710
|
- **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`).
|
|
710
711
|
- **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`.
|
|
711
|
-
- **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
|
|
712
|
+
- **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 visible under the skeleton until `UPDATED_APPEARANCE`, or for 1.5s after `IFRAME_READY` if appearance never acks. Embed messages match on origin plus `iframeName` when `contentWindow` identity changes.
|
|
712
713
|
- **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. Toggling that prop hides or shows the existing Embedded handler — it does not reload Institution Search. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method. While Link loads, the SDK shows a 350px pulse skeleton until `onLoad` (1.5s fallback) — do not overlay a host loader.
|
|
713
714
|
- **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.
|
|
714
715
|
- **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
|
@@ -67,6 +67,10 @@ export declare function focusField({ iframeRef, field, }: {
|
|
|
67
67
|
}): void;
|
|
68
68
|
type ForwardedIframeRef = Ref<HTMLIFrameElement> | undefined;
|
|
69
69
|
type IframePassthroughProps = Omit<ComponentProps<"iframe">, "src" | "title" | "name" | "role" | "allow">;
|
|
70
|
+
type PostalCodeChangeHandler = (event: {
|
|
71
|
+
postalCode: string | null;
|
|
72
|
+
country: string;
|
|
73
|
+
}) => void;
|
|
70
74
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
71
75
|
renderToken: string;
|
|
72
76
|
appearance?: Appearance;
|
|
@@ -85,6 +89,12 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
85
89
|
onCardBrandChanged?: (event: {
|
|
86
90
|
brand: "visa" | "mastercard" | "amex" | "discover" | "diners" | "jcb" | null;
|
|
87
91
|
}) => void;
|
|
92
|
+
/**
|
|
93
|
+
* Called when the customer commits a billing postal code, or clears
|
|
94
|
+
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
95
|
+
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
96
|
+
*/
|
|
97
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
88
98
|
/**
|
|
89
99
|
* Called when the customer presses Escape in the iframe. PCI-safe —
|
|
90
100
|
* no field values. Use this to close a host modal that contains the
|
|
@@ -102,7 +112,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
102
112
|
*/
|
|
103
113
|
defaultValues?: PaymentMethodFormDefaultValues;
|
|
104
114
|
};
|
|
105
|
-
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, onEscapeKeyPressed, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
|
|
115
|
+
export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, onPostalCodeChange, onEscapeKeyPressed, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
|
|
106
116
|
type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
107
117
|
renderToken: string;
|
|
108
118
|
appearance?: Appearance;
|
|
@@ -122,6 +132,12 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
122
132
|
* showing.
|
|
123
133
|
*/
|
|
124
134
|
onEscapeKeyPressed?: () => void;
|
|
135
|
+
/**
|
|
136
|
+
* Called when the customer commits a billing postal code, or clears
|
|
137
|
+
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
138
|
+
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
139
|
+
*/
|
|
140
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
125
141
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
126
142
|
/**
|
|
127
143
|
* Seed account holder name and billing address. Provided keys
|
|
@@ -151,7 +167,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
151
167
|
*/
|
|
152
168
|
intent?: "payment" | "setup";
|
|
153
169
|
};
|
|
154
|
-
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onEscapeKeyPressed, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
170
|
+
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onPostalCodeChange, onEscapeKeyPressed, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
155
171
|
type AmosGooglePayButtonProps = {
|
|
156
172
|
ref?: ForwardedIframeRef;
|
|
157
173
|
renderToken: string;
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function r(e){var t;return e?(t=e.current)==null?null:t:null}function i({iframeRef:t}){return(0,e.validateForm)({iframe:r(t)})}function a({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmPayment)({iframe:r(t),token:n,defaultValues:i})}function o({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmSetup)({iframe:r(t),token:n,defaultValues:i})}function s({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c({iframeRef:t,field:n}){(0,e.focusField)({iframe:r(t),field:n})}function l(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function u(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function d({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let c=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return c.current=a,l(n,a.iframe),u(a.iframe,o),()=>{a.destroy(),c.current=null,l(n,null)}},[...a]),(0,t.useEffect)(()=>{var e;(e=c.current)==null||e.update(i)},[...s]),(0,t.useEffect)(()=>{var e;let t=(e=c.current)==null?void 0:e.iframe;t&&u(t,o)})}var f=`oklch(0.97 0 0)`;function p({height:r,borderRadius:i,containerRef:a}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:r,minHeight:r,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:r,borderRadius:i,background:f,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:a,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function m({ref:
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function r(e){var t;return e?(t=e.current)==null?null:t:null}function i({iframeRef:t}){return(0,e.validateForm)({iframe:r(t)})}function a({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmPayment)({iframe:r(t),token:n,defaultValues:i})}function o({iframeRef:t,token:n,defaultValues:i}){return(0,e.confirmSetup)({iframe:r(t),token:n,defaultValues:i})}function s({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c({iframeRef:t,field:n}){(0,e.focusField)({iframe:r(t),field:n})}function l(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function u(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),Object.assign(e.style,t);for(let[t,n]of Object.entries(i))n!=null&&(t in e?Reflect.set(e,t,n):e.setAttribute(t,String(n)))}function d({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let c=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return c.current=a,l(n,a.iframe),u(a.iframe,o),()=>{a.destroy(),c.current=null,l(n,null)}},[...a]),(0,t.useEffect)(()=>{var e;(e=c.current)==null||e.update(i)},[...s]),(0,t.useEffect)(()=>{var e;let t=(e=c.current)==null?void 0:e.iframe;t&&u(t,o)})}var f=`oklch(0.97 0 0)`;function p({height:r,borderRadius:i,containerRef:a}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:r,minHeight:r,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:r,borderRadius:i,background:f,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:a,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function m(t,n){return(0,e.mountAmosCreditCardPaymentMethodForm)(t,n)}function h(t,n){return(0,e.mountAmosBankAccountPaymentMethodForm)(t,n)}function g({ref:e,renderToken:r,appearance:i,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c,additionalFields:l={cardholderName:!1},billingAddressRequirement:u=`country`,defaultValues:f,style:p,...h}){let g=(0,t.useRef)(null);return d({containerRef:g,iframeRef:e,mount:m,options:{renderToken:r,appearance:i,additionalFields:l,billingAddressRequirement:u,defaultValues:f,onValidityChange:a,onCardBrandChanged:o,onPostalCodeChange:s,onEscapeKeyPressed:c},remountDeps:[r,l.cardholderName,u],iframePassthrough:{style:p,...h},updateDeps:[i,l,u,f,a,o,s,c]}),(0,n.jsx)(`div`,{ref:g})}function _({ref:e,renderToken:r,appearance:i,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s,billingAddressRequirement:c=`country`,defaultValues:l,requireAchVerification:u=!1,intent:f=`payment`,style:p,...m}){let g=(0,t.useRef)(null);return d({containerRef:g,iframeRef:e,mount:h,options:{renderToken:r,appearance:i,billingAddressRequirement:c,defaultValues:l,requireAchVerification:u,intent:f,onValidityChange:a,onPostalCodeChange:o,onEscapeKeyPressed:s},remountDeps:[r,c,f],iframePassthrough:{style:p,...m},updateDeps:[i,c,l,u,f,a,o,s]}),(0,n.jsx)(`div`,{ref:g})}function v({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:f,onConfirm:m}){let h=(0,t.useRef)(null),g=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:f==null?void 0:f.style,buttonProps:c});return d({containerRef:h,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:m},remountDeps:[i],iframePassthrough:f==null?{}:f,updateDeps:[a,o,s,c,l,u,m]}),(0,n.jsx)(p,{height:s,borderRadius:g,containerRef:h})}function y({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:f,onConfirm:m}){let h=(0,t.useRef)(null),g=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:f==null?void 0:f.style,buttonProps:c});return d({containerRef:h,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:m},remountDeps:[i],iframePassthrough:f==null?{}:f,updateDeps:[a,o,s,c,l,u,m]}),(0,n.jsx)(p,{height:s,borderRadius:g,containerRef:h})}exports.AmosApplePayButton=y,exports.AmosBankAccountPaymentMethodForm=_,exports.AmosCreditCardPaymentMethodForm=g,exports.AmosGooglePayButton=v,exports.confirmPayment=a,exports.confirmSetup=o,exports.focusField=c,exports.resetForm=s,exports.validateForm=i,Object.keys(e).forEach(function(t){t!=="default"&&!Object.prototype.hasOwnProperty.call(exports,t)&&Object.defineProperty(exports,t,{enumerable:!0,get:function(){return e[t]}})});
|
package/dist/index.mjs
CHANGED
|
@@ -95,12 +95,18 @@ function E({ height: e, borderRadius: t, containerRef: r }) {
|
|
|
95
95
|
})]
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
function D(
|
|
98
|
+
function D(e, t) {
|
|
99
|
+
return o(e, t);
|
|
100
|
+
}
|
|
101
|
+
function O(e, t) {
|
|
102
|
+
return a(e, t);
|
|
103
|
+
}
|
|
104
|
+
function k({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onPostalCodeChange: a, onEscapeKeyPressed: o, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", defaultValues: l, style: u, ...d }) {
|
|
99
105
|
let f = p(null);
|
|
100
106
|
return w({
|
|
101
107
|
containerRef: f,
|
|
102
108
|
iframeRef: e,
|
|
103
|
-
mount:
|
|
109
|
+
mount: D,
|
|
104
110
|
options: {
|
|
105
111
|
renderToken: t,
|
|
106
112
|
appearance: n,
|
|
@@ -109,7 +115,8 @@ function D({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardB
|
|
|
109
115
|
defaultValues: l,
|
|
110
116
|
onValidityChange: r,
|
|
111
117
|
onCardBrandChanged: i,
|
|
112
|
-
|
|
118
|
+
onPostalCodeChange: a,
|
|
119
|
+
onEscapeKeyPressed: o
|
|
113
120
|
},
|
|
114
121
|
remountDeps: [
|
|
115
122
|
t,
|
|
@@ -127,16 +134,17 @@ function D({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardB
|
|
|
127
134
|
l,
|
|
128
135
|
r,
|
|
129
136
|
i,
|
|
130
|
-
a
|
|
137
|
+
a,
|
|
138
|
+
o
|
|
131
139
|
]
|
|
132
140
|
}), /* @__PURE__ */ m("div", { ref: f });
|
|
133
141
|
}
|
|
134
|
-
function
|
|
142
|
+
function A({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPostalCodeChange: i, onEscapeKeyPressed: a, billingAddressRequirement: o = "country", defaultValues: s, requireAchVerification: c = !1, intent: l = "payment", style: u, ...d }) {
|
|
135
143
|
let f = p(null);
|
|
136
144
|
return w({
|
|
137
145
|
containerRef: f,
|
|
138
146
|
iframeRef: e,
|
|
139
|
-
mount:
|
|
147
|
+
mount: O,
|
|
140
148
|
options: {
|
|
141
149
|
renderToken: t,
|
|
142
150
|
appearance: n,
|
|
@@ -145,7 +153,8 @@ function O({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onEscap
|
|
|
145
153
|
requireAchVerification: c,
|
|
146
154
|
intent: l,
|
|
147
155
|
onValidityChange: r,
|
|
148
|
-
|
|
156
|
+
onPostalCodeChange: i,
|
|
157
|
+
onEscapeKeyPressed: a
|
|
149
158
|
},
|
|
150
159
|
remountDeps: [
|
|
151
160
|
t,
|
|
@@ -163,11 +172,12 @@ function O({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onEscap
|
|
|
163
172
|
c,
|
|
164
173
|
l,
|
|
165
174
|
r,
|
|
166
|
-
i
|
|
175
|
+
i,
|
|
176
|
+
a
|
|
167
177
|
]
|
|
168
178
|
}), /* @__PURE__ */ m("div", { ref: f });
|
|
169
179
|
}
|
|
170
|
-
function
|
|
180
|
+
function j({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, phoneRequired: o, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
|
|
171
181
|
let f = p(null), h = l({
|
|
172
182
|
iframeStyle: u == null ? void 0 : u.style,
|
|
173
183
|
buttonProps: a
|
|
@@ -203,7 +213,7 @@ function k({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48
|
|
|
203
213
|
containerRef: f
|
|
204
214
|
});
|
|
205
215
|
}
|
|
206
|
-
function
|
|
216
|
+
function M({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48px", buttonProps: o, phoneRequired: s, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
|
|
207
217
|
let f = p(null), h = l({
|
|
208
218
|
iframeStyle: u == null ? void 0 : u.style,
|
|
209
219
|
buttonProps: o
|
|
@@ -240,4 +250,4 @@ function A({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48
|
|
|
240
250
|
});
|
|
241
251
|
}
|
|
242
252
|
//#endregion
|
|
243
|
-
export {
|
|
253
|
+
export { M as AmosApplePayButton, A as AmosBankAccountPaymentMethodForm, k as AmosCreditCardPaymentMethodForm, j as AmosGooglePayButton, v as confirmPayment, y as confirmSetup, x as focusField, b as resetForm, _ as validateForm };
|
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.22",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
],
|
|
47
47
|
"description": "React SDK for embedding Amos payment methods via iframes. Wraps @amos.com/amos-js.",
|
|
48
48
|
"devDependencies": {
|
|
49
|
-
"@amos.com/node": "0.1.
|
|
49
|
+
"@amos.com/node": "0.1.64",
|
|
50
50
|
"@biomejs/biome": "2.5.11",
|
|
51
51
|
"@changesets/cli": "2.31.1",
|
|
52
52
|
"@types/node": "26.4.0",
|
|
@@ -57,11 +57,11 @@
|
|
|
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.24",
|
|
61
61
|
"@types/googlepay": "0.7.12"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
|
64
64
|
"react": "^17 || ^18 || ^19",
|
|
65
|
-
"@amos.com/node": ">=0.1.
|
|
65
|
+
"@amos.com/node": ">=0.1.64"
|
|
66
66
|
}
|
|
67
67
|
}
|
package/src/index.tsx
CHANGED
|
@@ -296,6 +296,35 @@ function WalletButtonSlot({
|
|
|
296
296
|
);
|
|
297
297
|
}
|
|
298
298
|
|
|
299
|
+
type PostalCodeChangeHandler = (event: {
|
|
300
|
+
postalCode: string | null;
|
|
301
|
+
country: string;
|
|
302
|
+
}) => void;
|
|
303
|
+
|
|
304
|
+
/**
|
|
305
|
+
* The installed `@amos.com/amos-js` types may not include
|
|
306
|
+
* `onPostalCodeChange` until that package is published. The mount
|
|
307
|
+
* parameter accepts the extra field; the runtime object still carries
|
|
308
|
+
* it into `attachPaymentMethodFormListeners`.
|
|
309
|
+
*/
|
|
310
|
+
function mountCreditCardPaymentMethodForm(
|
|
311
|
+
container: HTMLElement,
|
|
312
|
+
options: Parameters<typeof mountAmosCreditCardPaymentMethodForm>[1] & {
|
|
313
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
314
|
+
},
|
|
315
|
+
) {
|
|
316
|
+
return mountAmosCreditCardPaymentMethodForm(container, options);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
function mountBankAccountPaymentMethodForm(
|
|
320
|
+
container: HTMLElement,
|
|
321
|
+
options: Parameters<typeof mountAmosBankAccountPaymentMethodForm>[1] & {
|
|
322
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
323
|
+
},
|
|
324
|
+
) {
|
|
325
|
+
return mountAmosBankAccountPaymentMethodForm(container, options);
|
|
326
|
+
}
|
|
327
|
+
|
|
299
328
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
300
329
|
renderToken: string;
|
|
301
330
|
appearance?: Appearance;
|
|
@@ -319,6 +348,12 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
319
348
|
| "jcb"
|
|
320
349
|
| null;
|
|
321
350
|
}) => void;
|
|
351
|
+
/**
|
|
352
|
+
* Called when the customer commits a billing postal code, or clears
|
|
353
|
+
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
354
|
+
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
355
|
+
*/
|
|
356
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
322
357
|
/**
|
|
323
358
|
* Called when the customer presses Escape in the iframe. PCI-safe —
|
|
324
359
|
* no field values. Use this to close a host modal that contains the
|
|
@@ -343,6 +378,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
343
378
|
appearance,
|
|
344
379
|
onValidityChange,
|
|
345
380
|
onCardBrandChanged,
|
|
381
|
+
onPostalCodeChange,
|
|
346
382
|
onEscapeKeyPressed,
|
|
347
383
|
additionalFields = { cardholderName: false },
|
|
348
384
|
billingAddressRequirement = "country",
|
|
@@ -355,7 +391,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
355
391
|
useAmosEmbed({
|
|
356
392
|
containerRef,
|
|
357
393
|
iframeRef: ref as ForwardedIframeRef,
|
|
358
|
-
mount:
|
|
394
|
+
mount: mountCreditCardPaymentMethodForm,
|
|
359
395
|
options: {
|
|
360
396
|
renderToken,
|
|
361
397
|
appearance,
|
|
@@ -364,6 +400,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
364
400
|
defaultValues,
|
|
365
401
|
onValidityChange,
|
|
366
402
|
onCardBrandChanged,
|
|
403
|
+
onPostalCodeChange,
|
|
367
404
|
onEscapeKeyPressed,
|
|
368
405
|
},
|
|
369
406
|
remountDeps: [
|
|
@@ -379,6 +416,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
379
416
|
defaultValues,
|
|
380
417
|
onValidityChange,
|
|
381
418
|
onCardBrandChanged,
|
|
419
|
+
onPostalCodeChange,
|
|
382
420
|
onEscapeKeyPressed,
|
|
383
421
|
],
|
|
384
422
|
});
|
|
@@ -403,6 +441,12 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
403
441
|
* showing.
|
|
404
442
|
*/
|
|
405
443
|
onEscapeKeyPressed?: () => void;
|
|
444
|
+
/**
|
|
445
|
+
* Called when the customer commits a billing postal code, or clears
|
|
446
|
+
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
447
|
+
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
448
|
+
*/
|
|
449
|
+
onPostalCodeChange?: PostalCodeChangeHandler;
|
|
406
450
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
407
451
|
/**
|
|
408
452
|
* Seed account holder name and billing address. Provided keys
|
|
@@ -438,6 +482,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
438
482
|
renderToken,
|
|
439
483
|
appearance,
|
|
440
484
|
onValidityChange,
|
|
485
|
+
onPostalCodeChange,
|
|
441
486
|
onEscapeKeyPressed,
|
|
442
487
|
billingAddressRequirement = "country",
|
|
443
488
|
defaultValues,
|
|
@@ -451,7 +496,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
451
496
|
useAmosEmbed({
|
|
452
497
|
containerRef,
|
|
453
498
|
iframeRef: ref as ForwardedIframeRef,
|
|
454
|
-
mount:
|
|
499
|
+
mount: mountBankAccountPaymentMethodForm,
|
|
455
500
|
options: {
|
|
456
501
|
renderToken,
|
|
457
502
|
appearance,
|
|
@@ -460,6 +505,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
460
505
|
requireAchVerification,
|
|
461
506
|
intent,
|
|
462
507
|
onValidityChange,
|
|
508
|
+
onPostalCodeChange,
|
|
463
509
|
onEscapeKeyPressed,
|
|
464
510
|
},
|
|
465
511
|
// `requireAchVerification` is an update, not a remount: amos-js hides
|
|
@@ -473,6 +519,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
473
519
|
requireAchVerification,
|
|
474
520
|
intent,
|
|
475
521
|
onValidityChange,
|
|
522
|
+
onPostalCodeChange,
|
|
476
523
|
onEscapeKeyPressed,
|
|
477
524
|
],
|
|
478
525
|
});
|