@amos.com/react-amos-js 0.9.4 → 0.9.6

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
@@ -7,16 +7,18 @@ It is a thin wrapper around [`@amos.com/amos-js`](../amos-js) that adapts the fr
7
7
  ## Installation
8
8
 
9
9
  ```bash
10
- npm install @amos.com/react-amos-js
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.
14
+
13
15
  ## What it gives you
14
16
 
15
17
  - React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`, `AmosApplePayButton`.
16
- - React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPaymentIntent({ iframeRef, token })`, `confirmSetupIntent({ iframeRef, token })`.
17
- - Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `ConfirmationResult`, `ConfirmationIncompleteReason`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
18
+ - React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPaymentIntent({ iframeRef, token })`, `confirmSetupIntent({ 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`, `ConfirmationResult`, `ConfirmationIncompleteReason`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
18
20
 
19
- > **Note:** A server-side SDK (for example `@amos.com/node`) must be used alongside `@amos.com/react-amos-js` for end-to-end payment processing. `@amos.com/react-amos-js` is the client-side half.
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.
20
22
 
21
23
  ## Requirements
22
24
 
@@ -381,6 +383,16 @@ Confirms a setup intent in the embedded iframe flow. Use this when saving a paym
381
383
 
382
384
  **Returns:** `void`
383
385
 
386
+ ### `resetForm({ iframeRef })`
387
+
388
+ Clears all field values and API errors in the embedded card/bank iframe form. Call after `onResult` when the customer wants to try again (for example, after a successful payment when starting a new one).
389
+
390
+ **Parameters:**
391
+
392
+ - `iframeRef` (`React.RefObject<HTMLIFrameElement | null> | undefined`, required)
393
+
394
+ **Returns:** `void`
395
+
384
396
  ### `AmosCreditCardPaymentMethodForm`
385
397
 
386
398
  Renders the secure credit card iframe form.
@@ -454,7 +466,7 @@ Re-exports of the same advanced helpers exposed by `@amos.com/amos-js`. Most int
454
466
 
455
467
  ## Notes and potential gotchas
456
468
 
457
- - **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, or `confirmSetupIntent`. The component forwards the ref to the inner iframe.
469
+ - **`ref` / `iframeRef`**: for card and bank forms, pass `ref={iframeRef}` to the form component. The same `iframeRef` must be used when calling `validateForm`, `confirmPaymentIntent`, `confirmSetupIntent`, or `resetForm`. The component forwards the ref to the inner iframe.
458
470
  - **`onResult` is not settlement proof**: `onResult` tells you when to stop waiting (e.g. dismiss a spinner). Verify payment or setup success on your backend via webhooks. On `status: "incomplete"`, unlock your UI — the customer can fix fields in the iframe and retry. Use `result.reason` (`"field_errors"` or `"validation_failed"`) to distinguish recoverable states.
459
471
  - **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 (`confirmPaymentIntent` vs `confirmSetupIntent`). Handle both payment and setup outcomes via `onResult`.
460
472
  - **Amount format**: for `AmosGooglePayButton` and `AmosApplePayButton`, `amount` is a string (e.g. `"5000"` for $50.00). For `components["schemas"]["CreatePaymentIntentInput"]` on the server, `amount` is a number in cents (e.g. `5000`).
package/dist/index.d.ts CHANGED
@@ -33,6 +33,13 @@ export declare function confirmPaymentIntent({ iframeRef, token, }: {
33
33
  export declare function confirmSetupIntent({ iframeRef, token, }: {
34
34
  iframeRef: IframeRef;
35
35
  } & Pick<components["schemas"]["EmbedToken"], "token">): void;
36
+ /**
37
+ * Clear all field values and API errors in the embedded card/bank iframe
38
+ * form. Call after `onResult` when the customer wants to try again.
39
+ */
40
+ export declare function resetForm({ iframeRef }: {
41
+ iframeRef: IframeRef;
42
+ }): void;
36
43
  type IframePassthroughProps = Omit<ComponentProps<"iframe">, "src" | "title" | "name" | "role" | "allow">;
37
44
  type AmosCreditCardPaymentMethodFormProps = IframePassthroughProps & {
38
45
  renderToken: string;
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(e,t){typeof e==`function`?e(t):e&&(e.current=t)}function c(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 l({containerRef:e,iframeRef:n,mount:r,options:i,remountDeps:a,iframePassthrough:o,updateDeps:l}){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,s(n,a.iframe),c(a.iframe,o),()=>{a.destroy(),u.current=null,s(n,null)}},[...a]),(0,t.useEffect)(()=>{u.current?.update(i)},[...l]),(0,t.useEffect)(()=>{let e=u.current?.iframe;e&&c(e,o)})}function u({ref:r,renderToken:i,appearance:a,onResult:o,additionalFields:s={cardholderName:!1},billingAddressRequirement:c=`country`,style:u,...d}){let f=(0,t.useRef)(null);return l({containerRef:f,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:s,billingAddressRequirement:c,onResult:o},remountDeps:[i,s.cardholderName,c],iframePassthrough:{style:u,...d},updateDeps:[a,s,c,o]}),(0,n.jsx)(`div`,{ref:f})}function d({ref:r,renderToken:i,appearance:a,onResult:o,billingAddressRequirement:s=`country`,style:c,...u}){let d=(0,t.useRef)(null);return l({containerRef:d,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:s,onResult:o},remountDeps:[i,s],iframePassthrough:{style:c,...u},updateDeps:[a,s,o]}),(0,n.jsx)(`div`,{ref:d})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(`div`,{ref:p})}function p({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:u},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,u]}),(0,n.jsx)(`div`,{ref:p})}exports.AmosApplePayButton=p,exports.AmosBankAccountPaymentMethodForm=d,exports.AmosCreditCardPaymentMethodForm=u,exports.AmosGooglePayButton=f,exports.confirmPaymentIntent=a,exports.confirmSetupIntent=o,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),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 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,additionalFields:s={cardholderName:!1},billingAddressRequirement:c=`country`,style:l,...d}){let f=(0,t.useRef)(null);return u({containerRef:f,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:s,billingAddressRequirement:c,onResult:o},remountDeps:[i,s.cardholderName,c],iframePassthrough:{style:l,...d},updateDeps:[a,s,c,o]}),(0,n.jsx)(`div`,{ref:f})}function f({ref:r,renderToken:i,appearance:a,onResult:o,billingAddressRequirement:s=`country`,style:c,...l}){let d=(0,t.useRef)(null);return u({containerRef:d,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:s,onResult:o},remountDeps:[i,s],iframePassthrough:{style:c,...l},updateDeps:[a,s,o]}),(0,n.jsx)(`div`,{ref:d})}function p({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,l]}),(0,n.jsx)(`div`,{ref:p})}function m({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l,style:d,...f}){let p=(0,t.useRef)(null);return u({containerRef:p,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onResult:l},remountDeps:[i],iframePassthrough:{style:d,...f},updateDeps:[a,o,s,c,l]}),(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
@@ -1,52 +1,55 @@
1
- import { confirmPaymentIntent as e, confirmSetupIntent as t, mountAmosApplePayButton as n, mountAmosBankAccountPaymentMethodForm as r, mountAmosCreditCardPaymentMethodForm as i, mountAmosGooglePayButton as a, validateForm as o } from "@amos.com/amos-js";
2
- import { useEffect as s, useRef as c } from "react";
3
- import { jsx as l } from "react/jsx-runtime";
1
+ import { confirmPaymentIntent as e, confirmSetupIntent as t, mountAmosApplePayButton as n, mountAmosBankAccountPaymentMethodForm as r, mountAmosCreditCardPaymentMethodForm as i, mountAmosGooglePayButton as a, resetForm as o, validateForm as s } from "@amos.com/amos-js";
2
+ import { useEffect as c, useRef as l } from "react";
3
+ import { jsx as u } from "react/jsx-runtime";
4
4
  export * from "@amos.com/amos-js";
5
5
  //#region src/index.tsx
6
- function u(e) {
6
+ function d(e) {
7
7
  return e ? e.current ?? null : null;
8
8
  }
9
- function d({ iframeRef: e }) {
10
- return o({ iframe: u(e) });
9
+ function f({ iframeRef: e }) {
10
+ return s({ iframe: d(e) });
11
11
  }
12
- function f({ iframeRef: t, token: n }) {
12
+ function p({ iframeRef: t, token: n }) {
13
13
  e({
14
- iframe: u(t),
14
+ iframe: d(t),
15
15
  token: n
16
16
  });
17
17
  }
18
- function p({ iframeRef: e, token: n }) {
18
+ function m({ iframeRef: e, token: n }) {
19
19
  t({
20
- iframe: u(e),
20
+ iframe: d(e),
21
21
  token: n
22
22
  });
23
23
  }
24
- function m(e, t) {
24
+ function h({ iframeRef: e }) {
25
+ o({ iframe: d(e) });
26
+ }
27
+ function g(e, t) {
25
28
  typeof e == "function" ? e(t) : e && (e.current = t);
26
29
  }
27
- function h(e, { style: t, className: n, id: r, ...i }) {
30
+ function _(e, { style: t, className: n, id: r, ...i }) {
28
31
  n != null && (e.className = n), r != null && (e.id = r), t != null && Object.assign(e.style, t);
29
32
  for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
30
33
  }
31
- function g({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
32
- let l = c(null);
33
- s(() => {
34
+ function v({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
35
+ let s = l(null);
36
+ c(() => {
34
37
  let i = e.current;
35
38
  if (!i) return;
36
39
  let o = n(i, r);
37
- return l.current = o, m(t, o.iframe), h(o.iframe, a), () => {
38
- o.destroy(), l.current = null, m(t, null);
40
+ return s.current = o, g(t, o.iframe), _(o.iframe, a), () => {
41
+ o.destroy(), s.current = null, g(t, null);
39
42
  };
40
- }, [...i]), s(() => {
41
- l.current?.update(r);
42
- }, [...o]), s(() => {
43
- let e = l.current?.iframe;
44
- e && h(e, a);
43
+ }, [...i]), c(() => {
44
+ s.current?.update(r);
45
+ }, [...o]), c(() => {
46
+ let e = s.current?.iframe;
47
+ e && _(e, a);
45
48
  });
46
49
  }
47
- function _({ ref: e, renderToken: t, appearance: n, onResult: r, additionalFields: a = { cardholderName: !1 }, billingAddressRequirement: o = "country", style: s, ...u }) {
48
- let d = c(null);
49
- return g({
50
+ function y({ ref: e, renderToken: t, appearance: n, onResult: r, additionalFields: a = { cardholderName: !1 }, billingAddressRequirement: o = "country", style: s, ...c }) {
51
+ let d = l(null);
52
+ return v({
50
53
  containerRef: d,
51
54
  iframeRef: e,
52
55
  mount: i,
@@ -64,7 +67,7 @@ function _({ ref: e, renderToken: t, appearance: n, onResult: r, additionalField
64
67
  ],
65
68
  iframePassthrough: {
66
69
  style: s,
67
- ...u
70
+ ...c
68
71
  },
69
72
  updateDeps: [
70
73
  n,
@@ -72,12 +75,12 @@ function _({ ref: e, renderToken: t, appearance: n, onResult: r, additionalField
72
75
  o,
73
76
  r
74
77
  ]
75
- }), /* @__PURE__ */ l("div", { ref: d });
78
+ }), /* @__PURE__ */ u("div", { ref: d });
76
79
  }
77
- function v({ ref: e, renderToken: t, appearance: n, onResult: i, billingAddressRequirement: a = "country", style: o, ...s }) {
78
- let u = c(null);
79
- return g({
80
- containerRef: u,
80
+ function b({ ref: e, renderToken: t, appearance: n, onResult: i, billingAddressRequirement: a = "country", style: o, ...s }) {
81
+ let c = l(null);
82
+ return v({
83
+ containerRef: c,
81
84
  iframeRef: e,
82
85
  mount: r,
83
86
  options: {
@@ -96,11 +99,11 @@ function v({ ref: e, renderToken: t, appearance: n, onResult: i, billingAddressR
96
99
  a,
97
100
  i
98
101
  ]
99
- }), /* @__PURE__ */ l("div", { ref: u });
102
+ }), /* @__PURE__ */ u("div", { ref: c });
100
103
  }
101
- function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s, style: u, ...d }) {
102
- let f = c(null);
103
- return g({
104
+ function x({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onResult: s, style: c, ...d }) {
105
+ let f = l(null);
106
+ return v({
104
107
  containerRef: f,
105
108
  iframeRef: e,
106
109
  mount: a,
@@ -114,7 +117,7 @@ function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i,
114
117
  },
115
118
  remountDeps: [t],
116
119
  iframePassthrough: {
117
- style: u,
120
+ style: c,
118
121
  ...d
119
122
  },
120
123
  updateDeps: [
@@ -124,11 +127,11 @@ function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i,
124
127
  o,
125
128
  s
126
129
  ]
127
- }), /* @__PURE__ */ l("div", { ref: f });
130
+ }), /* @__PURE__ */ u("div", { ref: f });
128
131
  }
129
- function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s, style: u, ...d }) {
130
- let f = c(null);
131
- return g({
132
+ function S({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onResult: s, style: c, ...d }) {
133
+ let f = l(null);
134
+ return v({
132
135
  containerRef: f,
133
136
  iframeRef: e,
134
137
  mount: n,
@@ -142,7 +145,7 @@ function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a,
142
145
  },
143
146
  remountDeps: [t],
144
147
  iframePassthrough: {
145
- style: u,
148
+ style: c,
146
149
  ...d
147
150
  },
148
151
  updateDeps: [
@@ -152,7 +155,7 @@ function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a,
152
155
  o,
153
156
  s
154
157
  ]
155
- }), /* @__PURE__ */ l("div", { ref: f });
158
+ }), /* @__PURE__ */ u("div", { ref: f });
156
159
  }
157
160
  //#endregion
158
- export { b as AmosApplePayButton, v as AmosBankAccountPaymentMethodForm, _ as AmosCreditCardPaymentMethodForm, y as AmosGooglePayButton, f as confirmPaymentIntent, p as confirmSetupIntent, d as validateForm };
161
+ 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.4",
3
+ "version": "0.9.6",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -37,6 +37,7 @@
37
37
  "license": "MIT",
38
38
  "description": "React SDK for embedding Amos payment methods via iframes. Wraps @amos.com/amos-js.",
39
39
  "devDependencies": {
40
+ "@amos.com/node": "0.1.39",
40
41
  "@biomejs/biome": "2.5.7",
41
42
  "@changesets/cli": "2.31.1",
42
43
  "@types/node": "26.1.2",
@@ -47,11 +48,11 @@
47
48
  "vite-plugin-dts": "5.0.3"
48
49
  },
49
50
  "dependencies": {
50
- "@amos.com/amos-js": "0.9.3",
51
- "@amos.com/node": "0.1.36",
51
+ "@amos.com/amos-js": "0.9.7",
52
52
  "@types/googlepay": "0.7.11"
53
53
  },
54
54
  "peerDependencies": {
55
- "react": "^17 || ^18 || ^19"
55
+ "react": "^17 || ^18 || ^19",
56
+ "@amos.com/node": ">=0.1.39"
56
57
  }
57
58
  }
package/src/index.tsx CHANGED
@@ -4,6 +4,7 @@ import {
4
4
  type Appearance,
5
5
  confirmPaymentIntent as amosConfirmPaymentIntent,
6
6
  confirmSetupIntent as amosConfirmSetupIntent,
7
+ resetForm as amosResetForm,
7
8
  validateForm as amosValidateForm,
8
9
  type BillingAddressRequirement,
9
10
  type ConfirmationResult,
@@ -79,6 +80,14 @@ export function confirmSetupIntent({
79
80
  amosConfirmSetupIntent({ iframe: resolveIframe(iframeRef), token });
80
81
  }
81
82
 
83
+ /**
84
+ * Clear all field values and API errors in the embedded card/bank iframe
85
+ * form. Call after `onResult` when the customer wants to try again.
86
+ */
87
+ export function resetForm({ iframeRef }: { iframeRef: IframeRef }): void {
88
+ amosResetForm({ iframe: resolveIframe(iframeRef) });
89
+ }
90
+
82
91
  type ForwardedIframeRef = Ref<HTMLIFrameElement> | undefined;
83
92
 
84
93
  function setForwardedRef(