@amos.com/react-amos-js 0.9.13 → 0.9.14

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
@@ -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.37`). 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.
13
+ `@amos.com/node` is a **peer dependency** (requires `>=0.1.39`). 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
 
@@ -28,7 +28,7 @@ npm install @amos.com/react-amos-js @amos.com/node
28
28
  3. Amos account ID (provided once your application has been approved)
29
29
  ```
30
30
 
31
- The render token configures the iframe's allowed origin(s), allowed payment methods, and the range of valid payment amounts. If the render token does not allow an origin, the iframe will not render. Similarly, components corresponding to different payment method types will not render if not allowed by the render token.
31
+ The render token configures the iframe's allowed origin(s), allowed payment methods, accepted billing countries or US states, and the range of valid payment amounts. These settings come from the render template and are embedded in the token JWT (`RenderTokenJwt`); billing geography is controlled by `billing_address_options` (`allowed_countries` for international templates, `allowed_states` for US-only). If the render token does not allow an origin, the iframe will not render. Similarly, components corresponding to different payment method types will not render if not allowed by the render token, and billing addresses outside the configured countries or states will be rejected.
32
32
 
33
33
  > **Note**: The render token also determines the environment (`production` or `sandbox`). Render tokens created on `dashboard.amos.com` have a `production` environment. Render tokens created on `dashboard-sandbox.amos.com` have a `sandbox` environment. Similarly, API keys can only access the environment that they were created in.
34
34
 
@@ -62,7 +62,7 @@ Setup intents are used to save payment methods for future use (e.g. recurring pa
62
62
 
63
63
  - On the server, call `POST /setup_intents` instead of `POST /payment_intents`.
64
64
  - On the client, call `confirmSetupIntent({ iframeRef, token })` instead of `confirmPaymentIntent({ iframeRef, token })`.
65
- - The same `onResult` callback is used for setup intents (`intent: "setup"`).
65
+ - The same `onResult` callback is used; succeeded setup intents arrive as `{ status: "succeeded", intent: "setup", setupIntent }`.
66
66
 
67
67
  The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call.
68
68
 
@@ -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
- Every component accepts 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.
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`.
86
86
 
87
87
  ```tsx
88
88
  <AmosCreditCardPaymentMethodForm
@@ -107,57 +107,57 @@ Every component accepts an optional `appearance` prop that controls the look of
107
107
 
108
108
  Set `labels` to control how field labels are rendered in card and bank account forms:
109
109
 
110
- | Value | Behavior |
111
- | ----- | -------- |
112
- | `above` (default) | Label text above each input |
113
- | `floating` | Label inside the control; moves up when focused or filled |
114
- | `placeholder` | No visible label; placeholder and `aria-label` only |
110
+ | Value | Behavior |
111
+ | ----------------- | --------------------------------------------------------- |
112
+ | `above` (default) | Label text above each input |
113
+ | `floating` | Label inside the control; moves up when focused or filled |
114
+ | `placeholder` | No visible label; placeholder and `aria-label` only |
115
115
 
116
116
  Radio groups (e.g. account type) always use an above-style group label regardless of this setting.
117
117
 
118
118
  ### Available theme variables
119
119
 
120
- | Variable | Purpose | Default |
121
- | ------------------------ | ---------------------------------------------- | --------------------------- |
122
- | `--background` | Page body and base surface color | `oklch(1 0 0)` |
123
- | `--foreground` | Default text color | `oklch(0.145 0 0)` |
124
- | `--primary` | Button fill and input text-selection highlight | `oklch(0.205 0 0)` |
125
- | `--primary-foreground` | Text on primary-colored surfaces | `oklch(0.985 0 0)` |
126
- | `--secondary` | Secondary button fill | `oklch(0.97 0 0)` |
127
- | `--secondary-foreground` | Text on secondary-colored surfaces | `oklch(0.205 0 0)` |
128
- | `--muted` | Muted surface color | `oklch(0.97 0 0)` |
129
- | `--muted-foreground` | Placeholder text, helper labels, muted icons | `oklch(0.556 0 0)` |
130
- | `--accent` | Hover/focus highlight for interactive items | `oklch(0.97 0 0)` |
131
- | `--accent-foreground` | Text on accent-highlighted items | `oklch(0.205 0 0)` |
132
- | `--destructive` | Error/invalid state borders, icons, and field error text | `oklch(0.577 0.245 27.325)` |
133
- | `--destructive-foreground` | Text on destructive-colored surfaces | `oklch(0.45 0.24 27.325)` |
134
- | `--border` | General border color | `oklch(0.922 0 0)` |
135
- | `--popover` | Dropdown / popover panel background | `oklch(1 0 0)` |
136
- | `--popover-foreground` | Dropdown / popover panel text color | `oklch(0.145 0 0)` |
137
- | `--input` | Input field border color | `oklch(0.922 0 0)` |
138
- | `--input-background` | Input field background fill | `var(--background)` |
139
- | `--input-height` | Height of text inputs and form controls | `2.25rem` |
140
- | `--input-font-size` | Font size of text inputs and dropdown fields | `0.875rem` |
141
- | `--input-font-weight` | Font weight of typed input values | `400` |
142
- | `--input-padding` | Horizontal padding inside inputs | `0.75rem` |
143
- | `--input-border-width` | Input field border width | `1px` |
144
- | `--input-shadow` | Input field box shadow | `0 1px 2px 0 rgb(0 0 0 / 0.05)` |
145
- | `--floating-input-height` | Height of inputs when labels are floating | `3.25rem` |
146
- | `--floating-label-font-size` | Font size of floating labels when focused or filled | `0.75rem` |
147
- | `--floating-label-empty-font-size` | Font size of floating labels when empty (unfocused) | `var(--input-font-size)` |
148
- | `--floating-label-font-weight` | Font weight of floating labels | `500` |
149
- | `--floating-label-color` | Color of floating labels when empty (unfocused) | `var(--muted-foreground)` |
150
- | `--floating-label-floated-color` | Color of floating labels when focused or filled | `var(--floating-label-color)` |
151
- | `--floating-label-offset` | Top offset of the shrunk floating label | `0.625rem` |
152
- | `--label-font-size` | Font size of above-style field labels | `0.875rem` |
153
- | `--label-font-weight` | Font weight of above-style field labels | `500` |
154
- | `--field-gap` | Vertical gap between stacked form fields | `1rem` |
155
- | `--control-gap` | Horizontal gap between side-by-side controls | `0.5rem` |
156
- | `--error-font-size` | Font size of field-level error messages | `0.875rem` |
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)` |
159
- | `--ring-width` | Focus ring width | `3px` |
160
- | `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
120
+ | Variable | Purpose | Default |
121
+ | ---------------------------------- | -------------------------------------------------------- | ------------------------------- |
122
+ | `--background` | Page body and base surface color | `oklch(1 0 0)` |
123
+ | `--foreground` | Default text color | `oklch(0.145 0 0)` |
124
+ | `--primary` | Button fill and input text-selection highlight | `oklch(0.205 0 0)` |
125
+ | `--primary-foreground` | Text on primary-colored surfaces | `oklch(0.985 0 0)` |
126
+ | `--secondary` | Secondary button fill | `oklch(0.97 0 0)` |
127
+ | `--secondary-foreground` | Text on secondary-colored surfaces | `oklch(0.205 0 0)` |
128
+ | `--muted` | Muted surface color | `oklch(0.97 0 0)` |
129
+ | `--muted-foreground` | Placeholder text, helper labels, muted icons | `oklch(0.556 0 0)` |
130
+ | `--accent` | Hover/focus highlight for interactive items | `oklch(0.97 0 0)` |
131
+ | `--accent-foreground` | Text on accent-highlighted items | `oklch(0.205 0 0)` |
132
+ | `--destructive` | Error/invalid state borders, icons, and field error text | `oklch(0.577 0.245 27.325)` |
133
+ | `--destructive-foreground` | Text on destructive-colored surfaces | `oklch(0.45 0.24 27.325)` |
134
+ | `--border` | General border color | `oklch(0.922 0 0)` |
135
+ | `--popover` | Dropdown / popover panel background | `oklch(1 0 0)` |
136
+ | `--popover-foreground` | Dropdown / popover panel text color | `oklch(0.145 0 0)` |
137
+ | `--input` | Input field border color | `oklch(0.922 0 0)` |
138
+ | `--input-background` | Input field background fill | `var(--background)` |
139
+ | `--input-height` | Height of text inputs and form controls | `2.25rem` |
140
+ | `--input-font-size` | Font size of text inputs and dropdown fields | `0.875rem` |
141
+ | `--input-font-weight` | Font weight of typed input values | `400` |
142
+ | `--input-padding` | Horizontal padding inside inputs | `0.75rem` |
143
+ | `--input-border-width` | Input field border width | `1px` |
144
+ | `--input-shadow` | Input field box shadow | `0 1px 2px 0 rgb(0 0 0 / 0.05)` |
145
+ | `--floating-input-height` | Height of inputs when labels are floating | `3.25rem` |
146
+ | `--floating-label-font-size` | Font size of floating labels when focused or filled | `0.75rem` |
147
+ | `--floating-label-empty-font-size` | Font size of floating labels when empty (unfocused) | `var(--input-font-size)` |
148
+ | `--floating-label-font-weight` | Font weight of floating labels | `500` |
149
+ | `--floating-label-color` | Color of floating labels when empty (unfocused) | `var(--muted-foreground)` |
150
+ | `--floating-label-floated-color` | Color of floating labels when focused or filled | `var(--floating-label-color)` |
151
+ | `--floating-label-offset` | Top offset of the shrunk floating label | `0.625rem` |
152
+ | `--label-font-size` | Font size of above-style field labels | `0.875rem` |
153
+ | `--label-font-weight` | Font weight of above-style field labels | `500` |
154
+ | `--field-gap` | Vertical gap between stacked form fields | `1rem` |
155
+ | `--control-gap` | Horizontal gap between side-by-side controls | `0.5rem` |
156
+ | `--error-font-size` | Font size of field-level error messages | `0.875rem` |
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)` |
159
+ | `--ring-width` | Focus ring width | `3px` |
160
+ | `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
161
161
 
162
162
  ## Examples
163
163
 
@@ -192,10 +192,11 @@ function CheckoutForm() {
192
192
  return;
193
193
  }
194
194
 
195
- const paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"] = {
196
- amount: 5000, // $50.00 in cents
197
- capture_method: "automatic",
198
- };
195
+ const paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"] =
196
+ {
197
+ amount: 5000, // $50.00 in cents
198
+ capture_method: "automatic",
199
+ };
199
200
 
200
201
  const response = await fetch("/api/payment-intents", {
201
202
  method: "POST",
@@ -461,51 +462,36 @@ Renders the secure Google Pay iframe button (express checkout flow).
461
462
 
462
463
  **Optional props:**
463
464
 
464
- - `appearance` (`{ themeVariables?: Partial<Record<ThemeVariable, string>>; labels?: "above" | "floating" | "placeholder" }`)
465
- - `fullWidth` (`boolean`, defaults to `false`) fills the component's mount container
466
- - `buttonType` (`"book" | "buy" | "checkout" | "donate" | "order" | "pay" | "plain" | "subscribe" | "short" | "long"`, defaults to `"short"`)
467
- - `buttonColor` (`"default" | "black" | "white"`)
468
- - `buttonRadius` (`number`, 0–20)
469
- - `buttonSizeMode` (`"static" | "fill"`)
470
- - `buttonLocale` (`string`)
471
- - `buttonBorderType` (`"no_border" | "default_border"`)
472
- - `buttonStyle` — styles the Google Pay button **inside** the iframe, for example `buttonStyle={{ height: "48px" }}`
473
- - `iframeStyle` — styles the host-page `<iframe>` element
474
- - `style` — backward-compatible alias for `buttonStyle`; prefer the explicit name in new integrations
465
+ - `height` (`string`, defaults to `"48px"`) painted button height. CSS length (e.g. `"48px"`).
466
+ - `buttonProps` native Google Pay button options. Omitted fields keep `"plain"` / `"fill"`. The button fills the iframe; size the mount slot, not the button. Compact: `buttonProps={{ buttonSizeMode: "static", style: { width: "240px" } }}`.
467
+ - `iframeProps` — applied to the host-page `<iframe>` (e.g. `className`, `style`, `id`). Use CSS lengths with units in `style` (`{ borderRadius: "8px" }`). Amos does not ship Tailwind `className` only works if the host page defines those classes.
475
468
 
476
469
  ```tsx
477
470
  <AmosGooglePayButton
478
- fullWidth
479
- buttonStyle={{ height: "48px" }}
480
- iframeStyle={{ borderRadius: "6px" }}
471
+ buttonProps={{ buttonType: "donate", buttonBorderType: "no_border" }}
472
+ iframeProps={{ style: { borderRadius: "8px" } }}
481
473
  // ...required props
482
474
  />
483
475
  ```
484
476
 
485
- **Also accepts:** standard iframe props, minus `src`, `title`, `name`, `role`, `allow`, and `style`.
486
-
487
477
  ### `AmosApplePayButton`
488
478
 
489
479
  Renders the secure Apple Pay iframe button (express checkout flow). Same required props and callbacks as `AmosGooglePayButton`.
490
480
 
491
- **Optional visual props** use Apple's `<apple-pay-button>` attribute names:
481
+ **Optional visual props:**
492
482
 
493
- - `fullWidth` (`boolean`, defaults to `false`) — fills the component's mount container
494
- - `buttonstyle` (`"black" | "white" | "white-outline"`, defaults to `"black"`)
495
- - `type` (`"plain" | "buy" | "set-up" | "donate" | "check-out" | "book" | "subscribe" | "reload" | "add-money" | "top-up" | "order" | "rent" | "support" | "contribute" | "tip"`, defaults to `"plain"`)
496
- - `locale` (`string`, BCP 47, defaults to `"en-US"`)
497
- - `buttonStyle` — forwarded to the `<apple-pay-button>` inside the iframe. Apple maps a CSS `height` onto its required custom property.
498
- - `iframeStyle` — styles the host-page `<iframe>` element
499
- - `style` — backward-compatible alias for `buttonStyle`
483
+ - `height` (`string`, defaults to `"48px"`) — painted button height. CSS length (e.g. `"48px"`). Apple ignores CSS `height`; Amos maps this for you.
484
+ - `buttonProps` — native `<apple-pay-button>` attributes. Omitted fields keep Apple's `black` / `plain` / `en-US`. The button fills the iframe; size the mount slot, not the button. `style.width` also updates `--apple-pay-button-width` unless you set that custom property yourself.
485
+ - `iframeProps` host-page `<iframe>` chrome (same as Google Pay).
500
486
 
501
487
  ```tsx
502
488
  <AmosApplePayButton
503
- fullWidth
504
- buttonstyle="white-outline"
505
- type="buy"
506
- locale="en-GB"
507
- buttonStyle={{ height: "48px" }}
508
- iframeStyle={{ borderRadius: "6px" }}
489
+ buttonProps={{
490
+ buttonstyle: "white-outline",
491
+ type: "buy",
492
+ locale: "en-GB",
493
+ }}
494
+ iframeProps={{ style: { borderRadius: "8px" } }}
509
495
  // ...required props
510
496
  />
511
497
  ```
package/dist/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  /// <reference types="googlepay" />
2
- import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmationResult, CreditCardAdditionalFields, GooglePayButtonElementProps, WalletButtonStyle } from '@amos.com/amos-js';
2
+ import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmationResult, CreditCardAdditionalFields, GooglePayButtonElementProps } from '@amos.com/amos-js';
3
3
  import { components } from '@amos.com/node';
4
- import { ComponentProps, RefObject } from 'react';
4
+ import { ComponentProps, Ref, RefObject } from 'react';
5
5
  export * from '@amos.com/amos-js';
6
6
  type IframeRef = RefObject<HTMLIFrameElement | null> | undefined;
7
7
  /**
@@ -40,25 +40,8 @@ export declare function confirmSetupIntent({ iframeRef, token, }: {
40
40
  export declare function resetForm({ iframeRef }: {
41
41
  iframeRef: IframeRef;
42
42
  }): void;
43
+ type ForwardedIframeRef = Ref<HTMLIFrameElement> | undefined;
43
44
  type IframePassthroughProps = Omit<ComponentProps<"iframe">, "src" | "title" | "name" | "role" | "allow">;
44
- type WalletStyleProps = {
45
- /**
46
- * Stretch the wallet button to fill the iframe width.
47
- *
48
- * @default false
49
- */
50
- fullWidth?: boolean;
51
- /** Styles applied to the wallet button inside the Amos iframe. */
52
- buttonStyle?: WalletButtonStyle;
53
- /** Styles applied to the host-page `<iframe>` element. */
54
- iframeStyle?: ComponentProps<"iframe">["style"];
55
- /**
56
- * Styles applied to the wallet button inside the Amos iframe.
57
- *
58
- * @deprecated Use `buttonStyle` to distinguish it from `iframeStyle`.
59
- */
60
- style?: WalletButtonStyle;
61
- };
62
45
  type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
63
46
  renderToken: string;
64
47
  appearance?: Appearance;
@@ -88,27 +71,55 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
88
71
  billingAddressRequirement?: BillingAddressRequirement;
89
72
  };
90
73
  export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onResult, onValidityChange, billingAddressRequirement, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
91
- type AmosGooglePayButtonProps = Omit<IframePassthroughProps, "style"> & Omit<GooglePayButtonElementProps, "style"> & WalletStyleProps & {
74
+ type AmosGooglePayButtonProps = {
75
+ ref?: ForwardedIframeRef;
92
76
  renderToken: string;
93
77
  amount: string;
94
78
  merchantName: string;
95
- appearance?: Appearance;
79
+ /**
80
+ * Painted button height. CSS length (e.g. `"48px"`).
81
+ * @default "48px"
82
+ */
83
+ height?: string;
84
+ /**
85
+ * Native Google Pay button attributes and inner style. Omitted
86
+ * fields keep Amos paint defaults (`buttonType: "plain"`,
87
+ * `buttonSizeMode: "fill"`). The button fills the iframe — size the
88
+ * mount slot, not the button.
89
+ */
90
+ buttonProps?: GooglePayButtonElementProps;
91
+ /** Props applied to the host-page `<iframe>` element. */
92
+ iframeProps?: IframePassthroughProps;
96
93
  onInitiatePaymentIntentRequest: ({ paymentIntentCreateAttributes, customerCreateAttributes, }: {
97
94
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
98
95
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
99
96
  }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
100
97
  onResult: (result: ConfirmationResult) => void;
101
98
  };
102
- export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, buttonType, buttonColor, buttonRadius, buttonSizeMode, buttonLocale, buttonBorderType, fullWidth, buttonStyle, iframeStyle, style, ...rest }: AmosGooglePayButtonProps): import("react").JSX.Element;
103
- type AmosApplePayButtonProps = Omit<IframePassthroughProps, "style" | "type"> & Omit<ApplePayButtonElementProps, "style"> & WalletStyleProps & {
99
+ export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, iframeProps, onInitiatePaymentIntentRequest, onResult, }: AmosGooglePayButtonProps): import("react").JSX.Element;
100
+ type AmosApplePayButtonProps = {
101
+ ref?: ForwardedIframeRef;
104
102
  renderToken: string;
105
103
  amount: string;
106
104
  merchantName: string;
107
- appearance?: Appearance;
105
+ /**
106
+ * Painted button height. CSS length (e.g. `"48px"`). Apple ignores
107
+ * CSS `height`; Amos maps this for you.
108
+ * @default "48px"
109
+ */
110
+ height?: string;
111
+ /**
112
+ * Native `<apple-pay-button>` attributes and inner style. Omitted
113
+ * fields keep Apple's defaults (`black` / `plain` / `en-US`). The
114
+ * button fills the iframe — size the mount slot, not the button.
115
+ */
116
+ buttonProps?: ApplePayButtonElementProps;
117
+ /** Props applied to the host-page `<iframe>` element. */
118
+ iframeProps?: IframePassthroughProps;
108
119
  onInitiatePaymentIntentRequest: ({ paymentIntentCreateAttributes, customerCreateAttributes, }: {
109
120
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
110
121
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
111
122
  }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
112
123
  onResult: (result: ConfirmationResult) => void;
113
124
  };
114
- export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onResult, buttonstyle, type, locale, fullWidth, buttonStyle, iframeStyle, style, ...rest }: AmosApplePayButtonProps): import("react").JSX.Element;
125
+ export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, height, buttonProps, iframeProps, onInitiatePaymentIntentRequest, onResult, }: AmosApplePayButtonProps): import("react").JSX.Element;
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({buttonSizeMode:e,style:t,fullWidth:n}){return{buttonSizeMode:e??(n?`fill`:void 0),style:n?{width:`100%`,...t}:t}}function u({style:e,fullWidth:t}){return t?{style:{"--apple-pay-button-width":`100%`,width:`100%`,...e}}:{style:e}}function d(e,{style:t,className:n,id:r,...i}){n!=null&&(e.className=n),r!=null&&(e.id=r),t!=null&&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 f({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:s}){let l=(0,t.useRef)(null);(0,t.useEffect)(()=>{let t=e.current;if(!t)return;let a=r(t,i);return l.current=a,c(n,a.iframe),d(a.iframe,o),()=>{a.destroy(),l.current=null,c(n,null)}},[...a]),(0,t.useEffect)(()=>{l.current?.update(i)},[...s]),(0,t.useEffect)(()=>{let e=l.current?.iframe;e&&d(e,o)})}function p({ref:r,renderToken:i,appearance:a,onResult:o,onValidityChange:s,additionalFields:c={cardholderName:!1},billingAddressRequirement:l=`country`,style:u,...d}){let p=(0,t.useRef)(null);return f({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:u,...d},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,...u}){let d=(0,t.useRef)(null);return f({containerRef:d,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:c,onResult:o,onValidityChange:s},remountDeps:[i,c],iframePassthrough:{style:l,...u},updateDeps:[a,c,o,s]}),(0,n.jsx)(`div`,{ref:d})}function h({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,buttonType:d,buttonColor:p,buttonRadius:m,buttonSizeMode:h,buttonLocale:g,buttonBorderType:_,fullWidth:v=!1,buttonStyle:y,iframeStyle:b,style:x,...S}){let C=(0,t.useRef)(null),w=l({buttonSizeMode:h,style:y??x,fullWidth:v});return f({containerRef:C,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,buttonType:d,buttonColor:p,buttonRadius:m,buttonSizeMode:w.buttonSizeMode,buttonLocale:g,buttonBorderType:_,style:w.style},remountDeps:[i],iframePassthrough:{style:b,...S},updateDeps:[a,o,s,c,u,d,p,m,w.buttonSizeMode,g,_,w.style]}),(0,n.jsx)(`div`,{ref:C})}function g({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonstyle:d,type:p,locale:m,fullWidth:h=!1,buttonStyle:g,iframeStyle:_,style:v,...y}){let b=(0,t.useRef)(null),x=u({style:g??v,fullWidth:h});return f({containerRef:b,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,buttonstyle:d,type:p,locale:m,style:x.style},remountDeps:[i],iframePassthrough:{style:_,...y},updateDeps:[a,o,s,c,l,d,p,m,x.style]}),(0,n.jsx)(`div`,{ref:b})}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.useEffect)(()=>{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)})}function d({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 f({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 p({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:f},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,f]}),(0,n.jsx)(`div`,{ref:p})}function m({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onInitiatePaymentIntentRequest:d,onResult:f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onInitiatePaymentIntentRequest:d,onResult:f},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d,f]}),(0,n.jsx)(`div`,{ref:p})}exports.AmosApplePayButton=m,exports.AmosBankAccountPaymentMethodForm=f,exports.AmosCreditCardPaymentMethodForm=d,exports.AmosGooglePayButton=p,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
@@ -27,45 +27,29 @@ function h({ iframeRef: e }) {
27
27
  function g(e, t) {
28
28
  typeof e == "function" ? e(t) : e && (e.current = t);
29
29
  }
30
- function _({ buttonSizeMode: e, style: t, fullWidth: n }) {
31
- return {
32
- buttonSizeMode: e ?? (n ? "fill" : void 0),
33
- style: n ? {
34
- width: "100%",
35
- ...t
36
- } : t
37
- };
38
- }
39
- function v({ style: e, fullWidth: t }) {
40
- return t ? { style: {
41
- "--apple-pay-button-width": "100%",
42
- width: "100%",
43
- ...e
44
- } } : { style: e };
45
- }
46
- function y(e, { style: t, className: n, id: r, ...i }) {
47
- n != null && (e.className = n), r != null && (e.id = r), t != null && Object.assign(e.style, t);
30
+ function _(e, { style: t, className: n, id: r, ...i }) {
31
+ n != null && (e.className = n), r != null && (e.id = r), Object.assign(e.style, t);
48
32
  for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
49
33
  }
50
- function b({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
34
+ function v({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
51
35
  let s = l(null);
52
36
  c(() => {
53
37
  let i = e.current;
54
38
  if (!i) return;
55
39
  let o = n(i, r);
56
- return s.current = o, g(t, o.iframe), y(o.iframe, a), () => {
40
+ return s.current = o, g(t, o.iframe), _(o.iframe, a), () => {
57
41
  o.destroy(), s.current = null, g(t, null);
58
42
  };
59
43
  }, [...i]), c(() => {
60
44
  s.current?.update(r);
61
45
  }, [...o]), c(() => {
62
46
  let e = s.current?.iframe;
63
- e && y(e, a);
47
+ e && _(e, a);
64
48
  });
65
49
  }
66
- function x({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, additionalFields: o = { cardholderName: !1 }, billingAddressRequirement: s = "country", style: c, ...d }) {
50
+ function y({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChange: a, additionalFields: o = { cardholderName: !1 }, billingAddressRequirement: s = "country", style: c, ...d }) {
67
51
  let f = l(null);
68
- return b({
52
+ return v({
69
53
  containerRef: f,
70
54
  iframeRef: e,
71
55
  mount: i,
@@ -95,9 +79,9 @@ function x({ ref: e, renderToken: t, appearance: n, onResult: r, onValidityChang
95
79
  ]
96
80
  }), /* @__PURE__ */ u("div", { ref: f });
97
81
  }
98
- function S({ ref: e, renderToken: t, appearance: n, onResult: i, onValidityChange: a, billingAddressRequirement: o = "country", style: s, ...c }) {
82
+ function b({ ref: e, renderToken: t, appearance: n, onResult: i, onValidityChange: a, billingAddressRequirement: o = "country", style: s, ...c }) {
99
83
  let d = l(null);
100
- return b({
84
+ return v({
101
85
  containerRef: d,
102
86
  iframeRef: e,
103
87
  mount: r,
@@ -121,90 +105,59 @@ function S({ ref: e, renderToken: t, appearance: n, onResult: i, onValidityChang
121
105
  ]
122
106
  }), /* @__PURE__ */ u("div", { ref: d });
123
107
  }
124
- function C({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s, buttonType: c, buttonColor: d, buttonRadius: f, buttonSizeMode: p, buttonLocale: m, buttonBorderType: h, fullWidth: g = !1, buttonStyle: v, iframeStyle: y, style: x, ...S }) {
125
- let C = l(null), w = _({
126
- buttonSizeMode: p,
127
- style: v ?? x,
128
- fullWidth: g
129
- });
130
- return b({
131
- containerRef: C,
108
+ function x({ ref: e, renderToken: t, amount: n, merchantName: r, height: i = "48px", buttonProps: o, iframeProps: s, onInitiatePaymentIntentRequest: c, onResult: d }) {
109
+ let f = l(null);
110
+ return v({
111
+ containerRef: f,
132
112
  iframeRef: e,
133
113
  mount: a,
134
114
  options: {
135
115
  renderToken: t,
136
116
  amount: n,
137
117
  merchantName: r,
138
- appearance: i,
139
- onInitiatePaymentIntentRequest: o,
140
- onResult: s,
141
- buttonType: c,
142
- buttonColor: d,
143
- buttonRadius: f,
144
- buttonSizeMode: w.buttonSizeMode,
145
- buttonLocale: m,
146
- buttonBorderType: h,
147
- style: w.style
118
+ height: i,
119
+ buttonProps: o,
120
+ onInitiatePaymentIntentRequest: c,
121
+ onResult: d
148
122
  },
149
123
  remountDeps: [t],
150
- iframePassthrough: {
151
- style: y,
152
- ...S
153
- },
124
+ iframePassthrough: s ?? {},
154
125
  updateDeps: [
155
126
  n,
156
127
  r,
157
128
  i,
158
129
  o,
159
- s,
160
130
  c,
161
- d,
162
- f,
163
- w.buttonSizeMode,
164
- m,
165
- h,
166
- w.style
131
+ d
167
132
  ]
168
- }), /* @__PURE__ */ u("div", { ref: C });
133
+ }), /* @__PURE__ */ u("div", { ref: f });
169
134
  }
170
- function w({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s, buttonstyle: c, type: d, locale: f, fullWidth: p = !1, buttonStyle: m, iframeStyle: h, style: g, ..._ }) {
171
- let y = l(null), x = v({
172
- style: m ?? g,
173
- fullWidth: p
174
- });
175
- return b({
176
- containerRef: y,
135
+ function S({ ref: e, renderToken: t, amount: r, merchantName: i, height: a = "48px", buttonProps: o, iframeProps: s, onInitiatePaymentIntentRequest: c, onResult: d }) {
136
+ let f = l(null);
137
+ return v({
138
+ containerRef: f,
177
139
  iframeRef: e,
178
140
  mount: n,
179
141
  options: {
180
142
  renderToken: t,
181
143
  amount: r,
182
144
  merchantName: i,
183
- appearance: a,
184
- onInitiatePaymentIntentRequest: o,
185
- onResult: s,
186
- buttonstyle: c,
187
- type: d,
188
- locale: f,
189
- style: x.style
145
+ height: a,
146
+ buttonProps: o,
147
+ onInitiatePaymentIntentRequest: c,
148
+ onResult: d
190
149
  },
191
150
  remountDeps: [t],
192
- iframePassthrough: {
193
- style: h,
194
- ..._
195
- },
151
+ iframePassthrough: s ?? {},
196
152
  updateDeps: [
197
153
  r,
198
154
  i,
199
155
  a,
200
156
  o,
201
- s,
202
157
  c,
203
- d,
204
- f,
205
- x.style
158
+ d
206
159
  ]
207
- }), /* @__PURE__ */ u("div", { ref: y });
160
+ }), /* @__PURE__ */ u("div", { ref: f });
208
161
  }
209
162
  //#endregion
210
- export { w as AmosApplePayButton, S as AmosBankAccountPaymentMethodForm, x as AmosCreditCardPaymentMethodForm, C as AmosGooglePayButton, p as confirmPaymentIntent, m as confirmSetupIntent, h as resetForm, f as validateForm };
163
+ export { S as AmosApplePayButton, b as AmosBankAccountPaymentMethodForm, y as AmosCreditCardPaymentMethodForm, x as AmosGooglePayButton, p as confirmPaymentIntent, m as confirmSetupIntent, h as resetForm, f as validateForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.9.13",
3
+ "version": "0.9.14",
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.14",
51
+ "@amos.com/amos-js": "0.9.15",
52
52
  "@types/googlepay": "0.7.11"
53
53
  },
54
54
  "peerDependencies": {
package/src/index.tsx CHANGED
@@ -15,7 +15,6 @@ import {
15
15
  mountAmosBankAccountPaymentMethodForm,
16
16
  mountAmosCreditCardPaymentMethodForm,
17
17
  mountAmosGooglePayButton,
18
- type WalletButtonStyle,
19
18
  } from "@amos.com/amos-js";
20
19
  import type { components } from "@amos.com/node";
21
20
  import {
@@ -109,59 +108,6 @@ type IframePassthroughProps = Omit<
109
108
  "src" | "title" | "name" | "role" | "allow"
110
109
  >;
111
110
 
112
- type WalletStyleProps = {
113
- /**
114
- * Stretch the wallet button to fill the iframe width.
115
- *
116
- * @default false
117
- */
118
- fullWidth?: boolean;
119
- /** Styles applied to the wallet button inside the Amos iframe. */
120
- buttonStyle?: WalletButtonStyle;
121
- /** Styles applied to the host-page `<iframe>` element. */
122
- iframeStyle?: ComponentProps<"iframe">["style"];
123
- /**
124
- * Styles applied to the wallet button inside the Amos iframe.
125
- *
126
- * @deprecated Use `buttonStyle` to distinguish it from `iframeStyle`.
127
- */
128
- style?: WalletButtonStyle;
129
- };
130
-
131
- function resolveGooglePayButtonLayout({
132
- buttonSizeMode,
133
- style,
134
- fullWidth,
135
- }: {
136
- buttonSizeMode?: GooglePayButtonElementProps["buttonSizeMode"];
137
- style?: WalletButtonStyle;
138
- fullWidth: boolean;
139
- }): Pick<GooglePayButtonElementProps, "buttonSizeMode" | "style"> {
140
- return {
141
- buttonSizeMode: buttonSizeMode ?? (fullWidth ? "fill" : undefined),
142
- style: fullWidth ? { width: "100%", ...style } : style,
143
- };
144
- }
145
-
146
- function resolveApplePayButtonLayout({
147
- style,
148
- fullWidth,
149
- }: {
150
- style?: WalletButtonStyle;
151
- fullWidth: boolean;
152
- }): Pick<ApplePayButtonElementProps, "style"> {
153
- if (!fullWidth) {
154
- return { style };
155
- }
156
- return {
157
- style: {
158
- "--apple-pay-button-width": "100%",
159
- width: "100%",
160
- ...style,
161
- },
162
- };
163
- }
164
-
165
111
  function applyIframePassthrough(
166
112
  iframe: HTMLIFrameElement,
167
113
  { style, className, id, ...rest }: IframePassthroughProps,
@@ -172,9 +118,7 @@ function applyIframePassthrough(
172
118
  if (id != null) {
173
119
  iframe.id = id;
174
120
  }
175
- if (style != null) {
176
- Object.assign(iframe.style, style);
177
- }
121
+ Object.assign(iframe.style, style);
178
122
  for (const [key, value] of Object.entries(rest)) {
179
123
  if (value == null) {
180
124
  continue;
@@ -348,50 +292,47 @@ export function AmosBankAccountPaymentMethodForm({
348
292
  return <div ref={containerRef} />;
349
293
  }
350
294
 
351
- type AmosGooglePayButtonProps = Omit<IframePassthroughProps, "style"> &
352
- Omit<GooglePayButtonElementProps, "style"> &
353
- WalletStyleProps & {
354
- renderToken: string;
355
- amount: string;
356
- merchantName: string;
357
- appearance?: Appearance;
358
- onInitiatePaymentIntentRequest: ({
359
- paymentIntentCreateAttributes,
360
- customerCreateAttributes,
361
- }: {
362
- paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
363
- customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
364
- }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
365
- onResult: (result: ConfirmationResult) => void;
366
- };
295
+ type AmosGooglePayButtonProps = {
296
+ ref?: ForwardedIframeRef;
297
+ renderToken: string;
298
+ amount: string;
299
+ merchantName: string;
300
+ /**
301
+ * Painted button height. CSS length (e.g. `"48px"`).
302
+ * @default "48px"
303
+ */
304
+ height?: string;
305
+ /**
306
+ * Native Google Pay button attributes and inner style. Omitted
307
+ * fields keep Amos paint defaults (`buttonType: "plain"`,
308
+ * `buttonSizeMode: "fill"`). The button fills the iframe — size the
309
+ * mount slot, not the button.
310
+ */
311
+ buttonProps?: GooglePayButtonElementProps;
312
+ /** Props applied to the host-page `<iframe>` element. */
313
+ iframeProps?: IframePassthroughProps;
314
+ onInitiatePaymentIntentRequest: ({
315
+ paymentIntentCreateAttributes,
316
+ customerCreateAttributes,
317
+ }: {
318
+ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
319
+ customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
320
+ }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
321
+ onResult: (result: ConfirmationResult) => void;
322
+ };
367
323
 
368
324
  export function AmosGooglePayButton({
369
325
  ref,
370
326
  renderToken,
371
327
  amount,
372
328
  merchantName,
373
- appearance,
329
+ height = "48px",
330
+ buttonProps,
331
+ iframeProps,
374
332
  onInitiatePaymentIntentRequest,
375
333
  onResult,
376
- buttonType,
377
- buttonColor,
378
- buttonRadius,
379
- buttonSizeMode,
380
- buttonLocale,
381
- buttonBorderType,
382
- fullWidth = false,
383
- buttonStyle,
384
- iframeStyle,
385
- style,
386
- ...rest
387
334
  }: AmosGooglePayButtonProps) {
388
335
  const containerRef = useRef<HTMLDivElement | null>(null);
389
- const resolvedStyle = buttonStyle ?? style;
390
- const layout = resolveGooglePayButtonLayout({
391
- buttonSizeMode,
392
- style: resolvedStyle,
393
- fullWidth,
394
- });
395
336
 
396
337
  useAmosEmbed({
397
338
  containerRef,
@@ -401,78 +342,67 @@ export function AmosGooglePayButton({
401
342
  renderToken,
402
343
  amount,
403
344
  merchantName,
404
- appearance,
345
+ height,
346
+ buttonProps,
405
347
  onInitiatePaymentIntentRequest,
406
348
  onResult,
407
- buttonType,
408
- buttonColor,
409
- buttonRadius,
410
- buttonSizeMode: layout.buttonSizeMode,
411
- buttonLocale,
412
- buttonBorderType,
413
- style: layout.style,
414
349
  },
415
350
  remountDeps: [renderToken],
416
- iframePassthrough: { style: iframeStyle, ...rest },
351
+ iframePassthrough: iframeProps ?? {},
417
352
  updateDeps: [
418
353
  amount,
419
354
  merchantName,
420
- appearance,
355
+ height,
356
+ buttonProps,
421
357
  onInitiatePaymentIntentRequest,
422
358
  onResult,
423
- buttonType,
424
- buttonColor,
425
- buttonRadius,
426
- layout.buttonSizeMode,
427
- buttonLocale,
428
- buttonBorderType,
429
- layout.style,
430
359
  ],
431
360
  });
432
361
 
433
362
  return <div ref={containerRef} />;
434
363
  }
435
364
 
436
- type AmosApplePayButtonProps = Omit<IframePassthroughProps, "style" | "type"> &
437
- Omit<ApplePayButtonElementProps, "style"> &
438
- WalletStyleProps & {
439
- renderToken: string;
440
- amount: string;
441
- merchantName: string;
442
- appearance?: Appearance;
443
- onInitiatePaymentIntentRequest: ({
444
- paymentIntentCreateAttributes,
445
- customerCreateAttributes,
446
- }: {
447
- paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
448
- customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
449
- }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
450
- onResult: (result: ConfirmationResult) => void;
451
- };
365
+ type AmosApplePayButtonProps = {
366
+ ref?: ForwardedIframeRef;
367
+ renderToken: string;
368
+ amount: string;
369
+ merchantName: string;
370
+ /**
371
+ * Painted button height. CSS length (e.g. `"48px"`). Apple ignores
372
+ * CSS `height`; Amos maps this for you.
373
+ * @default "48px"
374
+ */
375
+ height?: string;
376
+ /**
377
+ * Native `<apple-pay-button>` attributes and inner style. Omitted
378
+ * fields keep Apple's defaults (`black` / `plain` / `en-US`). The
379
+ * button fills the iframe — size the mount slot, not the button.
380
+ */
381
+ buttonProps?: ApplePayButtonElementProps;
382
+ /** Props applied to the host-page `<iframe>` element. */
383
+ iframeProps?: IframePassthroughProps;
384
+ onInitiatePaymentIntentRequest: ({
385
+ paymentIntentCreateAttributes,
386
+ customerCreateAttributes,
387
+ }: {
388
+ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
389
+ customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
390
+ }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
391
+ onResult: (result: ConfirmationResult) => void;
392
+ };
452
393
 
453
394
  export function AmosApplePayButton({
454
395
  ref,
455
396
  renderToken,
456
397
  amount,
457
398
  merchantName,
458
- appearance,
399
+ height = "48px",
400
+ buttonProps,
401
+ iframeProps,
459
402
  onInitiatePaymentIntentRequest,
460
403
  onResult,
461
- buttonstyle,
462
- type,
463
- locale,
464
- fullWidth = false,
465
- buttonStyle,
466
- iframeStyle,
467
- style,
468
- ...rest
469
404
  }: AmosApplePayButtonProps) {
470
405
  const containerRef = useRef<HTMLDivElement | null>(null);
471
- const resolvedStyle = buttonStyle ?? style;
472
- const layout = resolveApplePayButtonLayout({
473
- style: resolvedStyle,
474
- fullWidth,
475
- });
476
406
 
477
407
  useAmosEmbed({
478
408
  containerRef,
@@ -482,26 +412,20 @@ export function AmosApplePayButton({
482
412
  renderToken,
483
413
  amount,
484
414
  merchantName,
485
- appearance,
415
+ height,
416
+ buttonProps,
486
417
  onInitiatePaymentIntentRequest,
487
418
  onResult,
488
- buttonstyle,
489
- type,
490
- locale,
491
- style: layout.style,
492
419
  },
493
420
  remountDeps: [renderToken],
494
- iframePassthrough: { style: iframeStyle, ...rest },
421
+ iframePassthrough: iframeProps ?? {},
495
422
  updateDeps: [
496
423
  amount,
497
424
  merchantName,
498
- appearance,
425
+ height,
426
+ buttonProps,
499
427
  onInitiatePaymentIntentRequest,
500
428
  onResult,
501
- buttonstyle,
502
- type,
503
- locale,
504
- layout.style,
505
429
  ],
506
430
  });
507
431