@amos.com/react-amos-js 0.11.21 → 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 CHANGED
@@ -575,6 +575,7 @@ Renders the secure credit card iframe form. A field-shaped skeleton covers a vis
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.
@@ -589,7 +590,7 @@ When `requireAchVerification` is true (or `intent` is `"setup"`), and the render
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.
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: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,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 _({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=_,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){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({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onEscapeKeyPressed: a, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", defaultValues: l, style: u, ...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: o,
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
- onEscapeKeyPressed: a
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 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 }) {
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: a,
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
- onEscapeKeyPressed: i
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 k({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, phoneRequired: o, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
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 A({ ref: e, renderToken: t, amount: n, merchantName: r, height: a = "48px", buttonProps: o, phoneRequired: s, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
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 { A as AmosApplePayButton, O as AmosBankAccountPaymentMethodForm, D as AmosCreditCardPaymentMethodForm, k as AmosGooglePayButton, v as confirmPayment, y as confirmSetup, x as focusField, b as resetForm, _ as validateForm };
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.21",
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.61",
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.23",
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.61"
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: mountAmosCreditCardPaymentMethodForm,
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: mountAmosBankAccountPaymentMethodForm,
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
  });