@amos.com/react-amos-js 0.11.2 → 0.11.4
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 +24 -26
- package/dist/index.d.ts +18 -23
- package/dist/index.js +1 -1
- package/dist/index.mjs +2 -2
- package/package.json +2 -2
- package/src/index.tsx +21 -25
package/README.md
CHANGED
|
@@ -16,7 +16,7 @@ npm install @amos.com/react-amos-js @amos.com/node
|
|
|
16
16
|
|
|
17
17
|
- React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`, `AmosApplePayButton`.
|
|
18
18
|
- React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPayment({ iframeRef, token })`, `confirmSetup({ iframeRef, token })`, `resetForm({ iframeRef })`.
|
|
19
|
-
- Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `resetForm`, `
|
|
19
|
+
- Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `resetForm`, `ConfirmPaymentResult`, `ConfirmSetupResult`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
|
|
20
20
|
|
|
21
21
|
> **Note:** `@amos.com/react-amos-js` is the client-side half of the Amos integration. For end-to-end payment processing you also need `@amos.com/node` on your server (creating payment intents, handling webhooks, etc.). The same `@amos.com/node` package is listed as a peer dependency so you can import its OpenAPI types in client-side TypeScript code.
|
|
22
22
|
|
|
@@ -44,7 +44,7 @@ The following flow is for credit card and bank account payment method types only
|
|
|
44
44
|
4. **Create payment intent on your server**: use your server-side Amos client to call `POST /payment_intents`. You may also associate this payment intent with a new or existing customer via `POST /customers`. This must be server-side because it uses your private API key.
|
|
45
45
|
5. **Return the payment intent token to the browser**: your backend responds with the embed token (`components["schemas"]["EmbedToken"]`) needed for confirmation.
|
|
46
46
|
6. **Confirm the payment intent from the client**: `await confirmPayment({ iframeRef, token })`.
|
|
47
|
-
7. **Handle UX**: show the user a "processing" state while awaiting `confirmPayment`. Do not treat `{ status: "succeeded" }` as settlement proof — verify payment success on your backend via webhooks. Recoverable field errors stay in the iframe; `confirmPayment` still resolves `{ status: "failed" }
|
|
47
|
+
7. **Handle UX**: show the user a "processing" state while awaiting `confirmPayment`. Do not treat `{ status: "succeeded" }` as settlement proof — verify payment success on your backend via webhooks. Recoverable field errors stay in the iframe; `confirmPayment` still resolves `{ status: "failed" }` (with `paymentIntent` when the confirm API returned a body, including `last_payment_error` on declines).
|
|
48
48
|
|
|
49
49
|
### Google Pay & Apple Pay
|
|
50
50
|
|
|
@@ -62,9 +62,9 @@ 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, `await confirmSetup({ iframeRef, token })` instead of `confirmPayment({ iframeRef, token })`.
|
|
65
|
-
- Both resolve
|
|
65
|
+
- Both resolve with a status and the matching intent object when the confirm API returned a body (`ConfirmPaymentResult` / `ConfirmSetupResult`).
|
|
66
66
|
|
|
67
|
-
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call. For bank setup, pass `intent="setup"` so
|
|
67
|
+
The same `AmosCreditCardPaymentMethodForm` / `AmosBankAccountPaymentMethodForm` components support both payment intents and setup intents — they are differentiated by which confirmation function you call. For bank setup, pass `intent="setup"` so Plaid is always shown (unless the render token disables verification).
|
|
68
68
|
|
|
69
69
|
## Understanding PCI DSS compliance requirements
|
|
70
70
|
|
|
@@ -82,7 +82,7 @@ In short, your app orchestrates the payment flow, while sensitive payment data s
|
|
|
82
82
|
|
|
83
83
|
## Appearance
|
|
84
84
|
|
|
85
|
-
Card and bank components accept an optional `appearance` prop that controls the look of the iframe UI
|
|
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
|
|
@@ -151,7 +151,7 @@ Radio groups (e.g. account type) always use an above-style group label regardles
|
|
|
151
151
|
| `--control-gap` | Horizontal gap between side-by-side controls | `0.5rem` |
|
|
152
152
|
| `--error-font-size` | Font size of field-level error messages | `0.875rem` |
|
|
153
153
|
| `--radio-size` | Size of radio buttons on the bank account form | `1rem` |
|
|
154
|
-
| `--ring` | Focus ring and outline color (inputs
|
|
154
|
+
| `--ring` | Focus ring and outline color (inputs) | `oklch(0.708 0 0)` |
|
|
155
155
|
| `--ring-width` | Focus ring width | `3px` |
|
|
156
156
|
| `--radius` | Base border-radius (derived into sm/md/lg/xl) | `0.625rem` |
|
|
157
157
|
|
|
@@ -243,7 +243,7 @@ import { useState } from "react";
|
|
|
243
243
|
import {
|
|
244
244
|
AmosApplePayButton,
|
|
245
245
|
AmosGooglePayButton,
|
|
246
|
-
type
|
|
246
|
+
type ConfirmPaymentResult,
|
|
247
247
|
} from "@amos.com/react-amos-js";
|
|
248
248
|
import type { components } from "@amos.com/node";
|
|
249
249
|
|
|
@@ -279,8 +279,8 @@ function CheckoutWallets({ renderToken }: { renderToken: string }) {
|
|
|
279
279
|
}: {
|
|
280
280
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
281
281
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
282
|
-
confirmPayment: (token: string) => Promise<
|
|
283
|
-
}): Promise<
|
|
282
|
+
confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
|
|
283
|
+
}): Promise<ConfirmPaymentResult> {
|
|
284
284
|
try {
|
|
285
285
|
const token = await createPaymentIntentToken({
|
|
286
286
|
paymentIntentCreateAttributes,
|
|
@@ -433,14 +433,14 @@ Validates the embedded card/bank iframe form before payment confirmation.
|
|
|
433
433
|
|
|
434
434
|
### `confirmPayment({ iframeRef, token })`
|
|
435
435
|
|
|
436
|
-
Confirms a payment intent in the embedded iframe flow. Resolves `{ status: "succeeded" }` or `{ status: "failed" }`.
|
|
436
|
+
Confirms a payment intent in the embedded iframe flow. Resolves `{ status: "succeeded", paymentIntent }` or `{ status: "failed", paymentIntent? }`.
|
|
437
437
|
|
|
438
438
|
**Parameters:**
|
|
439
439
|
|
|
440
440
|
- `iframeRef` (`React.RefObject<HTMLIFrameElement | null> | undefined`, required)
|
|
441
441
|
- `token` (typed as `Pick<components["schemas"]["EmbedToken"], "token">` — the embed JWT string returned by your server)
|
|
442
442
|
|
|
443
|
-
**Returns:** `Promise<
|
|
443
|
+
**Returns:** `Promise<ConfirmPaymentResult>`
|
|
444
444
|
|
|
445
445
|
### `confirmSetup({ iframeRef, token })`
|
|
446
446
|
|
|
@@ -451,7 +451,7 @@ Confirms a setup intent in the embedded iframe flow. Use this when saving a paym
|
|
|
451
451
|
- `iframeRef` (`React.RefObject<HTMLIFrameElement | null> | undefined`, required)
|
|
452
452
|
- `token` (same `Pick<components["schemas"]["EmbedToken"], "token">` embed JWT string as for payment confirmation)
|
|
453
453
|
|
|
454
|
-
**Returns:** `Promise<
|
|
454
|
+
**Returns:** `Promise<ConfirmSetupResult>`
|
|
455
455
|
|
|
456
456
|
### `resetForm({ iframeRef })`
|
|
457
457
|
|
|
@@ -486,25 +486,23 @@ Renders the secure credit card iframe form. A field-shaped skeleton is shown imm
|
|
|
486
486
|
|
|
487
487
|
Renders the secure bank account iframe form. A field-shaped skeleton is shown immediately and replaced by the iframe once appearance is applied.
|
|
488
488
|
|
|
489
|
-
When
|
|
489
|
+
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. 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.
|
|
490
490
|
|
|
491
|
-
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken
|
|
491
|
+
**Required props:** same as `AmosCreditCardPaymentMethodForm` — `renderToken`.
|
|
492
492
|
|
|
493
|
-
|
|
494
|
-
- `intent` (`"payment" | "setup"`, defaults to `"payment"`) — `"setup"` always shows Connect / Plaid (no merchant ACH threshold lookup), unless the render token disables verification. Use this when saving a bank account for later charges.
|
|
493
|
+
**Optional props:** same as `AmosCreditCardPaymentMethodForm` — `appearance`, `billingAddressRequirement`, `onValidityChange` (`isValid` is also true after Plaid returns credentials) — plus:
|
|
495
494
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
Compare locally once the iframe posts `ACH_THRESHOLD`: Plaid when `requireVerification` is true (setup intents), or when the amount (converted to cents, default `0`) is `>= achThreshold`. No threshold (or `null`) keeps the manual bank form. Render tokens with Plaid verification disabled never require Connect. If `amount` later drops under the threshold, Plaid credentials are dropped and the iframe form is shown again.
|
|
495
|
+
- `requireAchVerification` (`boolean`, defaults to `false`) — when true, show Plaid Embedded Link instead of routing/account fields. Ignored for `intent="setup"` (always Plaid) and when the render token has bank `verification: false`. Hosts that still have an ACH threshold should compute this themselves and pass a new value when the charge changes.
|
|
496
|
+
- `intent` (`"payment" | "setup"`, defaults to `"payment"`) — `"setup"` always shows Plaid unless the render token disables verification. Use this when saving a bank account for later charges.
|
|
499
497
|
|
|
500
498
|
```tsx
|
|
501
499
|
<AmosBankAccountPaymentMethodForm
|
|
502
500
|
renderToken={renderToken}
|
|
503
|
-
|
|
501
|
+
requireAchVerification
|
|
504
502
|
/>
|
|
505
503
|
```
|
|
506
504
|
|
|
507
|
-
Setup (always
|
|
505
|
+
Setup (always Plaid, unless the render token disables verification):
|
|
508
506
|
|
|
509
507
|
```tsx
|
|
510
508
|
<AmosBankAccountPaymentMethodForm
|
|
@@ -528,7 +526,7 @@ Renders the secure Google Pay iframe button (express checkout flow). A button-sh
|
|
|
528
526
|
- `renderToken` (`string`)
|
|
529
527
|
- `amount` (`string`) — major-currency decimal string shown in the wallet sheet (e.g. `"50.00"` for $50.00). The iframe converts this to cents in `paymentIntentCreateAttributes.amount`.
|
|
530
528
|
- `merchantName` (`string`)
|
|
531
|
-
- `onConfirm` (callback receiving `{ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment }`. Create a payment intent, then `return confirmPayment(token)` — `Promise<
|
|
529
|
+
- `onConfirm` (callback receiving `{ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment }`. Create a payment intent, then `return confirmPayment(token)` — `Promise<ConfirmPaymentResult>`)
|
|
532
530
|
|
|
533
531
|
**Optional props:**
|
|
534
532
|
|
|
@@ -584,15 +582,15 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
|
|
|
584
582
|
|
|
585
583
|
### Exported types
|
|
586
584
|
|
|
587
|
-
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `
|
|
585
|
+
`@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmPaymentResult`, `ConfirmSetupResult`, `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`.
|
|
588
586
|
|
|
589
587
|
## Notes and potential gotchas
|
|
590
588
|
|
|
591
589
|
- **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPayment`, `confirmSetup`, or `resetForm`. The component forwards the ref to the inner iframe.
|
|
592
|
-
- **`confirmPayment` / `confirmSetup` are not settlement proof**: `{ status: "succeeded" }` means authorization succeeded (capture may still finish asynchronously). Verify payment or setup success on your backend via webhooks. Recoverable field errors stay in the iframe; the Promise still resolves `{ status: "failed" }`.
|
|
590
|
+
- **`confirmPayment` / `confirmSetup` are not settlement proof**: `{ status: "succeeded" }` means authorization succeeded (capture may still finish asynchronously). Verify payment or setup success on your backend via webhooks. Recoverable field errors stay in the iframe; the Promise still resolves `{ status: "failed" }`. Declined confirms include the intent so you can read `last_payment_error` without a follow-up GET.
|
|
593
591
|
- **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`).
|
|
594
|
-
- **Amount format**: for `AmosGooglePayButton
|
|
595
|
-
- **Plaid Link (ACH verification)**: load `cdn.plaid.com` from the **parent** document (see CSP on `AmosBankAccountPaymentMethodForm`). Merchants do not proxy Pay API; the bank iframe
|
|
592
|
+
- **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`).
|
|
593
|
+
- **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. Confirm still goes through the bank iframe so Amos can attach `plaid` to the payment method.
|
|
596
594
|
- **Apple Pay waiting overlay**: on browsers where Apple's QR handoff opens in a popup (non-Safari), `AmosApplePayButton` shows a fixed full-viewport overlay on the host page until payment completes, the popup closes, or the user clicks **Cancel payment**. Avoid stacking other fixed UI above it.
|
|
597
595
|
- **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.
|
|
598
596
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="googlepay" />
|
|
2
|
-
import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement,
|
|
2
|
+
import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmPaymentResult, ConfirmSetupResult, CreditCardAdditionalFields, GooglePayButtonElementProps } 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';
|
|
@@ -22,7 +22,7 @@ export declare function validateForm({ iframeRef, }: {
|
|
|
22
22
|
*/
|
|
23
23
|
export declare function confirmPayment({ iframeRef, token, }: {
|
|
24
24
|
iframeRef: IframeRef;
|
|
25
|
-
} & Pick<components["schemas"]["EmbedToken"], "token">): Promise<
|
|
25
|
+
} & Pick<components["schemas"]["EmbedToken"], "token">): Promise<ConfirmPaymentResult>;
|
|
26
26
|
/**
|
|
27
27
|
* Confirm a setup intent in the embedded iframe flow. Use this when
|
|
28
28
|
* saving a payment method for future use.
|
|
@@ -32,7 +32,7 @@ export declare function confirmPayment({ iframeRef, token, }: {
|
|
|
32
32
|
*/
|
|
33
33
|
export declare function confirmSetup({ iframeRef, token, }: {
|
|
34
34
|
iframeRef: IframeRef;
|
|
35
|
-
} & Pick<components["schemas"]["EmbedToken"], "token">): Promise<
|
|
35
|
+
} & Pick<components["schemas"]["EmbedToken"], "token">): Promise<ConfirmSetupResult>;
|
|
36
36
|
/**
|
|
37
37
|
* Clear all field values and API errors in the embedded card/bank iframe
|
|
38
38
|
* form. Call after a failed confirm when the customer wants to try again.
|
|
@@ -69,37 +69,32 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
69
69
|
appearance?: Appearance;
|
|
70
70
|
/**
|
|
71
71
|
* Called when form validity changes. `isValid` is true when all
|
|
72
|
-
* required fields are present and valid, or when Plaid Link
|
|
73
|
-
* returned credentials. Does not include PCI data.
|
|
72
|
+
* required fields are present and valid, or when Plaid Embedded Link
|
|
73
|
+
* has returned credentials. Does not include PCI data.
|
|
74
74
|
*/
|
|
75
75
|
onValidityChange?: (event: {
|
|
76
76
|
isValid: boolean;
|
|
77
77
|
}) => void;
|
|
78
78
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
79
79
|
/**
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* stays hidden until the host passes a real charge.
|
|
80
|
+
* When true, hide the routing/account iframe and mount Plaid Embedded
|
|
81
|
+
* Institution Search in the parent. Ignored when `intent` is `"setup"`
|
|
82
|
+
* (setup always shows Plaid) or when the render token disables
|
|
83
|
+
* verification.
|
|
85
84
|
*
|
|
86
|
-
*
|
|
87
|
-
* `"setup"`.
|
|
88
|
-
*
|
|
89
|
-
* @default "0"
|
|
85
|
+
* @default false
|
|
90
86
|
*/
|
|
91
|
-
|
|
87
|
+
requireAchVerification?: boolean;
|
|
92
88
|
/**
|
|
93
89
|
* `"setup"` saves a bank account for later charges and always shows
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
* merchant ACH threshold.
|
|
90
|
+
* Plaid (unless the render token disables verification). `"payment"`
|
|
91
|
+
* uses {@link AmosBankAccountPaymentMethodFormProps.requireAchVerification}.
|
|
97
92
|
*
|
|
98
93
|
* @default "payment"
|
|
99
94
|
*/
|
|
100
95
|
intent?: "payment" | "setup";
|
|
101
96
|
};
|
|
102
|
-
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, billingAddressRequirement,
|
|
97
|
+
export declare function AmosBankAccountPaymentMethodForm({ ref, renderToken, appearance, onValidityChange, billingAddressRequirement, requireAchVerification, intent, style, ...rest }: AmosBankAccountPaymentMethodFormProps): import("react").JSX.Element;
|
|
103
98
|
type AmosGooglePayButtonProps = {
|
|
104
99
|
ref?: ForwardedIframeRef;
|
|
105
100
|
renderToken: string;
|
|
@@ -131,8 +126,8 @@ type AmosGooglePayButtonProps = {
|
|
|
131
126
|
onConfirm: ({ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment, }: {
|
|
132
127
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
133
128
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
134
|
-
confirmPayment: (token: string) => Promise<
|
|
135
|
-
}) => Promise<
|
|
129
|
+
confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
|
|
130
|
+
}) => Promise<ConfirmPaymentResult>;
|
|
136
131
|
};
|
|
137
132
|
/**
|
|
138
133
|
* Renders the secure Google Pay iframe button. A button-shaped
|
|
@@ -171,8 +166,8 @@ type AmosApplePayButtonProps = {
|
|
|
171
166
|
onConfirm: ({ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment, }: {
|
|
172
167
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
173
168
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
174
|
-
confirmPayment: (token: string) => Promise<
|
|
175
|
-
}) => Promise<
|
|
169
|
+
confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
|
|
170
|
+
}) => Promise<ConfirmPaymentResult>;
|
|
176
171
|
};
|
|
177
172
|
/**
|
|
178
173
|
* Renders the secure Apple Pay iframe button. A button-shaped
|
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}){return(0,e.confirmPayment)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){return(0,e.confirmSetup)({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,onValidityChange:o,onCardBrandChanged: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,onValidityChange:o,onCardBrandChanged:s},remountDeps:[i,c.cardholderName,l],iframePassthrough:{style:d,...f},updateDeps:[a,c,l,o,s]}),(0,n.jsx)(`div`,{ref:p})}function m({ref:r,renderToken:i,appearance:a,onValidityChange:o,billingAddressRequirement:s=`country`,
|
|
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}){return(0,e.confirmPayment)({iframe:r(t),token:n})}function o({iframeRef:t,token:n}){return(0,e.confirmSetup)({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,onValidityChange:o,onCardBrandChanged: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,onValidityChange:o,onCardBrandChanged:s},remountDeps:[i,c.cardholderName,l],iframePassthrough:{style:d,...f},updateDeps:[a,c,l,o,s]}),(0,n.jsx)(`div`,{ref:p})}function m({ref:r,renderToken:i,appearance:a,onValidityChange:o,billingAddressRequirement:s=`country`,requireAchVerification:c=!1,intent:l=`payment`,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:s,requireAchVerification:c,intent:l,onValidityChange:o},remountDeps:[i,s,l],iframePassthrough:{style:d,...f},updateDeps:[a,s,c,l,o]}),(0,n.jsx)(`div`,{ref:p})}function h({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:d}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:d},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d]}),(0,n.jsx)(f,{height:s,borderRadius:m,containerRef:p})}function g({ref:r,renderToken:i,amount:a,merchantName:o,height:s=`48px`,buttonProps:c,iframeProps:l,onConfirm:d}){let p=(0,t.useRef)(null),m=(0,e.resolveWalletButtonSkeletonBorderRadius)({iframeStyle:l?.style,buttonProps:c});return u({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,height:s,buttonProps:c,onConfirm:d},remountDeps:[i],iframePassthrough:l??{},updateDeps:[a,o,s,c,d]}),(0,n.jsx)(f,{height:s,borderRadius:m,containerRef:p})}exports.AmosApplePayButton=g,exports.AmosBankAccountPaymentMethodForm=m,exports.AmosCreditCardPaymentMethodForm=p,exports.AmosGooglePayButton=h,exports.confirmPayment=a,exports.confirmSetup=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
|
@@ -116,7 +116,7 @@ function T({ ref: e, renderToken: t, appearance: n, onValidityChange: r, onCardB
|
|
|
116
116
|
]
|
|
117
117
|
}), /* @__PURE__ */ p("div", { ref: u });
|
|
118
118
|
}
|
|
119
|
-
function E({ ref: e, renderToken: t, appearance: n, onValidityChange: r, billingAddressRequirement: a = "country",
|
|
119
|
+
function E({ ref: e, renderToken: t, appearance: n, onValidityChange: r, billingAddressRequirement: a = "country", requireAchVerification: o = !1, intent: s = "payment", style: c, ...l }) {
|
|
120
120
|
let u = f(null);
|
|
121
121
|
return S({
|
|
122
122
|
containerRef: u,
|
|
@@ -126,7 +126,7 @@ function E({ ref: e, renderToken: t, appearance: n, onValidityChange: r, billing
|
|
|
126
126
|
renderToken: t,
|
|
127
127
|
appearance: n,
|
|
128
128
|
billingAddressRequirement: a,
|
|
129
|
-
|
|
129
|
+
requireAchVerification: o,
|
|
130
130
|
intent: s,
|
|
131
131
|
onValidityChange: r
|
|
132
132
|
},
|
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.4",
|
|
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.11.
|
|
51
|
+
"@amos.com/amos-js": "0.11.5",
|
|
52
52
|
"@types/googlepay": "0.7.12"
|
|
53
53
|
},
|
|
54
54
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -8,7 +8,8 @@ import {
|
|
|
8
8
|
resetForm as amosResetForm,
|
|
9
9
|
validateForm as amosValidateForm,
|
|
10
10
|
type BillingAddressRequirement,
|
|
11
|
-
type
|
|
11
|
+
type ConfirmPaymentResult,
|
|
12
|
+
type ConfirmSetupResult,
|
|
12
13
|
type CreditCardAdditionalFields,
|
|
13
14
|
ensureSkeletonStyles,
|
|
14
15
|
type GooglePayButtonElementProps,
|
|
@@ -68,7 +69,7 @@ export function confirmPayment({
|
|
|
68
69
|
} & Pick<
|
|
69
70
|
components["schemas"]["EmbedToken"],
|
|
70
71
|
"token"
|
|
71
|
-
>): Promise<
|
|
72
|
+
>): Promise<ConfirmPaymentResult> {
|
|
72
73
|
return amosConfirmPayment({ iframe: resolveIframe(iframeRef), token });
|
|
73
74
|
}
|
|
74
75
|
|
|
@@ -87,7 +88,7 @@ export function confirmSetup({
|
|
|
87
88
|
} & Pick<
|
|
88
89
|
components["schemas"]["EmbedToken"],
|
|
89
90
|
"token"
|
|
90
|
-
>): Promise<
|
|
91
|
+
>): Promise<ConfirmSetupResult> {
|
|
91
92
|
return amosConfirmSetup({ iframe: resolveIframe(iframeRef), token });
|
|
92
93
|
}
|
|
93
94
|
|
|
@@ -325,29 +326,24 @@ type AmosBankAccountPaymentMethodFormProps = IframePassthroughProps & {
|
|
|
325
326
|
appearance?: Appearance;
|
|
326
327
|
/**
|
|
327
328
|
* Called when form validity changes. `isValid` is true when all
|
|
328
|
-
* required fields are present and valid, or when Plaid Link
|
|
329
|
-
* returned credentials. Does not include PCI data.
|
|
329
|
+
* required fields are present and valid, or when Plaid Embedded Link
|
|
330
|
+
* has returned credentials. Does not include PCI data.
|
|
330
331
|
*/
|
|
331
332
|
onValidityChange?: (event: { isValid: boolean }) => void;
|
|
332
333
|
billingAddressRequirement?: BillingAddressRequirement;
|
|
333
334
|
/**
|
|
334
|
-
*
|
|
335
|
-
*
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* stays hidden until the host passes a real charge.
|
|
335
|
+
* When true, hide the routing/account iframe and mount Plaid Embedded
|
|
336
|
+
* Institution Search in the parent. Ignored when `intent` is `"setup"`
|
|
337
|
+
* (setup always shows Plaid) or when the render token disables
|
|
338
|
+
* verification.
|
|
339
339
|
*
|
|
340
|
-
*
|
|
341
|
-
* `"setup"`.
|
|
342
|
-
*
|
|
343
|
-
* @default "0"
|
|
340
|
+
* @default false
|
|
344
341
|
*/
|
|
345
|
-
|
|
342
|
+
requireAchVerification?: boolean;
|
|
346
343
|
/**
|
|
347
344
|
* `"setup"` saves a bank account for later charges and always shows
|
|
348
|
-
*
|
|
349
|
-
*
|
|
350
|
-
* merchant ACH threshold.
|
|
345
|
+
* Plaid (unless the render token disables verification). `"payment"`
|
|
346
|
+
* uses {@link AmosBankAccountPaymentMethodFormProps.requireAchVerification}.
|
|
351
347
|
*
|
|
352
348
|
* @default "payment"
|
|
353
349
|
*/
|
|
@@ -360,7 +356,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
360
356
|
appearance,
|
|
361
357
|
onValidityChange,
|
|
362
358
|
billingAddressRequirement = "country",
|
|
363
|
-
|
|
359
|
+
requireAchVerification = false,
|
|
364
360
|
intent = "payment",
|
|
365
361
|
style,
|
|
366
362
|
...rest
|
|
@@ -375,7 +371,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
375
371
|
renderToken,
|
|
376
372
|
appearance,
|
|
377
373
|
billingAddressRequirement,
|
|
378
|
-
|
|
374
|
+
requireAchVerification,
|
|
379
375
|
intent,
|
|
380
376
|
onValidityChange,
|
|
381
377
|
},
|
|
@@ -384,7 +380,7 @@ export function AmosBankAccountPaymentMethodForm({
|
|
|
384
380
|
updateDeps: [
|
|
385
381
|
appearance,
|
|
386
382
|
billingAddressRequirement,
|
|
387
|
-
|
|
383
|
+
requireAchVerification,
|
|
388
384
|
intent,
|
|
389
385
|
onValidityChange,
|
|
390
386
|
],
|
|
@@ -428,8 +424,8 @@ type AmosGooglePayButtonProps = {
|
|
|
428
424
|
}: {
|
|
429
425
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
430
426
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
431
|
-
confirmPayment: (token: string) => Promise<
|
|
432
|
-
}) => Promise<
|
|
427
|
+
confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
|
|
428
|
+
}) => Promise<ConfirmPaymentResult>;
|
|
433
429
|
};
|
|
434
430
|
|
|
435
431
|
/**
|
|
@@ -514,8 +510,8 @@ type AmosApplePayButtonProps = {
|
|
|
514
510
|
}: {
|
|
515
511
|
paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
|
|
516
512
|
customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
|
|
517
|
-
confirmPayment: (token: string) => Promise<
|
|
518
|
-
}) => Promise<
|
|
513
|
+
confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
|
|
514
|
+
}) => Promise<ConfirmPaymentResult>;
|
|
519
515
|
};
|
|
520
516
|
|
|
521
517
|
/**
|