@amos.com/react-amos-js 0.9.16 → 0.10.0

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
@@ -82,7 +82,7 @@ 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, and an optional `labels` setting for field label placement. You can update this prop after page load to update the iframe appearance. Wallet buttons do not take `appearance`.
85
+ Card and bank components accept an optional `appearance` prop that controls the look of the iframe UI, and of the parent-page **Connect bank account** button when ACH verification is required. It contains a `themeVariables` object whose keys are CSS custom-property names and whose values are strings, and an optional `labels` setting for field label placement. You can update this prop after page load to update the iframe appearance. Wallet buttons do not take `appearance`.
86
86
 
87
87
  ```tsx
88
88
  <AmosCreditCardPaymentMethodForm
@@ -155,7 +155,7 @@ Radio groups (e.g. account type) always use an above-style group label regardles
155
155
  | `--control-gap` | Horizontal gap between side-by-side controls | `0.5rem` |
156
156
  | `--error-font-size` | Font size of field-level error messages | `0.875rem` |
157
157
  | `--radio-size` | Size of radio buttons on the bank account form | `1rem` |
158
- | `--ring` | Focus ring and outline color | `oklch(0.708 0 0)` |
158
+ | `--ring` | Focus ring and outline color (inputs, Connect button) | `oklch(0.708 0 0)` |
159
159
  | `--ring-width` | Focus ring width | `3px` |
160
160
  | `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
161
161
 
@@ -485,6 +485,7 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
485
485
  - `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
486
486
  - `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.
487
487
  - `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.
488
+ - `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.
488
489
 
489
490
  **Also accepts:** standard iframe props (`React.ComponentProps<"iframe">`), minus `src`, `title`, `name`, and `role` (which are controlled by the SDK).
490
491
 
@@ -492,9 +493,27 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
492
493
 
493
494
  Renders the secure bank account iframe form. A field-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
494
495
 
496
+ When the charge meets the merchant’s ACH verification threshold, the SDK hides the routing/account iframe and renders a **Connect bank account** button in the parent page. The button follows the same outline/focus defaults as Amos UI (`--ring`, `--border`, `--radius`, `--input-height`, …): it inherits those CSS variables from the host page when present, and `appearance.themeVariables` overrides them the same way as the iframe. Clicking it asks the iframe to mint a Plaid Link token, then opens [Plaid Link](https://plaid.com/docs/link/web/). 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.
497
+
495
498
  **Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onResult`.
496
499
 
497
- **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange`.
500
+ **Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange` (`isValid` is also true after Plaid Link returns credentials), plus:
501
+
502
+ - `amount` (`string`, major-currency decimal, e.g. `"50.00"`) — same format as Google Pay / Apple Pay. Compared to the threshold the iframe fetches (cents). Omit to always Connect once a threshold exists (setup-intent save, or when you do not know the charge yet). Pass a new `amount` when the customer changes the charge if small charges should stay on the manual form.
503
+
504
+ Compare locally once the iframe posts `ACH_THRESHOLD`: Plaid when the amount (converted to cents) is `>= achThreshold`, or when `amount` is omitted and a threshold is set. No threshold (or `null`) keeps the manual bank form. If `amount` later drops under the threshold, Plaid credentials are dropped and the iframe form is shown again.
505
+
506
+ ```tsx
507
+ <AmosBankAccountPaymentMethodForm
508
+ renderToken={renderToken}
509
+ amount="50.00" // omit to always Connect
510
+ onResult={onResult}
511
+ />
512
+ ```
513
+
514
+ `validateForm` / `confirmPaymentIntent` / `confirmSetupIntent` stay iframe-based. When Plaid succeeded, confirm sends `payment_method.plaid` (`public_token`, `account_id`) and does not require typed account numbers.
515
+
516
+ **CSP:** the parent page must allow Plaid’s script and frames, for example `script-src https://cdn.plaid.com` and `frame-src https://cdn.plaid.com https://*.plaid.com`. Amos never loads `PLAID_SECRET` / `PLAID_CLIENT_ID` in the SDK or embed iframe.
498
517
 
499
518
  **Also accepts:** standard iframe props.
500
519
 
@@ -565,14 +584,15 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
565
584
 
566
585
  ### Exported types
567
586
 
568
- `@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmationResult`, `ConfirmationIncompleteReason`, `PaymentMethodFormValidityChangeEvent`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
587
+ `@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmationResult`, `ConfirmationIncompleteReason`, `PaymentMethodFormValidityChangeEvent`, `CardBrand`, `PaymentMethodFormCardBrandChangeEvent`, `FormattedGooglePayPaymentData`, `Message`, `Appearance`, `ThemeVariable`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
569
588
 
570
589
  ## Notes and potential gotchas
571
590
 
572
591
  - **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, `confirmSetupIntent`, or `resetForm`. The component forwards the ref to the inner iframe.
573
592
  - **`onResult` is not settlement proof**: `onResult` tells you when to stop waiting (e.g. dismiss a spinner). Verify payment or setup success on your backend via webhooks. On `status: "incomplete"`, unlock your UI — the customer can fix fields in the iframe and retry. Use `result.reason` (`"field_errors"` or `"validation_failed"`) to distinguish recoverable states.
574
593
  - **Same components for payment vs setup intents**: `AmosCreditCardPaymentMethodForm` and `AmosBankAccountPaymentMethodForm` support both payment intents and setup intents. The flow differs only by which server call you make and which confirmation function you use (`confirmPaymentIntent` vs `confirmSetupIntent`). Handle both payment and setup outcomes via `onResult`.
575
- - **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 `onInitiatePaymentIntentRequest`), `amount` is a number in cents (e.g. `5000`).
594
+ - **Amount format**: for `AmosGooglePayButton`, `AmosApplePayButton`, and `AmosBankAccountPaymentMethodForm`, `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 `onInitiatePaymentIntentRequest`), `amount` is a number in cents (e.g. `5000`).
595
+ - **Plaid Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe fetches the ACH threshold and mints link tokens. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method.
576
596
  - **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.
577
597
  - **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.
578
598
 
package/dist/index.d.ts CHANGED
@@ -53,24 +53,41 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
53
53
  onValidityChange?: (event: {
54
54
  isValid: boolean;
55
55
  }) => void;
56
+ /**
57
+ * Called when the detected card brand changes. `brand` is the matched
58
+ * network, or `null` when the field is empty or the digits do not
59
+ * match a known brand. Does not include PCI data.
60
+ */
61
+ onCardBrandChanged?: (event: {
62
+ brand: "visa" | "mastercard" | "amex" | "discover" | "diners" | "jcb" | null;
63
+ }) => void;
56
64
  additionalFields?: CreditCardAdditionalFields;
57
65
  billingAddressRequirement?: BillingAddressRequirement;
58
66
  };
59
- export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
67
+ export declare function AmosCreditCardPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, onCardBrandChanged, additionalFields, billingAddressRequirement, style, ...rest }: AmosCreditCardPaymentMethodFormProps): import("react").JSX.Element;
60
68
  type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
61
69
  renderToken: string;
62
70
  appearance?: Appearance;
63
71
  onResult: (result: ConfirmationResult) => void;
64
72
  /**
65
73
  * Called when form validity changes. `isValid` is true when all
66
- * required fields are present and valid. Does not include PCI data.
74
+ * required fields are present and valid, or when Plaid Link has
75
+ * returned credentials. Does not include PCI data.
67
76
  */
68
77
  onValidityChange?: (event: {
69
78
  isValid: boolean;
70
79
  }) => void;
71
80
  billingAddressRequirement?: BillingAddressRequirement;
81
+ /**
82
+ * Charge amount as a major-currency decimal string (e.g. `"50.00"`
83
+ * for $50.00), the same format as Google Pay / Apple Pay. Compared
84
+ * to the merchant ACH threshold fetched by the iframe. Omit for
85
+ * setup intents or when the charge is unknown — if a threshold is
86
+ * set, Plaid is required.
87
+ */
88
+ amount?: string;
72
89
  };
73
- export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
90
+ export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, billingAddressRequirement, amount, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
74
91
  type AmosGooglePayButtonProps = {
75
92
  ref?: ForwardedIframeRef;
76
93
  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}){(0,e.confirmPaymentIntent)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){(0,e.confirmSetupIntent)({iframe:r(t),token:n})}function s({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function l(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 u({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let u=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return u.current=a,c(n,a.iframe),l(a.iframe,o),()=>{a.destroy(),u.current=null,c(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&l(e,o)})}var d=`oklch(0.97 0 0)`;function f({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:d,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 p({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,additionalFields:c={cardholderName:!1},billingAddressRequirement:l=`country`,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:c,billingAddressRequirement:l,onResult:o,onValidityChange:s},remountDeps:[i,c.cardholderName,l],iframePassthrough:{style:d,...f},updateDeps:[a,c,l,o,s]}),(0,n.jsx)(`div`,{ref:p})}function m({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,billingAddressRequirement:c=`country`,style:l,...d}){let f=(0,t.useRef)(null);return u({containerRef:f,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:c,onResult:o,onValidityChange:s},remountDeps:[i,c],iframePassthrough:{style:l,...d},updateDeps:[a,c,o,s]}),(0,n.jsx)(`div`,{ref:f})}function h({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:p}){let m=(0,t.useRef)(null),h=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:p},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,p]}),(0,n.jsx)(f,{height:s,borderRadius:h,containerRef:m})}function g({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:p}){let m=(0,t.useRef)(null),h=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:m,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:p},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,p]}),(0,n.jsx)(f,{height:s,borderRadius:h,containerRef:m})}exports.AmosApplePayButton=g,exports.AmosBankAccountPaymentMethodForm=m,exports.AmosCreditCardPaymentMethodForm=p,exports.AmosGooglePayButton=h,exports.confirmPaymentIntent=a,exports.confirmSetupIntent=o,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}){(0,e.confirmPaymentIntent)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){(0,e.confirmSetupIntent)({iframe:r(t),token:n})}function s({iframeRef:t}){(0,e.resetForm)({iframe:r(t)})}function c(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function l(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 u({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let u=(0,t.useRef)(null);(0,t.useLayoutEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return u.current=a,c(n,a.iframe),l(a.iframe,o),()=>{a.destroy(),u.current=null,c(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&l(e,o)})}var d=`oklch(0.97 0 0)`;function f({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:d,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 p({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,onCardBrandChanged:c,additionalFields:l={cardholderName:!1},billingAddressRequirement:d=`country`,style:f,...p}){let m=(0,t.useRef)(null);return u({containerRef:m,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:l,billingAddressRequirement:d,onResult:o,onValidityChange:s,onCardBrandChanged:c},remountDeps:[i,l.cardholderName,d],iframePassthrough:{style:f,...p},updateDeps:[a,l,d,o,s,c]}),(0,n.jsx)(`div`,{ref:m})}function m({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,billingAddressRequirement:c=`country`,amount:l,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:c,amount:l,onResult:o,onValidityChange:s},remountDeps:[i,c],iframePassthrough:{style:d,...f},updateDeps:[a,c,l,o,s]}),(0,n.jsx)(`div`,{ref:p})}function h({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:p}){let m=(0,t.useRef)(null),h=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:p},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,p]}),(0,n.jsx)(f,{height:s,borderRadius:h,containerRef:m})}function g({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:p}){let m=(0,t.useRef)(null),h=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:m,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:p},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,p]}),(0,n.jsx)(f,{height:s,borderRadius:h,containerRef:m})}exports.AmosApplePayButton=g,exports.AmosBankAccountPaymentMethodForm=m,exports.AmosCreditCardPaymentMethodForm=p,exports.AmosGooglePayButton=h,exports.confirmPaymentIntent=a,exports.confirmSetupIntent=o,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
@@ -84,63 +84,67 @@ function w({ height: e, borderRadius: t, containerRef: r }) {
84
84
  })]
85
85
  });
86
86
  }
87
- function T({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: i, additionalFields: o = { cardholderName: !1 }, billingAddressRequirement: s = "country", style: c, ...l }) {
88
- let u = f(null);
87
+ function T({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: i, onCardBrandChanged: o, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: c = "country", style: l, ...u }) {
88
+ let d = f(null);
89
89
  return S({
90
- containerRef: u,
90
+ containerRef: d,
91
91
  iframeRef: e,
92
92
  mount: a,
93
93
  options: {
94
94
  renderToken: t,
95
95
  appearance: n,
96
- additionalFields: o,
97
- billingAddressRequirement: s,
96
+ additionalFields: s,
97
+ billingAddressRequirement: c,
98
98
  onResult: r,
99
- onValidityChange: i
99
+ onValidityChange: i,
100
+ onCardBrandChanged: o
100
101
  },
101
102
  remountDeps: [
102
103
  t,
103
- o.cardholderName,
104
- s
104
+ s.cardholderName,
105
+ c
105
106
  ],
106
107
  iframePassthrough: {
107
- style: c,
108
- ...l
108
+ style: l,
109
+ ...u
109
110
  },
110
111
  updateDeps: [
111
112
  n,
112
- o,
113
113
  s,
114
+ c,
114
115
  r,
115
- i
116
+ i,
117
+ o
116
118
  ]
117
- }), /* @__PURE__ */ p("div", { ref: u });
119
+ }), /* @__PURE__ */ p("div", { ref: d });
118
120
  }
119
- function E({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, billingAddressRequirement: o = "country", style: s, ...c }) {
120
- let l = f(null);
121
+ function E({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, billingAddressRequirement: o = "country", amount: s, style: c, ...l }) {
122
+ let u = f(null);
121
123
  return S({
122
- containerRef: l,
124
+ containerRef: u,
123
125
  iframeRef: e,
124
126
  mount: i,
125
127
  options: {
126
128
  renderToken: t,
127
129
  appearance: n,
128
130
  billingAddressRequirement: o,
131
+ amount: s,
129
132
  onResult: r,
130
133
  onValidityChange: a
131
134
  },
132
135
  remountDeps: [t, o],
133
136
  iframePassthrough: {
134
- style: s,
135
- ...c
137
+ style: c,
138
+ ...l
136
139
  },
137
140
  updateDeps: [
138
141
  n,
139
142
  o,
143
+ s,
140
144
  r,
141
145
  a
142
146
  ]
143
- }), /* @__PURE__ */ p("div", { ref: l });
147
+ }), /* @__PURE__ */ p("div", { ref: u });
144
148
  }
145
149
  function D({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, iframeProps: s, onInitiatePaymentIntentRequest: l, onResult: u }) {
146
150
  let d = f(null), m = c({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.9.16",
3
+ "version": "0.10.0",
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.9.17",
51
+ "@amos.com/amos-js": "0.10.0",
52
52
  "@types/googlepay": "0.7.11"
53
53
  },
54
54
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -253,6 +253,21 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
253
253
  * required fields are present and valid. Does not include PCI data.
254
254
  */
255
255
  onValidityChange?: (event: { isValid: boolean }) => void;
256
+ /**
257
+ * Called when the detected card brand changes. `brand` is the matched
258
+ * network, or `null` when the field is empty or the digits do not
259
+ * match a known brand. Does not include PCI data.
260
+ */
261
+ onCardBrandChanged?: (event: {
262
+ brand:
263
+ | "visa"
264
+ | "mastercard"
265
+ | "amex"
266
+ | "discover"
267
+ | "diners"
268
+ | "jcb"
269
+ | null;
270
+ }) => void;
256
271
  additionalFields?: CreditCardAdditionalFields;
257
272
  billingAddressRequirement?: BillingAddressRequirement;
258
273
  };
@@ -263,6 +278,7 @@ export function AmosCreditCardPaymentMethodForm({
263
278
  appearance,
264
279
  onResult,
265
280
  onValidityChange,
281
+ onCardBrandChanged,
266
282
  additionalFields = { cardholderName: false },
267
283
  billingAddressRequirement = "country",
268
284
  style,
@@ -281,6 +297,7 @@ export function AmosCreditCardPaymentMethodForm({
281
297
  billingAddressRequirement,
282
298
  onResult,
283
299
  onValidityChange,
300
+ onCardBrandChanged,
284
301
  },
285
302
  remountDeps: [
286
303
  renderToken,
@@ -294,6 +311,7 @@ export function AmosCreditCardPaymentMethodForm({
294
311
  billingAddressRequirement,
295
312
  onResult,
296
313
  onValidityChange,
314
+ onCardBrandChanged,
297
315
  ],
298
316
  });
299
317
 
@@ -306,10 +324,19 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
306
324
  onResult: (result: ConfirmationResult) => void;
307
325
  /**
308
326
  * Called when form validity changes. `isValid` is true when all
309
- * required fields are present and valid. Does not include PCI data.
327
+ * required fields are present and valid, or when Plaid Link has
328
+ * returned credentials. Does not include PCI data.
310
329
  */
311
330
  onValidityChange?: (event: { isValid: boolean }) => void;
312
331
  billingAddressRequirement?: BillingAddressRequirement;
332
+ /**
333
+ * Charge amount as a major-currency decimal string (e.g. `"50.00"`
334
+ * for $50.00), the same format as Google Pay / Apple Pay. Compared
335
+ * to the merchant ACH threshold fetched by the iframe. Omit for
336
+ * setup intents or when the charge is unknown — if a threshold is
337
+ * set, Plaid is required.
338
+ */
339
+ amount?: string;
313
340
  };
314
341
 
315
342
  export function AmosBankAccountPaymentMethodForm({
@@ -319,6 +346,7 @@ export function AmosBankAccountPaymentMethodForm({
319
346
  onResult,
320
347
  onValidityChange,
321
348
  billingAddressRequirement = "country",
349
+ amount,
322
350
  style,
323
351
  ...rest
324
352
  }: AmosBankAccountPaymentMethodFormProps) {
@@ -332,6 +360,7 @@ export function AmosBankAccountPaymentMethodForm({
332
360
  renderToken,
333
361
  appearance,
334
362
  billingAddressRequirement,
363
+ amount,
335
364
  onResult,
336
365
  onValidityChange,
337
366
  },
@@ -340,6 +369,7 @@ export function AmosBankAccountPaymentMethodForm({
340
369
  updateDeps: [
341
370
  appearance,
342
371
  billingAddressRequirement,
372
+ amount,
343
373
  onResult,
344
374
  onValidityChange,
345
375
  ],