@amos.com/react-amos-js 0.11.3 → 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 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`, `ConfirmResult`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
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,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, `await confirmSetup({ iframeRef, token })` instead of `confirmPayment({ iframeRef, token })`.
65
- - Both resolve `{ status: "succeeded" | "failed" }`.
65
+ - Both resolve with a status and the matching intent object when the confirm API returned a body (`ConfirmPaymentResult` / `ConfirmSetupResult`).
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. For bank setup, pass `intent="setup"` so Plaid is always shown (unless the render token disables verification).
68
68
 
@@ -243,7 +243,7 @@ import { useState } from "react";
243
243
  import {
244
244
  AmosApplePayButton,
245
245
  AmosGooglePayButton,
246
- type ConfirmResult,
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<ConfirmResult>;
283
- }): Promise<ConfirmResult> {
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<ConfirmResult>`
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<ConfirmResult>`
454
+ **Returns:** `Promise<ConfirmSetupResult>`
455
455
 
456
456
  ### `resetForm({ iframeRef })`
457
457
 
@@ -526,7 +526,7 @@ Renders the secure Google Pay iframe button (express checkout flow). A button-sh
526
526
  - `renderToken` (`string`)
527
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`.
528
528
  - `merchantName` (`string`)
529
- - `onConfirm` (callback receiving `{ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment }`. Create a payment intent, then `return confirmPayment(token)` — `Promise<ConfirmResult>`)
529
+ - `onConfirm` (callback receiving `{ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment }`. Create a payment intent, then `return confirmPayment(token)` — `Promise<ConfirmPaymentResult>`)
530
530
 
531
531
  **Optional props:**
532
532
 
@@ -582,12 +582,12 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
582
582
 
583
583
  ### Exported types
584
584
 
585
- `@amos.com/react-amos-js` re-exports everything from `@amos.com/amos-js`, including `ConfirmResult`, `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`.
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`.
586
586
 
587
587
  ## Notes and potential gotchas
588
588
 
589
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.
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" }`.
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.
591
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`).
592
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
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.
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference types="googlepay" />
2
- import { Appearance, ApplePayButtonElementProps, BillingAddressRequirement, ConfirmResult, CreditCardAdditionalFields, GooglePayButtonElementProps } from '@amos.com/amos-js';
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<ConfirmResult>;
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<ConfirmResult>;
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.
@@ -126,8 +126,8 @@ type AmosGooglePayButtonProps = {
126
126
  onConfirm: ({ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment, }: {
127
127
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
128
128
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
129
- confirmPayment: (token: string) => Promise<ConfirmResult>;
130
- }) => Promise<ConfirmResult>;
129
+ confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
130
+ }) => Promise<ConfirmPaymentResult>;
131
131
  };
132
132
  /**
133
133
  * Renders the secure Google Pay iframe button. A button-shaped
@@ -166,8 +166,8 @@ type AmosApplePayButtonProps = {
166
166
  onConfirm: ({ paymentIntentCreateAttributes, customerCreateAttributes, confirmPayment, }: {
167
167
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
168
168
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
169
- confirmPayment: (token: string) => Promise<ConfirmResult>;
170
- }) => Promise<ConfirmResult>;
169
+ confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
170
+ }) => Promise<ConfirmPaymentResult>;
171
171
  };
172
172
  /**
173
173
  * Renders the secure Apple Pay iframe button. A button-shaped
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.11.3",
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.4",
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 ConfirmResult,
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<ConfirmResult> {
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<ConfirmResult> {
91
+ >): Promise<ConfirmSetupResult> {
91
92
  return amosConfirmSetup({ iframe: resolveIframe(iframeRef), token });
92
93
  }
93
94
 
@@ -423,8 +424,8 @@ type AmosGooglePayButtonProps = {
423
424
  }: {
424
425
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
425
426
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
426
- confirmPayment: (token: string) => Promise<ConfirmResult>;
427
- }) => Promise<ConfirmResult>;
427
+ confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
428
+ }) => Promise<ConfirmPaymentResult>;
428
429
  };
429
430
 
430
431
  /**
@@ -509,8 +510,8 @@ type AmosApplePayButtonProps = {
509
510
  }: {
510
511
  paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
511
512
  customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
512
- confirmPayment: (token: string) => Promise<ConfirmResult>;
513
- }) => Promise<ConfirmResult>;
513
+ confirmPayment: (token: string) => Promise<ConfirmPaymentResult>;
514
+ }) => Promise<ConfirmPaymentResult>;
514
515
  };
515
516
 
516
517
  /**