@amos.com/react-amos-js 0.11.7 → 0.11.9

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 CHANGED
@@ -159,7 +159,7 @@ Radio groups (e.g. account type) always use an above-style group label regardles
159
159
 
160
160
  ### Rendering the credit card inputs within your custom form
161
161
 
162
- Wrap the component in a host `<form>`. Enter in the iframe submits it (same as Stripe Elements). The parent cannot listen for that key itself because the iframe is cross-origin.
162
+ Wrap the component in a host `<form>`. Enter in the iframe submits it (same as Stripe Elements). The parent cannot listen for that key itself because the iframe is cross-origin. If you render the iframe inside a modal, pass `onEscapeKeyPressed` to close it — Escape inside the iframe is likewise invisible to the parent.
163
163
 
164
164
  ```tsx
165
165
  import { useRef, useState } from "react";
@@ -327,7 +327,7 @@ function CheckoutWallets({ renderToken }: { renderToken: string }) {
327
327
 
328
328
  Do not call `validateForm` from the host in an express flow — create a payment intent inside `onConfirm`, then `await confirmPayment(token)`. Size the mount slot; omitted `buttonProps` keep paint defaults and fill the iframe.
329
329
 
330
- On Safari, Apple Pay uses the native payment sheet. On other browsers, Apple's QR handoff opens in a popup (`pay.apple.com`); while that popup is open, the SDK shows a waiting overlay with **Cancel payment**.
330
+ On Safari, Apple Pay uses the native payment sheet. On other browsers, Apple's QR handoff opens in a popup (`pay.apple.com`); while that popup is open, the SDK shows a waiting overlay with **Cancel payment**. After the buyer authorizes, Cancel is removed and the overlay shows **Completing your payment…** until `onConfirm` settles.
331
331
 
332
332
  Optional visuals:
333
333
 
@@ -481,6 +481,7 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
481
481
  - `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.
482
482
  - `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.
483
483
  - `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.
484
+ - `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, or while Plaid Embedded Institution Search is showing. The parent cannot attach a keydown listener for this itself because the iframe is cross-origin.
484
485
 
485
486
  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.
486
487
 
@@ -494,7 +495,7 @@ When `requireAchVerification` is true (or `intent` is `"setup"`), and the render
494
495
 
495
496
  **Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`.
496
497
 
497
- **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange` (`isValid` is also true after Plaid returns credentials) — plus:
498
+ **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange` (`isValid` is also true after Plaid returns credentials), `onEscapeKeyPressed` — plus:
498
499
 
499
500
  - `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.
500
501
  - `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.
@@ -568,7 +569,7 @@ Renders the secure Apple Pay iframe button (express checkout flow). Same require
568
569
  />
569
570
  ```
570
571
 
571
- Only Amos domains need Apple merchant registration. The button and `ApplePaySession` run inside the Amos embed iframe. On Safari, the native payment sheet is used. On other browsers, Apple's QR handoff opens in a popup (`pay.apple.com`); while that popup is open, the SDK automatically shows a full-viewport waiting overlay on the host page with instructions and a **Cancel payment** button. You do not need to implement popup or overlay handling yourself.
572
+ Only Amos domains need Apple merchant registration. The button and `ApplePaySession` run inside the Amos embed iframe. On Safari, the native payment sheet is used. On other browsers, Apple's QR handoff opens in a popup (`pay.apple.com`); while that popup is open, the SDK automatically shows a full-viewport waiting overlay on the host page with instructions and a **Cancel payment** button. After the buyer authorizes, the overlay switches to **Completing your payment…** and hides Cancel so the donor cannot double-pay. You do not need to implement popup or overlay handling yourself.
572
573
 
573
574
  ### `formatGooglePayPaymentData({ paymentData })`
574
575
 
@@ -595,7 +596,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
595
596
  - **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`).
596
597
  - **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`).
597
598
  - **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.
598
- - **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 until payment completes, the popup closes, or the user clicks **Cancel payment**. Avoid stacking other fixed UI above it.
599
+ - **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.
599
600
  - **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.
600
601
 
601
602
  ---
package/dist/index.d.ts CHANGED
@@ -71,6 +71,14 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
71
71
  onCardBrandChanged?: (event: {
72
72
  brand: "visa" | "mastercard" | "amex" | "discover" | "diners" | "jcb" | null;
73
73
  }) => void;
74
+ /**
75
+ * Called when the customer presses Escape in the iframe. PCI-safe —
76
+ * no field values. Use this to close a host modal that contains the
77
+ * iframe. Not fired while an iframe dropdown or address suggestion
78
+ * list is open, or while Plaid Embedded Institution Search is
79
+ * showing.
80
+ */
81
+ onEscapeKeyPressed?: () => void;
74
82
  additionalFields?: CreditCardAdditionalFields;
75
83
  billingAddressRequirement?: BillingAddressRequirement;
76
84
  /**
@@ -80,7 +88,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
80
88
  */
81
89
  defaultValues?: PaymentMethodFormDefaultValues;
82
90
  };
83
- export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
91
+ export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onCardBrandChanged, onEscapeKeyPressed, additionalFields, billingAddressRequirement, defaultValues, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
84
92
  type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
85
93
  renderToken: string;
86
94
  appearance?: Appearance;
@@ -92,6 +100,14 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
92
100
  onValidityChange?: (event: {
93
101
  isValid: boolean;
94
102
  }) => void;
103
+ /**
104
+ * Called when the customer presses Escape in the iframe. PCI-safe —
105
+ * no field values. Use this to close a host modal that contains the
106
+ * iframe. Not fired while an iframe dropdown or address suggestion
107
+ * list is open, or while Plaid Embedded Institution Search is
108
+ * showing.
109
+ */
110
+ onEscapeKeyPressed?: () => void;
95
111
  billingAddressRequirement?: BillingAddressRequirement;
96
112
  /**
97
113
  * Seed account holder name and billing address. Provided keys
@@ -117,7 +133,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
117
133
  */
118
134
  intent?: "payment" | "setup";
119
135
  };
120
- export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
136
+ export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, onEscapeKeyPressed, billingAddressRequirement, defaultValues, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
121
137
  type AmosGooglePayButtonProps = {
122
138
  ref?: ForwardedIframeRef;
123
139
  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){return e?e.current??null: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)(()=>{c.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=c.current?.iframe;e&&u(e,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:r,renderToken:i,appearance:a,onValidityChange:o,onCardBrandChanged:s,additionalFields:c={cardholderName:!1},billingAddressRequirement:l=`country`,defaultValues:u,style:f,...p}){let m=(0,t.useRef)(null);return d({containerRef:m,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:c,billingAddressRequirement:l,defaultValues:u,onValidityChange:o,onCardBrandChanged:s},remountDeps:[i,c.cardholderName,l],iframePassthrough:{style:f,...p},updateDeps:[a,c,l,u,o,s]}),(0,n.jsx)(`div`,{ref:m})}function h({ref:r,renderToken:i,appearance:a,onValidityChange:o,billingAddressRequirement:s=`country`,defaultValues:c,requireAchVerification:l=!1,intent:u=`payment`,style:f,...p}){let m=(0,t.useRef)(null);return d({containerRef:m,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:s,defaultValues:c,requireAchVerification:l,intent:u,onValidityChange:o},remountDeps:[i,s,u],iframePassthrough:{style:f,...p},updateDeps:[a,s,c,l,u,o]}),(0,n.jsx)(`div`,{ref:m})}function g({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:u}){let f=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return d({containerRef:f,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:u},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(p,{height:s,borderRadius:m,containerRef:f})}function _({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:u}){let f=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return d({containerRef:f,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:u},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(p,{height:s,borderRadius:m,containerRef:f})}exports.AmosApplePayButton=_,exports.AmosBankAccountPaymentMethodForm=h,exports.AmosCreditCardPaymentMethodForm=m,exports.AmosGooglePayButton=g,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]}})});
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){return e?e.current??null: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)(()=>{c.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=c.current?.iframe;e&&u(e,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:r,renderToken:i,appearance:a,onValidityChange:o,onCardBrandChanged:s,onEscapeKeyPressed:c,additionalFields:l={cardholderName:!1},billingAddressRequirement:u=`country`,defaultValues:f,style:p,...m}){let h=(0,t.useRef)(null);return d({containerRef:h,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:l,billingAddressRequirement:u,defaultValues:f,onValidityChange:o,onCardBrandChanged:s,onEscapeKeyPressed:c},remountDeps:[i,l.cardholderName,u],iframePassthrough:{style:p,...m},updateDeps:[a,l,u,f,o,s,c]}),(0,n.jsx)(`div`,{ref:h})}function h({ref:r,renderToken:i,appearance:a,onValidityChange:o,onEscapeKeyPressed:s,billingAddressRequirement:c=`country`,defaultValues:l,requireAchVerification:u=!1,intent:f=`payment`,style:p,...m}){let h=(0,t.useRef)(null);return d({containerRef:h,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:c,defaultValues:l,requireAchVerification:u,intent:f,onValidityChange:o,onEscapeKeyPressed:s},remountDeps:[i,c,f],iframePassthrough:{style:p,...m},updateDeps:[a,c,l,u,f,o,s]}),(0,n.jsx)(`div`,{ref:h})}function g({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:u}){let f=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return d({containerRef:f,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:u},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(p,{height:s,borderRadius:m,containerRef:f})}function _({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:u}){let f=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return d({containerRef:f,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:u},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(p,{height:s,borderRadius:m,containerRef:f})}exports.AmosApplePayButton=_,exports.AmosBankAccountPaymentMethodForm=h,exports.AmosCreditCardPaymentMethodForm=m,exports.AmosGooglePayButton=g,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
@@ -92,73 +92,77 @@ function E({ height: e, borderRadius: t, containerRef: r }) {
92
92
  })]
93
93
  });
94
94
  }
95
- function D({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, additionalFields: a = { cardholderName: !1 }, billingAddressRequirement: s = "country", defaultValues: c, style: l, ...u }) {
96
- let d = p(null);
95
+ function D({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onEscapeKeyPressed: a, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", defaultValues: l, style: u, ...d }) {
96
+ let f = p(null);
97
97
  return w({
98
- containerRef: d,
98
+ containerRef: f,
99
99
  iframeRef: e,
100
100
  mount: o,
101
101
  options: {
102
102
  renderToken: t,
103
103
  appearance: n,
104
- additionalFields: a,
105
- billingAddressRequirement: s,
106
- defaultValues: c,
104
+ additionalFields: s,
105
+ billingAddressRequirement: c,
106
+ defaultValues: l,
107
107
  onValidityChange: r,
108
- onCardBrandChanged: i
108
+ onCardBrandChanged: i,
109
+ onEscapeKeyPressed: a
109
110
  },
110
111
  remountDeps: [
111
112
  t,
112
- a.cardholderName,
113
- s
113
+ s.cardholderName,
114
+ c
114
115
  ],
115
116
  iframePassthrough: {
116
- style: l,
117
- ...u
117
+ style: u,
118
+ ...d
118
119
  },
119
120
  updateDeps: [
120
121
  n,
121
- a,
122
122
  s,
123
123
  c,
124
+ l,
124
125
  r,
125
- i
126
+ i,
127
+ a
126
128
  ]
127
- }), /* @__PURE__ */ m("div", { ref: d });
129
+ }), /* @__PURE__ */ m("div", { ref: f });
128
130
  }
129
- function O({ ref: e, renderToken: t, appearance: n, onValidityChange: r, billingAddressRequirement: i = "country", defaultValues: o, requireAchVerification: s = !1, intent: c = "payment", style: l, ...u }) {
130
- let d = p(null);
131
+ function O({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onEscapeKeyPressed: i, billingAddressRequirement: o = "country", defaultValues: s, requireAchVerification: c = !1, intent: l = "payment", style: u, ...d }) {
132
+ let f = p(null);
131
133
  return w({
132
- containerRef: d,
134
+ containerRef: f,
133
135
  iframeRef: e,
134
136
  mount: a,
135
137
  options: {
136
138
  renderToken: t,
137
139
  appearance: n,
138
- billingAddressRequirement: i,
139
- defaultValues: o,
140
- requireAchVerification: s,
141
- intent: c,
142
- onValidityChange: r
140
+ billingAddressRequirement: o,
141
+ defaultValues: s,
142
+ requireAchVerification: c,
143
+ intent: l,
144
+ onValidityChange: r,
145
+ onEscapeKeyPressed: i
143
146
  },
144
147
  remountDeps: [
145
148
  t,
146
- i,
147
- c
149
+ o,
150
+ l
148
151
  ],
149
152
  iframePassthrough: {
150
- style: l,
151
- ...u
153
+ style: u,
154
+ ...d
152
155
  },
153
156
  updateDeps: [
154
157
  n,
155
- i,
156
158
  o,
157
159
  s,
158
160
  c,
159
- r
161
+ l,
162
+ r,
163
+ i
160
164
  ]
161
- }), /* @__PURE__ */ m("div", { ref: d });
165
+ }), /* @__PURE__ */ m("div", { ref: f });
162
166
  }
163
167
  function k({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, iframeProps: o, onConfirm: c }) {
164
168
  let u = p(null), d = l({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.11.7",
3
+ "version": "0.11.9",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -48,7 +48,7 @@
48
48
  "vite-plugin-dts": "5.0.3"
49
49
  },
50
50
  "dependencies": {
51
- "@amos.com/amos-js": "0.11.9",
51
+ "@amos.com/amos-js": "0.11.11",
52
52
  "@types/googlepay": "0.7.12"
53
53
  },
54
54
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -304,6 +304,14 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
304
304
  | "jcb"
305
305
  | null;
306
306
  }) => void;
307
+ /**
308
+ * Called when the customer presses Escape in the iframe. PCI-safe —
309
+ * no field values. Use this to close a host modal that contains the
310
+ * iframe. Not fired while an iframe dropdown or address suggestion
311
+ * list is open, or while Plaid Embedded Institution Search is
312
+ * showing.
313
+ */
314
+ onEscapeKeyPressed?: () => void;
307
315
  additionalFields?: CreditCardAdditionalFields;
308
316
  billingAddressRequirement?: BillingAddressRequirement;
309
317
  /**
@@ -320,6 +328,7 @@ export function AmosCreditCardPaymentMethodForm({
320
328
  appearance,
321
329
  onValidityChange,
322
330
  onCardBrandChanged,
331
+ onEscapeKeyPressed,
323
332
  additionalFields = { cardholderName: false },
324
333
  billingAddressRequirement = "country",
325
334
  defaultValues,
@@ -340,6 +349,7 @@ export function AmosCreditCardPaymentMethodForm({
340
349
  defaultValues,
341
350
  onValidityChange,
342
351
  onCardBrandChanged,
352
+ onEscapeKeyPressed,
343
353
  },
344
354
  remountDeps: [
345
355
  renderToken,
@@ -354,6 +364,7 @@ export function AmosCreditCardPaymentMethodForm({
354
364
  defaultValues,
355
365
  onValidityChange,
356
366
  onCardBrandChanged,
367
+ onEscapeKeyPressed,
357
368
  ],
358
369
  });
359
370
 
@@ -369,6 +380,14 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
369
380
  * has returned credentials. Does not include PCI data.
370
381
  */
371
382
  onValidityChange?: (event: { isValid: boolean }) => void;
383
+ /**
384
+ * Called when the customer presses Escape in the iframe. PCI-safe —
385
+ * no field values. Use this to close a host modal that contains the
386
+ * iframe. Not fired while an iframe dropdown or address suggestion
387
+ * list is open, or while Plaid Embedded Institution Search is
388
+ * showing.
389
+ */
390
+ onEscapeKeyPressed?: () => void;
372
391
  billingAddressRequirement?: BillingAddressRequirement;
373
392
  /**
374
393
  * Seed account holder name and billing address. Provided keys
@@ -400,6 +419,7 @@ export function AmosBankAccountPaymentMethodForm({
400
419
  renderToken,
401
420
  appearance,
402
421
  onValidityChange,
422
+ onEscapeKeyPressed,
403
423
  billingAddressRequirement = "country",
404
424
  defaultValues,
405
425
  requireAchVerification = false,
@@ -421,6 +441,7 @@ export function AmosBankAccountPaymentMethodForm({
421
441
  requireAchVerification,
422
442
  intent,
423
443
  onValidityChange,
444
+ onEscapeKeyPressed,
424
445
  },
425
446
  remountDeps: [renderToken, billingAddressRequirement, intent],
426
447
  iframePassthrough: { style, ...rest },
@@ -431,6 +452,7 @@ export function AmosBankAccountPaymentMethodForm({
431
452
  requireAchVerification,
432
453
  intent,
433
454
  onValidityChange,
455
+ onEscapeKeyPressed,
434
456
  ],
435
457
  });
436
458