@amos.com/react-amos-js 0.11.24 → 0.11.25
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 +9 -9
- package/dist/index.d.ts +3 -7
- package/dist/index.js +1 -1
- package/dist/index.mjs +31 -37
- package/package.json +2 -2
- package/src/index.tsx +5 -33
package/README.md
CHANGED
|
@@ -10,7 +10,7 @@ It is a thin wrapper around [`@amos.com/amos-js`](../amos-js) that adapts the fr
|
|
|
10
10
|
npm install @amos.com/react-amos-js @amos.com/node
|
|
11
11
|
```
|
|
12
12
|
|
|
13
|
-
`@amos.com/node` is a **peer dependency** (requires `>=0.1.
|
|
13
|
+
`@amos.com/node` is a **peer dependency** (requires `>=0.1.65`). Install it in your app for OpenAPI schema types (for example `components["schemas"]["CreatePaymentIntentInput"]`) used in the examples below, and for your server-side Amos API client. React (`^17`, `^18`, or `^19`) is also a peer dependency.
|
|
14
14
|
|
|
15
15
|
## What it gives you
|
|
16
16
|
|
|
@@ -141,7 +141,7 @@ appearance={{
|
|
|
141
141
|
|
|
142
142
|
Rules override `themeVariables` for the properties they set (Stripe). `--input-height` / `--floating-input-height` are a **minimum**; `.Input` `padding`, `fontSize`, and `lineHeight` can grow the field. Rule values may reference allowlisted tokens as `var(--primary)` (no fallback argument).
|
|
143
143
|
|
|
144
|
-
The host skeleton (shown until `UPDATED_APPEARANCE`, or 1.5s after
|
|
144
|
+
The host skeleton (shown until `UPDATED_APPEARANCE`, or 1.5s after mount if appearance never acks) copies `themeVariables` and resting **`.Input` / `.Label`** declarations (the same allowlisted properties as iframe rules). The iframe stays `opacity: 0` at its default pixel height underneath, so the skeleton is the only thing visible and WebKit still runs iframe JS. It does not inject webfonts: it uses `--font-family` / `fontFamily` when that face is already on the host page, and falls back to `ui-sans-serif, system-ui, sans-serif`. Hover, invalid, placeholder, dropdown, and radio rules have no skeleton equivalent. Floating labels sit inside the control, so `.Label` / `.Label--floating` do not change skeleton height.
|
|
145
145
|
|
|
146
146
|
| Selector | Targets |
|
|
147
147
|
| --- | --- |
|
|
@@ -560,7 +560,7 @@ Focus a named control inside the card or bank iframe. No-op if the field is not
|
|
|
560
560
|
|
|
561
561
|
### `AmosCreditCardPaymentMethodForm`
|
|
562
562
|
|
|
563
|
-
Renders the secure credit card iframe form. A field-shaped skeleton
|
|
563
|
+
Renders the secure credit card iframe form. A field-shaped skeleton is shown immediately (sized from `appearance`, including resting `.Input` / `.Label` rules). The iframe stays `opacity: 0` at its default pixel height until appearance is applied, or for 1.5s after mount if appearance never acks.
|
|
564
564
|
|
|
565
565
|
**Required props:**
|
|
566
566
|
|
|
@@ -584,7 +584,7 @@ Enter in a card or bank iframe field submits the enclosing host `<form>` via `re
|
|
|
584
584
|
|
|
585
585
|
### `AmosBankAccountPaymentMethodForm`
|
|
586
586
|
|
|
587
|
-
Renders the secure bank account iframe form. A field-shaped skeleton
|
|
587
|
+
Renders the secure bank account iframe form. A field-shaped skeleton is shown immediately (sized from `appearance`, including resting `.Input` / `.Label` rules). The iframe stays `opacity: 0` at its default pixel height until appearance is applied, or for 1.5s after mount if appearance never acks.
|
|
588
588
|
|
|
589
589
|
When `requireAchVerification` is true (or `intent` is `"setup"`), and the render token allows verification, the SDK hides the routing/account iframe and mounts [Plaid Embedded Institution Search](https://plaid.com/docs/link/embedded-institution-search/) in the parent. A **350px pulse skeleton** covers that slot until Plaid's `onLoad` (1.5s fallback). Do not overlay a host loader. Hosts do not proxy Pay API (`GET /merchants`, `POST /plaid_link_tokens`); embed does that with `PAY_API_KEY`. Do not put Plaid secrets in the browser.
|
|
590
590
|
|
|
@@ -621,7 +621,7 @@ Setup (always Plaid, unless the render token disables verification):
|
|
|
621
621
|
|
|
622
622
|
### `AmosGooglePayButton`
|
|
623
623
|
|
|
624
|
-
Renders the secure Google Pay iframe button (express checkout flow). A button-shaped skeleton
|
|
624
|
+
Renders the secure Google Pay iframe button (express checkout flow). A button-shaped skeleton is shown immediately. The iframe stays `opacity: 0` at its default pixel height until appearance is applied, or for 1.5s after mount if appearance never acks.
|
|
625
625
|
|
|
626
626
|
**Required props:**
|
|
627
627
|
|
|
@@ -648,7 +648,7 @@ Renders the secure Google Pay iframe button (express checkout flow). A button-sh
|
|
|
648
648
|
|
|
649
649
|
### `AmosApplePayButton`
|
|
650
650
|
|
|
651
|
-
Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`. A button-shaped skeleton
|
|
651
|
+
Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`. A button-shaped skeleton is shown immediately. The iframe stays `opacity: 0` at its default pixel height until appearance is applied, or for 1.5s after mount if appearance never acks.
|
|
652
652
|
|
|
653
653
|
**Optional props:**
|
|
654
654
|
|
|
@@ -690,7 +690,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
690
690
|
|
|
691
691
|
Re-exports from `@amos.com/amos-js`. Build the iframe `src` URL for each form type. The React components call these for you.
|
|
692
692
|
|
|
693
|
-
Each URL includes the embed's canonical search params (`token`, `additionalFields`, `billingAddressRequirement`, `intent`) so the embed router does not 307 to fill in defaults. After the iframe `load` event, if `IFRAME_READY` never arrives (stale HTML, missing JS chunk), the SDK rewrites `src` once with `amosReload` so the next document is a real navigation. Appearance is applied after handshake via `UPDATE_APPEARANCE`. A host-page skeleton
|
|
693
|
+
Each URL includes the embed's canonical search params (`token`, `additionalFields`, `billingAddressRequirement`, `intent`) so the embed router does not 307 to fill in defaults. After the iframe `load` event, if `IFRAME_READY` never arrives (stale HTML, missing JS chunk), the SDK rewrites `src` once with `amosReload` so the next document is a real navigation. Appearance is applied after handshake via `UPDATE_APPEARANCE`. A host-page skeleton is shown until then. The iframe stays `opacity: 0` at its default pixel height, and is revealed 1.5s after mount if appearance never acks.
|
|
694
694
|
|
|
695
695
|
### `updateDefaultValues({ iframe, defaultValues })`
|
|
696
696
|
|
|
@@ -702,7 +702,7 @@ Re-export from `@amos.com/amos-js`. Fills omitted Inter `fonts` / `--font-family
|
|
|
702
702
|
|
|
703
703
|
### Exported types
|
|
704
704
|
|
|
705
|
-
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmPaymentResult`, `ConfirmSetupResult`, `PaymentMethodFormValidityChangeEvent`, `CardBrand`, `PaymentMethodFormCardBrandChangeEvent`, `FormattedGooglePayPaymentData`, `WalletCustomerCreateAttributes`, `WalletPostalAddress`, `WalletContactRequirements`, `Message`, `Appearance`, `ThemeVariable`, `FontSource`, `CssFontSource`, `CustomFontSource`, `AppearanceRuleSelector`, `AppearanceRuleDeclarations`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
705
|
+
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmPaymentResult`, `ConfirmSetupResult`, `isConfirmTimeout`, `CONFIRM_TIMEOUT_MS`, `PaymentMethodFormValidityChangeEvent`, `CardBrand`, `PaymentMethodFormCardBrandChangeEvent`, `PaymentMethodFormPostalCodeChangeEvent`, `FormattedGooglePayPaymentData`, `WalletCustomerCreateAttributes`, `WalletPostalAddress`, `WalletContactRequirements`, `Message`, `Appearance`, `ThemeVariable`, `FontSource`, `CssFontSource`, `CustomFontSource`, `AppearanceRuleSelector`, `AppearanceRuleDeclarations`, `PaymentMethodFormDefaultValues`, `PaymentMethodFormField`, and the per-form `*Options` / `*Controller` types. For OpenAPI schema types (e.g. `PaymentIntent`, `CreatePaymentIntentInput`), import `components` from `@amos.com/node`.
|
|
706
706
|
|
|
707
707
|
## Notes and potential gotchas
|
|
708
708
|
|
|
@@ -711,7 +711,7 @@ Re-export from `@amos.com/amos-js`. Fills omitted Inter `fonts` / `--font-family
|
|
|
711
711
|
- **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`).
|
|
712
712
|
- **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`).
|
|
713
713
|
- **Embed host / CSP**: iframes load from `https://js.amos.com` (production) and `https://js-sandbox.amos.com` (sandbox) via `getEmbedOrigin`. Parent pages that pin CSP must allow `frame-src https://js.amos.com https://js-sandbox.amos.com` (and `Permissions-Policy payment=` for those origins) **before** upgrading this package. Older SDK versions still load `embed.amos.com` / `embed-sandbox.amos.com`.
|
|
714
|
-
- **Iframe handshake**: iframe URLs include canonical search params so the embed does not 307. If the document loads but never posts `IFRAME_READY`, the SDK rewrites `src` once with `amosReload`. Appearance is applied after handshake. The iframe stays
|
|
714
|
+
- **Iframe handshake**: iframe URLs include canonical search params so the embed does not 307. If the document loads but never posts `IFRAME_READY`, the SDK rewrites `src` once with `amosReload`. Appearance is applied after handshake. The iframe stays `opacity: 0` at its default pixel height until `UPDATED_APPEARANCE`, or for 1.5s after mount if appearance never acks. Embed messages match on origin plus `iframeName` when `contentWindow` identity changes.
|
|
715
715
|
- **Plaid Embedded Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe mints link tokens. Pass `requireAchVerification` when the host wants Plaid, or `intent="setup"` to always show it, unless the render token disables verification. Toggling that prop hides or shows the existing Embedded handler — it does not reload Institution Search. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method. While Link loads, the SDK shows a 350px pulse skeleton until `onLoad` (1.5s fallback) — do not overlay a host loader. After success the same slot is a connected-account row (institution name, mask, outline Disconnect) styled with existing `themeVariables`. Disconnect shows Institution Search again.
|
|
716
716
|
- **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.
|
|
717
717
|
- **Going framework-free**: if you need to use Amos outside of React (vanilla JS, another framework, etc.), use [`@amos.com/amos-js`](../amos-js) directly.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="googlepay" />
|
|
2
|
-
import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmPaymentResult, ConfirmSetupResult, CreditCardAdditionalFields, GooglePayButtonElementProps, PaymentMethodFormDefaultValues, PaymentMethodFormField, WalletCustomerCreateAttributes } from '@amos.com/amos-js';
|
|
2
|
+
import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmPaymentResult, ConfirmSetupResult, CreditCardAdditionalFields, GooglePayButtonElementProps, PaymentMethodFormDefaultValues, PaymentMethodFormField, PaymentMethodFormPostalCodeChangeEvent, WalletCustomerCreateAttributes } from '@amos.com/amos-js';
|
|
3
3
|
import { components } from '@amos.com/node';
|
|
4
4
|
import { ComponentProps, Ref, RefObject } from 'react';
|
|
5
5
|
export * from '@amos.com/amos-js';
|
|
@@ -67,10 +67,6 @@ 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;
|
|
74
70
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
75
71
|
renderToken: string;
|
|
76
72
|
appearance?: Appearance;
|
|
@@ -94,7 +90,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
94
90
|
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
95
91
|
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
96
92
|
*/
|
|
97
|
-
onPostalCodeChange?:
|
|
93
|
+
onPostalCodeChange?: (event: PaymentMethodFormPostalCodeChangeEvent) => void;
|
|
98
94
|
/**
|
|
99
95
|
* Called when the customer presses Escape in the iframe. PCI-safe —
|
|
100
96
|
* no field values. Use this to close a host modal that contains the
|
|
@@ -137,7 +133,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
137
133
|
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
138
134
|
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
139
135
|
*/
|
|
140
|
-
onPostalCodeChange?:
|
|
136
|
+
onPostalCodeChange?: (event: PaymentMethodFormPostalCodeChangeEvent) => void;
|
|
141
137
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
142
138
|
/**
|
|
143
139
|
* Seed account holder name and billing address. Provided keys
|
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 resolveIframe(e){var t;return e?(t=e.current)==null?null:t:null}function validateForm({iframeRef:t}){return(0,e.validateForm)({iframe:resolveIframe(t)})}function confirmPayment({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmPayment)({iframe:resolveIframe(t),token:n,defaultValues:r})}function confirmSetup({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmSetup)({iframe:resolveIframe(t),token:n,defaultValues:r})}function resetForm({iframeRef:t}){(0,e.resetForm)({iframe:resolveIframe(t)})}function focusField({iframeRef:t,field:n}){(0,e.focusField)({iframe:resolveIframe(t),field:n})}function setForwardedRef(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function applyIframePassthrough(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 useAmosEmbed({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,setForwardedRef(n,a.iframe),applyIframePassthrough(a.iframe,o),()=>{a.destroy(),c.current=null,setForwardedRef(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&&applyIframePassthrough(t,o)})}var r=`oklch(0.97 0 0)`;function WalletButtonSlot({height:i,borderRadius:a,containerRef:o}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:i,minHeight:i,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:i,borderRadius:a,background:r,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:o,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});let e=require("@amos.com/amos-js"),t=require("react"),n=require("react/jsx-runtime");function resolveIframe(e){var t;return e?(t=e.current)==null?null:t:null}function validateForm({iframeRef:t}){return(0,e.validateForm)({iframe:resolveIframe(t)})}function confirmPayment({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmPayment)({iframe:resolveIframe(t),token:n,defaultValues:r})}function confirmSetup({iframeRef:t,token:n,defaultValues:r}){return(0,e.confirmSetup)({iframe:resolveIframe(t),token:n,defaultValues:r})}function resetForm({iframeRef:t}){(0,e.resetForm)({iframe:resolveIframe(t)})}function focusField({iframeRef:t,field:n}){(0,e.focusField)({iframe:resolveIframe(t),field:n})}function setForwardedRef(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function applyIframePassthrough(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 useAmosEmbed({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,setForwardedRef(n,a.iframe),applyIframePassthrough(a.iframe,o),()=>{a.destroy(),c.current=null,setForwardedRef(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&&applyIframePassthrough(t,o)})}var r=`oklch(0.97 0 0)`;function WalletButtonSlot({height:i,borderRadius:a,containerRef:o}){return(0,t.useLayoutEffect)(()=>{(0,e.ensureSkeletonStyles)()},[]),(0,n.jsxs)(`div`,{style:{boxSizing:`border-box`,position:`relative`,width:`100%`,height:i,minHeight:i,overflow:`hidden`},children:[(0,n.jsx)(`div`,{className:`amos-js-form-skeleton-input amos-js-wallet-skeleton`,style:{position:`absolute`,inset:0,height:i,borderRadius:a,background:r,pointerEvents:`none`,zIndex:0},"aria-hidden":!0}),(0,n.jsx)(`div`,{ref:o,style:{position:`absolute`,inset:0,zIndex:1,width:`100%`,height:`100%`}})]})}function AmosCreditCardPaymentMethodForm({ref:r,renderToken:i,appearance:a,onValidityChange:o,onCardBrandChanged:s,onPostalCodeChange:c,onEscapeKeyPressed:l,additionalFields:u={cardholderName:!1},billingAddressRequirement:d=`country`,defaultValues:f,style:p,...m}){let h=(0,t.useRef)(null);return useAmosEmbed({containerRef:h,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,billingAddressRequirement:d,defaultValues:f,onValidityChange:o,onCardBrandChanged:s,onPostalCodeChange:c,onEscapeKeyPressed:l},remountDeps:[i,u.cardholderName,d],iframePassthrough:{style:p,...m},updateDeps:[a,u,d,f,o,s,c,l]}),(0,n.jsx)(`div`,{ref:h})}function AmosBankAccountPaymentMethodForm({ref:r,renderToken:i,appearance:a,onValidityChange:o,onPostalCodeChange:s,onEscapeKeyPressed:c,billingAddressRequirement:l=`country`,defaultValues:u,requireAchVerification:d=!1,intent:f=`payment`,style:p,...m}){let h=(0,t.useRef)(null);return useAmosEmbed({containerRef:h,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:l,defaultValues:u,requireAchVerification:d,intent:f,onValidityChange:o,onPostalCodeChange:s,onEscapeKeyPressed:c},remountDeps:[i,l,f],iframePassthrough:{style:p,...m},updateDeps:[a,l,u,d,f,o,s,c]}),(0,n.jsx)(`div`,{ref:h})}function AmosGooglePayButton({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:d,onConfirm:f}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:d==null?void 0:d.style,buttonProps:c});return useAmosEmbed({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:f},remountDeps:[i],iframePassthrough:d==null?{}:d,updateDeps:[a,o,s,c,l,u,f]}),(0,n.jsx)(WalletButtonSlot,{height:s,borderRadius:m,containerRef:p})}function AmosApplePayButton({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,iframeProps:d,onConfirm:f}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:d==null?void 0:d.style,buttonProps:c});return useAmosEmbed({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,phoneRequired:l,shippingAddressRequired:u,onConfirm:f},remountDeps:[i],iframePassthrough:d==null?{}:d,updateDeps:[a,o,s,c,l,u,f]}),(0,n.jsx)(WalletButtonSlot,{height:s,borderRadius:m,containerRef:p})}exports.AmosApplePayButton=AmosApplePayButton,exports.AmosBankAccountPaymentMethodForm=AmosBankAccountPaymentMethodForm,exports.AmosCreditCardPaymentMethodForm=AmosCreditCardPaymentMethodForm,exports.AmosGooglePayButton=AmosGooglePayButton,exports.confirmPayment=confirmPayment,exports.confirmSetup=confirmSetup,exports.focusField=focusField,exports.resetForm=resetForm,exports.validateForm=validateForm,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
|
@@ -96,87 +96,81 @@ function WalletButtonSlot({ height: e, borderRadius: t, containerRef: r }) {
|
|
|
96
96
|
})]
|
|
97
97
|
});
|
|
98
98
|
}
|
|
99
|
-
function
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
function mountBankAccountPaymentMethodForm(e, t) {
|
|
103
|
-
return a(e, t);
|
|
104
|
-
}
|
|
105
|
-
function AmosCreditCardPaymentMethodForm({ 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 }) {
|
|
106
|
-
let f = p(null);
|
|
99
|
+
function AmosCreditCardPaymentMethodForm({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardBrandChanged: i, onPostalCodeChange: a, onEscapeKeyPressed: s, additionalFields: c = { cardholderName: !1 }, billingAddressRequirement: l = "country", defaultValues: u, style: d, ...f }) {
|
|
100
|
+
let h = p(null);
|
|
107
101
|
return useAmosEmbed({
|
|
108
|
-
containerRef:
|
|
102
|
+
containerRef: h,
|
|
109
103
|
iframeRef: e,
|
|
110
|
-
mount:
|
|
104
|
+
mount: o,
|
|
111
105
|
options: {
|
|
112
106
|
renderToken: t,
|
|
113
107
|
appearance: n,
|
|
114
|
-
additionalFields:
|
|
115
|
-
billingAddressRequirement:
|
|
116
|
-
defaultValues:
|
|
108
|
+
additionalFields: c,
|
|
109
|
+
billingAddressRequirement: l,
|
|
110
|
+
defaultValues: u,
|
|
117
111
|
onValidityChange: r,
|
|
118
112
|
onCardBrandChanged: i,
|
|
119
113
|
onPostalCodeChange: a,
|
|
120
|
-
onEscapeKeyPressed:
|
|
114
|
+
onEscapeKeyPressed: s
|
|
121
115
|
},
|
|
122
116
|
remountDeps: [
|
|
123
117
|
t,
|
|
124
|
-
|
|
125
|
-
|
|
118
|
+
c.cardholderName,
|
|
119
|
+
l
|
|
126
120
|
],
|
|
127
121
|
iframePassthrough: {
|
|
128
|
-
style:
|
|
129
|
-
...
|
|
122
|
+
style: d,
|
|
123
|
+
...f
|
|
130
124
|
},
|
|
131
125
|
updateDeps: [
|
|
132
126
|
n,
|
|
133
|
-
s,
|
|
134
127
|
c,
|
|
135
128
|
l,
|
|
129
|
+
u,
|
|
136
130
|
r,
|
|
137
131
|
i,
|
|
138
132
|
a,
|
|
139
|
-
|
|
133
|
+
s
|
|
140
134
|
]
|
|
141
|
-
}), /* @__PURE__ */ m("div", { ref:
|
|
135
|
+
}), /* @__PURE__ */ m("div", { ref: h });
|
|
142
136
|
}
|
|
143
|
-
function AmosBankAccountPaymentMethodForm({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPostalCodeChange: i, onEscapeKeyPressed:
|
|
144
|
-
let
|
|
137
|
+
function AmosBankAccountPaymentMethodForm({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onPostalCodeChange: i, onEscapeKeyPressed: o, billingAddressRequirement: s = "country", defaultValues: c, requireAchVerification: l = !1, intent: u = "payment", style: d, ...f }) {
|
|
138
|
+
let h = p(null);
|
|
145
139
|
return useAmosEmbed({
|
|
146
|
-
containerRef:
|
|
140
|
+
containerRef: h,
|
|
147
141
|
iframeRef: e,
|
|
148
|
-
mount:
|
|
142
|
+
mount: a,
|
|
149
143
|
options: {
|
|
150
144
|
renderToken: t,
|
|
151
145
|
appearance: n,
|
|
152
|
-
billingAddressRequirement:
|
|
153
|
-
defaultValues:
|
|
154
|
-
requireAchVerification:
|
|
155
|
-
intent:
|
|
146
|
+
billingAddressRequirement: s,
|
|
147
|
+
defaultValues: c,
|
|
148
|
+
requireAchVerification: l,
|
|
149
|
+
intent: u,
|
|
156
150
|
onValidityChange: r,
|
|
157
151
|
onPostalCodeChange: i,
|
|
158
|
-
onEscapeKeyPressed:
|
|
152
|
+
onEscapeKeyPressed: o
|
|
159
153
|
},
|
|
160
154
|
remountDeps: [
|
|
161
155
|
t,
|
|
162
|
-
|
|
163
|
-
|
|
156
|
+
s,
|
|
157
|
+
u
|
|
164
158
|
],
|
|
165
159
|
iframePassthrough: {
|
|
166
|
-
style:
|
|
167
|
-
...
|
|
160
|
+
style: d,
|
|
161
|
+
...f
|
|
168
162
|
},
|
|
169
163
|
updateDeps: [
|
|
170
164
|
n,
|
|
171
|
-
o,
|
|
172
165
|
s,
|
|
173
166
|
c,
|
|
174
167
|
l,
|
|
168
|
+
u,
|
|
175
169
|
r,
|
|
176
170
|
i,
|
|
177
|
-
|
|
171
|
+
o
|
|
178
172
|
]
|
|
179
|
-
}), /* @__PURE__ */ m("div", { ref:
|
|
173
|
+
}), /* @__PURE__ */ m("div", { ref: h });
|
|
180
174
|
}
|
|
181
175
|
function AmosGooglePayButton({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: a, phoneRequired: o, shippingAddressRequired: c, iframeProps: u, onConfirm: d }) {
|
|
182
176
|
let f = p(null), h = l({
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.25",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
"vite-plugin-dts": "5.1.1"
|
|
58
58
|
},
|
|
59
59
|
"dependencies": {
|
|
60
|
-
"@amos.com/amos-js": "0.11.
|
|
60
|
+
"@amos.com/amos-js": "0.11.27",
|
|
61
61
|
"@types/googlepay": "0.7.13"
|
|
62
62
|
},
|
|
63
63
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -20,6 +20,7 @@ import {
|
|
|
20
20
|
mountAmosGooglePayButton,
|
|
21
21
|
type PaymentMethodFormDefaultValues,
|
|
22
22
|
type PaymentMethodFormField,
|
|
23
|
+
type PaymentMethodFormPostalCodeChangeEvent,
|
|
23
24
|
resolveWalletButtonSkeletonBorderRadius,
|
|
24
25
|
type WalletCustomerCreateAttributes,
|
|
25
26
|
} from "@amos.com/amos-js";
|
|
@@ -296,35 +297,6 @@ function WalletButtonSlot({
|
|
|
296
297
|
);
|
|
297
298
|
}
|
|
298
299
|
|
|
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
|
-
|
|
328
300
|
type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
329
301
|
renderToken: string;
|
|
330
302
|
appearance?: Appearance;
|
|
@@ -353,7 +325,7 @@ type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
353
325
|
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
354
326
|
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
355
327
|
*/
|
|
356
|
-
onPostalCodeChange?:
|
|
328
|
+
onPostalCodeChange?: (event: PaymentMethodFormPostalCodeChangeEvent) => void;
|
|
357
329
|
/**
|
|
358
330
|
* Called when the customer presses Escape in the iframe. PCI-safe —
|
|
359
331
|
* no field values. Use this to close a host modal that contains the
|
|
@@ -391,7 +363,7 @@ export function AmosCreditCardPaymentMethodForm({
|
|
|
391
363
|
useAmosEmbed({
|
|
392
364
|
containerRef,
|
|
393
365
|
iframeRef: ref as ForwardedIframeRef,
|
|
394
|
-
mount:
|
|
366
|
+
mount: mountAmosCreditCardPaymentMethodForm,
|
|
395
367
|
options: {
|
|
396
368
|
renderToken,
|
|
397
369
|
appearance,
|
|
@@ -446,7 +418,7 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
446
418
|
* one. `postalCode` is null when a finished code becomes incomplete.
|
|
447
419
|
* Incomplete keystrokes and `defaultValues` writes are omitted.
|
|
448
420
|
*/
|
|
449
|
-
onPostalCodeChange?:
|
|
421
|
+
onPostalCodeChange?: (event: PaymentMethodFormPostalCodeChangeEvent) => void;
|
|
450
422
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
451
423
|
/**
|
|
452
424
|
* Seed account holder name and billing address. Provided keys
|
|
@@ -496,7 +468,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
496
468
|
useAmosEmbed({
|
|
497
469
|
containerRef,
|
|
498
470
|
iframeRef: ref as ForwardedIframeRef,
|
|
499
|
-
mount:
|
|
471
|
+
mount: mountAmosBankAccountPaymentMethodForm,
|
|
500
472
|
options: {
|
|
501
473
|
renderToken,
|
|
502
474
|
appearance,
|