@amos.com/react-amos-js 0.9.17 → 0.10.1
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 +7 -6
- package/dist/index.d.ts +14 -4
- package/dist/index.js +1 -1
- package/dist/index.mjs +16 -14
- package/package.json +2 -2
- package/src/index.tsx +24 -4
package/README.md
CHANGED
|
@@ -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
|
|
|
@@ -494,18 +495,18 @@ Renders the secure bank account iframe form. A field-shaped skeleton is shown im
|
|
|
494
495
|
|
|
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.
|
|
496
497
|
|
|
497
|
-
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onResult
|
|
498
|
+
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`, `onResult` — plus:
|
|
498
499
|
|
|
499
|
-
|
|
500
|
+
- `amount` (`string`, major-currency decimal, e.g. `"50.00"`, defaults to `"0"`) — same format as Google Pay / Apple Pay. Compared to the threshold the iframe fetches (cents). Pass `"0"` (the default) on open-amount forms until the customer enters a charge — 0 is typically under the threshold, so Connect stays hidden. Pass a new `amount` when the customer changes the charge. For setup intents, pass an amount at or above the merchant ACH threshold (the expected future charge) to show Connect.
|
|
500
501
|
|
|
501
|
-
|
|
502
|
+
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange` (`isValid` is also true after Plaid Link returns credentials).
|
|
502
503
|
|
|
503
|
-
Compare locally once the iframe posts `ACH_THRESHOLD`: Plaid when the amount (converted to cents
|
|
504
|
+
Compare locally once the iframe posts `ACH_THRESHOLD`: Plaid when the amount (converted to cents, default `0`) is `>= achThreshold`. 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.
|
|
504
505
|
|
|
505
506
|
```tsx
|
|
506
507
|
<AmosBankAccountPaymentMethodForm
|
|
507
508
|
renderToken={renderToken}
|
|
508
|
-
amount="50.00" //
|
|
509
|
+
amount="50.00" // defaults to "0" (manual form until the charge meets the threshold)
|
|
509
510
|
onResult={onResult}
|
|
510
511
|
/>
|
|
511
512
|
```
|
|
@@ -583,7 +584,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
583
584
|
|
|
584
585
|
### Exported types
|
|
585
586
|
|
|
586
|
-
`@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`.
|
|
587
588
|
|
|
588
589
|
## Notes and potential gotchas
|
|
589
590
|
|
package/dist/index.d.ts
CHANGED
|
@@ -53,10 +53,18 @@ 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;
|
|
@@ -73,9 +81,11 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
73
81
|
/**
|
|
74
82
|
* Charge amount as a major-currency decimal string (e.g. `"50.00"`
|
|
75
83
|
* for $50.00), the same format as Google Pay / Apple Pay. Compared
|
|
76
|
-
* to the merchant ACH threshold fetched by the iframe.
|
|
77
|
-
*
|
|
78
|
-
*
|
|
84
|
+
* to the merchant ACH threshold fetched by the iframe. Defaults to
|
|
85
|
+
* `"0"`, which is typically under the threshold so Connect / Plaid
|
|
86
|
+
* stays hidden until the host passes a real charge.
|
|
87
|
+
*
|
|
88
|
+
* @default "0"
|
|
79
89
|
*/
|
|
80
90
|
amount?: string;
|
|
81
91
|
};
|
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:
|
|
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=`0`,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,39 +84,41 @@ 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,
|
|
88
|
-
let
|
|
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:
|
|
90
|
+
containerRef: d,
|
|
91
91
|
iframeRef: e,
|
|
92
92
|
mount: a,
|
|
93
93
|
options: {
|
|
94
94
|
renderToken: t,
|
|
95
95
|
appearance: n,
|
|
96
|
-
additionalFields:
|
|
97
|
-
billingAddressRequirement:
|
|
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
|
-
|
|
104
|
-
|
|
104
|
+
s.cardholderName,
|
|
105
|
+
c
|
|
105
106
|
],
|
|
106
107
|
iframePassthrough: {
|
|
107
|
-
style:
|
|
108
|
-
...
|
|
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:
|
|
119
|
+
}), /* @__PURE__ */ p("div", { ref: d });
|
|
118
120
|
}
|
|
119
|
-
function E({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, billingAddressRequirement: o = "country", amount: s, style: c, ...l }) {
|
|
121
|
+
function E({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, billingAddressRequirement: o = "country", amount: s = "0", style: c, ...l }) {
|
|
120
122
|
let u = f(null);
|
|
121
123
|
return S({
|
|
122
124
|
containerRef: u,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.1",
|
|
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.
|
|
51
|
+
"@amos.com/amos-js": "0.10.1",
|
|
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
|
|
|
@@ -314,9 +332,11 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
314
332
|
/**
|
|
315
333
|
* Charge amount as a major-currency decimal string (e.g. `"50.00"`
|
|
316
334
|
* for $50.00), the same format as Google Pay / Apple Pay. Compared
|
|
317
|
-
* to the merchant ACH threshold fetched by the iframe.
|
|
318
|
-
*
|
|
319
|
-
*
|
|
335
|
+
* to the merchant ACH threshold fetched by the iframe. Defaults to
|
|
336
|
+
* `"0"`, which is typically under the threshold so Connect / Plaid
|
|
337
|
+
* stays hidden until the host passes a real charge.
|
|
338
|
+
*
|
|
339
|
+
* @default "0"
|
|
320
340
|
*/
|
|
321
341
|
amount?: string;
|
|
322
342
|
};
|
|
@@ -328,7 +348,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
328
348
|
onResult,
|
|
329
349
|
onValidityChange,
|
|
330
350
|
billingAddressRequirement = "country",
|
|
331
|
-
amount,
|
|
351
|
+
amount = "0",
|
|
332
352
|
style,
|
|
333
353
|
...rest
|
|
334
354
|
}: AmosBankAccountPaymentMethodFormProps) {
|