@amos.com/react-amos-js 0.4.0 → 0.5.0

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
@@ -12,7 +12,7 @@ npm install @amos.com/react-amos-js
12
12
 
13
13
  ## What it gives you
14
14
 
15
- - React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`.
15
+ - React components for the iframe payment method forms: `AmosCreditCardPaymentMethodForm`, `AmosBankAccountPaymentMethodForm`, `AmosGooglePayButton`, `AmosApplePayButton`.
16
16
  - React-flavoured iframe message helpers that accept a React `ref`: `validateForm({ iframeRef })`, `confirmPaymentIntent({ iframeRef, token })`, `confirmSetupIntent({ iframeRef, token })`.
17
17
  - Re-exports of the `@amos.com/amos-js` helpers and types that come up in client code: `createMessage`, `decodeJwt`, `getEmbedOrigin`, `formatGooglePayPaymentData`, `FormattedGooglePayPaymentData`, `Appearance`, `Message`, etc.
18
18
 
@@ -46,7 +46,7 @@ The following flow is for credit card and bank account payment method types only
46
46
 
47
47
  ### Google Pay
48
48
 
49
- Google Pay (and soon, Apple Pay) is a form of express checkout. The Google Pay button is an alternative to the "Pay now" button in your payment forms. Users can make a payment with either flow.
49
+ Google Pay and Apple Pay are forms of express checkout. Their buttons are alternatives to the "Pay now" button in your payment forms. Users can make a payment with either flow.
50
50
 
51
51
  The key differences between the express and non-express payment flows are:
52
52
 
@@ -383,7 +383,7 @@ Renders the secure credit card iframe form.
383
383
  - `onPaymentIntentConfirmationSucceeded` (`(paymentIntent: components["schemas"]["PaymentIntent"]) => void`)
384
384
  - `onSetupIntentConfirmationSucceeded` (`(setupIntent: components["schemas"]["SetupIntent"]) => void`)
385
385
  - `additionalFields` (`{ cardholderName: boolean }`) — set `additionalFields={{ cardholderName: true }}` to render the cardholder name field in the iframe (`false` by default)
386
- - `billingAddressRequirement` (`"postalCode" | "postalCodeAndCountry" | "full"`, defaults to `"postalCode"`) — how much billing address the iframe collects. `postalCode` sends only postal code (no country). `full` shows a full street address form with Smarty autocomplete.
386
+ - `billingAddressRequirement` (`"country" | "full"`, defaults to `"country"`) — how much billing address the iframe collects. `country` collects country / region and, for CA / PR / GB / US, a postal code (labeled ZIP for the United States). `full` shows a full street address form with Smarty autocomplete.
387
387
 
388
388
  **Also accepts:** standard iframe props (`React.ComponentProps<"iframe">`), minus `src`, `title`, `name`, and `role` (which are controlled by the SDK).
389
389
 
@@ -416,6 +416,10 @@ Renders the secure Google Pay iframe button (express checkout flow).
416
416
 
417
417
  **Also accepts:** standard iframe props, minus the ones controlled by the SDK (`src`, `title`, `name`, `role`, `allow`).
418
418
 
419
+ ### `AmosApplePayButton`
420
+
421
+ Renders the secure Apple Pay iframe button (express checkout flow). Same props and callbacks as `AmosGooglePayButton`.
422
+
419
423
  ### `formatGooglePayPaymentData({ paymentData })`
420
424
 
421
425
  Transforms Google Pay payment data into an Amos-compatible `paymentMethod` payload. Use this when integrating with the raw Google Pay API (e.g. `@google-pay/button-react`) instead of `AmosGooglePayButton` — `AmosGooglePayButton` handles payment data internally and does not require this helper.
package/dist/index.d.ts CHANGED
@@ -66,3 +66,16 @@ type AmosGooglePayButtonProps = IframePassthroughProps & {
66
66
  onConfirmationFailed: (errorMessage: string) => void;
67
67
  };
68
68
  export declare function AmosGooglePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onPaymentIntentConfirmationSucceeded, onConfirmationFailed, style, ...rest }: AmosGooglePayButtonProps): import("react").JSX.Element;
69
+ type AmosApplePayButtonProps = IframePassthroughProps & {
70
+ renderToken: string;
71
+ amount: string;
72
+ merchantName: string;
73
+ appearance?: Appearance;
74
+ onInitiatePaymentIntentRequest: ({ paymentIntentCreateAttributes, customerCreateAttributes, }: {
75
+ paymentIntentCreateAttributes: components["schemas"]["CreatePaymentIntentInput"];
76
+ customerCreateAttributes: components["schemas"]["CreateCustomerInput"];
77
+ }) => Promise<components["schemas"]["EmbedToken"]["token"]>;
78
+ onPaymentIntentConfirmationSucceeded: (paymentIntent: components["schemas"]["PaymentIntent"]) => void;
79
+ onConfirmationFailed: (errorMessage: string) => void;
80
+ };
81
+ export declare function AmosApplePayButton({ ref, renderToken, amount, merchantName, appearance, onInitiatePaymentIntentRequest, onPaymentIntentConfirmationSucceeded, onConfirmationFailed, style, ...rest }: 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(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,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,additionalFields:u={cardholderName:!1},billingAddressRequirement:d=`postalCode`,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,billingAddressRequirement:d,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u.cardholderName,d],iframePassthrough:{style:f,...p},updateDeps:[a,u,d,o,s,c]}),(0,n.jsx)(`div`,{ref:m})}function d({ref:r,renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,billingAddressRequirement:u=`postalCode`,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:u,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u],iframePassthrough:{style:d,...f},updateDeps:[a,u,o,s,c]}),(0,n.jsx)(`div`,{ref:p})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d},remountDeps:[i],iframePassthrough:{style:f,...p},updateDeps:[a,o,s,c,u,d]}),(0,n.jsx)(`div`,{ref:m})}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(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,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,additionalFields:u={cardholderName:!1},billingAddressRequirement:d=`country`,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,billingAddressRequirement:d,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u.cardholderName,d],iframePassthrough:{style:f,...p},updateDeps:[a,u,d,o,s,c]}),(0,n.jsx)(`div`,{ref:m})}function d({ref:r,renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,billingAddressRequirement:u=`country`,style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,billingAddressRequirement:u,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u],iframePassthrough:{style:d,...f},updateDeps:[a,u,o,s,c]}),(0,n.jsx)(`div`,{ref:p})}function f({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosGooglePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d},remountDeps:[i],iframePassthrough:{style:f,...p},updateDeps:[a,o,s,c,u,d]}),(0,n.jsx)(`div`,{ref:m})}function p({ref:r,renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d,style:f,...p}){let m=(0,t.useRef)(null);return l({containerRef:m,iframeRef:r,mount:e.mountAmosApplePayButton,options:{renderToken:i,amount:a,merchantName:o,appearance:s,onInitiatePaymentIntentRequest:c,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:d},remountDeps:[i],iframePassthrough:{style:f,...p},updateDeps:[a,o,s,c,u,d]}),(0,n.jsx)(`div`,{ref:m})}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]}})});
package/dist/index.mjs CHANGED
@@ -1,67 +1,67 @@
1
- import { confirmPaymentIntent as e, confirmSetupIntent as t, mountAmosBankAccountPaymentMethodForm as n, mountAmosCreditCardPaymentMethodForm as r, mountAmosGooglePayButton as i, validateForm as a } from "@amos.com/amos-js";
2
- import { useEffect as o, useRef as s } from "react";
3
- import { jsx as c } from "react/jsx-runtime";
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";
4
4
  export * from "@amos.com/amos-js";
5
5
  //#region src/index.tsx
6
- function l(e) {
6
+ function u(e) {
7
7
  return e ? e.current ?? null : null;
8
8
  }
9
- function u({ iframeRef: e }) {
10
- return a({ iframe: l(e) });
9
+ function d({ iframeRef: e }) {
10
+ return o({ iframe: u(e) });
11
11
  }
12
- function d({ iframeRef: t, token: n }) {
12
+ function f({ iframeRef: t, token: n }) {
13
13
  e({
14
- iframe: l(t),
14
+ iframe: u(t),
15
15
  token: n
16
16
  });
17
17
  }
18
- function f({ iframeRef: e, token: n }) {
18
+ function p({ iframeRef: e, token: n }) {
19
19
  t({
20
- iframe: l(e),
20
+ iframe: u(e),
21
21
  token: n
22
22
  });
23
23
  }
24
- function p(e, t) {
24
+ function m(e, t) {
25
25
  typeof e == "function" ? e(t) : e && (e.current = t);
26
26
  }
27
- function m(e, { style: t, className: n, id: r, ...i }) {
27
+ function h(e, { style: t, className: n, id: r, ...i }) {
28
28
  n != null && (e.className = n), r != null && (e.id = r), t != null && Object.assign(e.style, t);
29
29
  for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
30
30
  }
31
- function h({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: c }) {
32
- let l = s(null);
33
- o(() => {
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
34
  let i = e.current;
35
35
  if (!i) return;
36
36
  let o = n(i, r);
37
- return l.current = o, p(t, o.iframe), m(o.iframe, a), () => {
38
- o.destroy(), l.current = null, p(t, null);
37
+ return l.current = o, m(t, o.iframe), h(o.iframe, a), () => {
38
+ o.destroy(), l.current = null, m(t, null);
39
39
  };
40
- }, [...i]), o(() => {
40
+ }, [...i]), s(() => {
41
41
  l.current?.update(r);
42
- }, [...c]), o(() => {
42
+ }, [...o]), s(() => {
43
43
  let e = l.current?.iframe;
44
- e && m(e, a);
44
+ e && h(e, a);
45
45
  });
46
46
  }
47
- function g({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, additionalFields: l = { cardholderName: !1 }, billingAddressRequirement: u = "postalCode", style: d, ...f }) {
48
- let p = s(null);
49
- return h({
47
+ function _({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: r, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, additionalFields: s = { cardholderName: !1 }, billingAddressRequirement: u = "country", style: d, ...f }) {
48
+ let p = c(null);
49
+ return g({
50
50
  containerRef: p,
51
51
  iframeRef: e,
52
- mount: r,
52
+ mount: i,
53
53
  options: {
54
54
  renderToken: t,
55
55
  appearance: n,
56
- additionalFields: l,
56
+ additionalFields: s,
57
57
  billingAddressRequirement: u,
58
- onPaymentIntentConfirmationSucceeded: i,
58
+ onPaymentIntentConfirmationSucceeded: r,
59
59
  onSetupIntentConfirmationSucceeded: a,
60
60
  onConfirmationFailed: o
61
61
  },
62
62
  remountDeps: [
63
63
  t,
64
- l.cardholderName,
64
+ s.cardholderName,
65
65
  u
66
66
  ],
67
67
  iframePassthrough: {
@@ -70,55 +70,55 @@ function g({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationS
70
70
  },
71
71
  updateDeps: [
72
72
  n,
73
- l,
73
+ s,
74
74
  u,
75
- i,
75
+ r,
76
76
  a,
77
77
  o
78
78
  ]
79
- }), /* @__PURE__ */ c("div", { ref: p });
79
+ }), /* @__PURE__ */ l("div", { ref: p });
80
80
  }
81
- function _({ ref: e, renderToken: t, appearance: r, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, billingAddressRequirement: l = "postalCode", style: u, ...d }) {
82
- let f = s(null);
83
- return h({
81
+ function v({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, billingAddressRequirement: s = "country", style: u, ...d }) {
82
+ let f = c(null);
83
+ return g({
84
84
  containerRef: f,
85
85
  iframeRef: e,
86
- mount: n,
86
+ mount: r,
87
87
  options: {
88
88
  renderToken: t,
89
- appearance: r,
90
- billingAddressRequirement: l,
89
+ appearance: n,
90
+ billingAddressRequirement: s,
91
91
  onPaymentIntentConfirmationSucceeded: i,
92
92
  onSetupIntentConfirmationSucceeded: a,
93
93
  onConfirmationFailed: o
94
94
  },
95
- remountDeps: [t, l],
95
+ remountDeps: [t, s],
96
96
  iframePassthrough: {
97
97
  style: u,
98
98
  ...d
99
99
  },
100
100
  updateDeps: [
101
- r,
102
- l,
101
+ n,
102
+ s,
103
103
  i,
104
104
  a,
105
105
  o
106
106
  ]
107
- }), /* @__PURE__ */ c("div", { ref: f });
107
+ }), /* @__PURE__ */ l("div", { ref: f });
108
108
  }
109
- function v({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: a, onInitiatePaymentIntentRequest: o, onPaymentIntentConfirmationSucceeded: l, onConfirmationFailed: u, style: d, ...f }) {
110
- let p = s(null);
111
- return h({
109
+ function y({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: o, onPaymentIntentConfirmationSucceeded: s, onConfirmationFailed: u, style: d, ...f }) {
110
+ let p = c(null);
111
+ return g({
112
112
  containerRef: p,
113
113
  iframeRef: e,
114
- mount: i,
114
+ mount: a,
115
115
  options: {
116
116
  renderToken: t,
117
117
  amount: n,
118
118
  merchantName: r,
119
- appearance: a,
119
+ appearance: i,
120
120
  onInitiatePaymentIntentRequest: o,
121
- onPaymentIntentConfirmationSucceeded: l,
121
+ onPaymentIntentConfirmationSucceeded: s,
122
122
  onConfirmationFailed: u
123
123
  },
124
124
  remountDeps: [t],
@@ -129,12 +129,42 @@ function v({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: a,
129
129
  updateDeps: [
130
130
  n,
131
131
  r,
132
+ i,
133
+ o,
134
+ s,
135
+ u
136
+ ]
137
+ }), /* @__PURE__ */ l("div", { ref: p });
138
+ }
139
+ function b({ ref: e, renderToken: t, amount: r, merchantName: i, appearance: a, onInitiatePaymentIntentRequest: o, onPaymentIntentConfirmationSucceeded: s, onConfirmationFailed: u, style: d, ...f }) {
140
+ let p = c(null);
141
+ return g({
142
+ containerRef: p,
143
+ iframeRef: e,
144
+ mount: n,
145
+ options: {
146
+ renderToken: t,
147
+ amount: r,
148
+ merchantName: i,
149
+ appearance: a,
150
+ onInitiatePaymentIntentRequest: o,
151
+ onPaymentIntentConfirmationSucceeded: s,
152
+ onConfirmationFailed: u
153
+ },
154
+ remountDeps: [t],
155
+ iframePassthrough: {
156
+ style: d,
157
+ ...f
158
+ },
159
+ updateDeps: [
160
+ r,
161
+ i,
132
162
  a,
133
163
  o,
134
- l,
164
+ s,
135
165
  u
136
166
  ]
137
- }), /* @__PURE__ */ c("div", { ref: p });
167
+ }), /* @__PURE__ */ l("div", { ref: p });
138
168
  }
139
169
  //#endregion
140
- export { _ as AmosBankAccountPaymentMethodForm, g as AmosCreditCardPaymentMethodForm, v as AmosGooglePayButton, d as confirmPaymentIntent, f as confirmSetupIntent, u as validateForm };
170
+ export { b as AmosApplePayButton, v as AmosBankAccountPaymentMethodForm, _ as AmosCreditCardPaymentMethodForm, y as AmosGooglePayButton, f as confirmPaymentIntent, p as confirmSetupIntent, d as validateForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -46,7 +46,7 @@
46
46
  "vite-plugin-dts": "5.0.3"
47
47
  },
48
48
  "dependencies": {
49
- "@amos.com/amos-js": "0.4.0",
49
+ "@amos.com/amos-js": "0.5.0",
50
50
  "@amos.com/node": "0.1.31",
51
51
  "@types/googlepay": "0.7.11"
52
52
  },
package/src/index.tsx CHANGED
@@ -7,6 +7,7 @@ import {
7
7
  validateForm as amosValidateForm,
8
8
  type BillingAddressRequirement,
9
9
  type CreditCardAdditionalFields,
10
+ mountAmosApplePayButton,
10
11
  mountAmosBankAccountPaymentMethodForm,
11
12
  mountAmosCreditCardPaymentMethodForm,
12
13
  mountAmosGooglePayButton,
@@ -199,7 +200,7 @@ export function AmosCreditCardPaymentMethodForm({
199
200
  onSetupIntentConfirmationSucceeded,
200
201
  onConfirmationFailed,
201
202
  additionalFields = { cardholderName: false },
202
- billingAddressRequirement = "postalCode",
203
+ billingAddressRequirement = "country",
203
204
  style,
204
205
  ...rest
205
206
  }: AmosCreditCardPaymentMethodFormProps) {
@@ -257,7 +258,7 @@ export function AmosBankAccountPaymentMethodForm({
257
258
  onPaymentIntentConfirmationSucceeded,
258
259
  onSetupIntentConfirmationSucceeded,
259
260
  onConfirmationFailed,
260
- billingAddressRequirement = "postalCode",
261
+ billingAddressRequirement = "country",
261
262
  style,
262
263
  ...rest
263
264
  }: AmosBankAccountPaymentMethodFormProps) {
@@ -348,3 +349,63 @@ export function AmosGooglePayButton({
348
349
 
349
350
  return <div ref={containerRef} />;
350
351
  }
352
+
353
+ type AmosApplePayButtonProps = IframePassthroughProps & {
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
+ onPaymentIntentConfirmationSucceeded: (
366
+ paymentIntent: components["schemas"]["PaymentIntent"],
367
+ ) => void;
368
+ onConfirmationFailed: (errorMessage: string) => void;
369
+ };
370
+
371
+ export function AmosApplePayButton({
372
+ ref,
373
+ renderToken,
374
+ amount,
375
+ merchantName,
376
+ appearance,
377
+ onInitiatePaymentIntentRequest,
378
+ onPaymentIntentConfirmationSucceeded,
379
+ onConfirmationFailed,
380
+ style,
381
+ ...rest
382
+ }: AmosApplePayButtonProps) {
383
+ const containerRef = useRef<HTMLDivElement | null>(null);
384
+
385
+ useAmosEmbed({
386
+ containerRef,
387
+ iframeRef: ref as ForwardedIframeRef,
388
+ mount: mountAmosApplePayButton,
389
+ options: {
390
+ renderToken,
391
+ amount,
392
+ merchantName,
393
+ appearance,
394
+ onInitiatePaymentIntentRequest,
395
+ onPaymentIntentConfirmationSucceeded,
396
+ onConfirmationFailed,
397
+ },
398
+ remountDeps: [renderToken],
399
+ iframePassthrough: { style, ...rest },
400
+ updateDeps: [
401
+ amount,
402
+ merchantName,
403
+ appearance,
404
+ onInitiatePaymentIntentRequest,
405
+ onPaymentIntentConfirmationSucceeded,
406
+ onConfirmationFailed,
407
+ ],
408
+ });
409
+
410
+ return <div ref={containerRef} />;
411
+ }