@amos.com/react-amos-js 0.3.4 → 0.3.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/dist/index.js CHANGED
@@ -1 +1 @@
1
- "use strict";var A=Object.defineProperty;var o=(e,t)=>A(e,"name",{value:t,configurable:!0});Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g=require("react/jsx-runtime"),l=require("@amos.com/amos-js"),i=require("react");function y(e){return e?e.current??null:null}o(y,"resolveIframe");function h({iframeRef:e}){return l.validateForm({iframe:y(e)})}o(h,"validateForm");function j({iframeRef:e,token:t}){l.confirmPaymentIntent({iframe:y(e),token:t})}o(j,"confirmPaymentIntent");function R({iframeRef:e,token:t}){l.confirmSetupIntent({iframe:y(e),token:t})}o(R,"confirmSetupIntent");function b(e,t){typeof e=="function"?e(t):e&&(e.current=t)}o(b,"setForwardedRef");function p(e,{style:t,className:s,id:n,...f}){s!=null&&(e.className=s),n!=null&&(e.id=n),t!=null&&Object.assign(e.style,t);for(const[r,u]of Object.entries(f))u!=null&&(r in e?Reflect.set(e,r,u):e.setAttribute(r,String(u)))}o(p,"applyIframePassthrough");function P({containerRef:e,iframeRef:t,mount:s,options:n,remountDeps:f,iframePassthrough:r,updateDeps:u}){const m=i.useRef(null);i.useEffect(()=>{const c=e.current;if(!c)return;const a=s(c,n);return m.current=a,b(t,a.iframe),p(a.iframe,r),()=>{a.destroy(),m.current=null,b(t,null)}},[...f]),i.useEffect(()=>{m.current?.update(n)},[...u]),i.useEffect(()=>{const c=m.current?.iframe;c&&p(c,r)})}o(P,"useAmosEmbed");function v({ref:e,renderToken:t,appearance:s,onPaymentIntentConfirmationSucceeded:n,onSetupIntentConfirmationSucceeded:f,onConfirmationFailed:r,additionalFields:u={cardholderName:!1},style:m,...c}){const a=i.useRef(null);return P({containerRef:a,iframeRef:e,mount:l.mountAmosCreditCardPaymentMethodForm,options:{renderToken:t,appearance:s,additionalFields:u,onPaymentIntentConfirmationSucceeded:n,onSetupIntentConfirmationSucceeded:f,onConfirmationFailed:r},remountDeps:[t,u.cardholderName],iframePassthrough:{style:m,...c},updateDeps:[s,u,n,f,r]}),g.jsx("div",{ref:a})}o(v,"AmosCreditCardPaymentMethodForm");function M({ref:e,renderToken:t,appearance:s,onPaymentIntentConfirmationSucceeded:n,onSetupIntentConfirmationSucceeded:f,onConfirmationFailed:r,style:u,...m}){const c=i.useRef(null);return P({containerRef:c,iframeRef:e,mount:l.mountAmosBankAccountPaymentMethodForm,options:{renderToken:t,appearance:s,onPaymentIntentConfirmationSucceeded:n,onSetupIntentConfirmationSucceeded:f,onConfirmationFailed:r},remountDeps:[t],iframePassthrough:{style:u,...m},updateDeps:[s,n,f,r]}),g.jsx("div",{ref:c})}o(M,"AmosBankAccountPaymentMethodForm");function O({ref:e,renderToken:t,amount:s,merchantName:n,appearance:f,onInitiatePaymentIntentRequest:r,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:m,style:c,...a}){const d=i.useRef(null);return P({containerRef:d,iframeRef:e,mount:l.mountAmosGooglePayButton,options:{renderToken:t,amount:s,merchantName:n,appearance:f,onInitiatePaymentIntentRequest:r,onPaymentIntentConfirmationSucceeded:u,onConfirmationFailed:m},remountDeps:[t],iframePassthrough:{style:c,...a},updateDeps:[s,n,f,r,u,m]}),g.jsx("div",{ref:d})}o(O,"AmosGooglePayButton");Object.defineProperty(exports,"createMessage",{enumerable:!0,get:o(()=>l.createMessage,"get")});Object.defineProperty(exports,"decodeJwt",{enumerable:!0,get:o(()=>l.decodeJwt,"get")});Object.defineProperty(exports,"formatGooglePayPaymentData",{enumerable:!0,get:o(()=>l.formatGooglePayPaymentData,"get")});Object.defineProperty(exports,"getEmbedOrigin",{enumerable:!0,get:o(()=>l.getEmbedOrigin,"get")});exports.AmosBankAccountPaymentMethodForm=M;exports.AmosCreditCardPaymentMethodForm=v;exports.AmosGooglePayButton=O;exports.confirmPaymentIntent=j;exports.confirmSetupIntent=R;exports.validateForm=h;
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},style:d,...f}){let p=(0,t.useRef)(null);return l({containerRef:p,iframeRef:r,mount:e.mountAmosCreditCardPaymentMethodForm,options:{renderToken:i,appearance:a,additionalFields:u,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i,u.cardholderName],iframePassthrough:{style:d,...f},updateDeps:[a,u,o,s,c]}),(0,n.jsx)(`div`,{ref:p})}function d({ref:r,renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c,style:u,...d}){let f=(0,t.useRef)(null);return l({containerRef:f,iframeRef:r,mount:e.mountAmosBankAccountPaymentMethodForm,options:{renderToken:i,appearance:a,onPaymentIntentConfirmationSucceeded:o,onSetupIntentConfirmationSucceeded:s,onConfirmationFailed:c},remountDeps:[i],iframePassthrough:{style:u,...d},updateDeps:[a,o,s,c]}),(0,n.jsx)(`div`,{ref:f})}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,Object.defineProperty(exports,"createMessage",{enumerable:!0,get:function(){return e.createMessage}}),Object.defineProperty(exports,"decodeJwt",{enumerable:!0,get:function(){return e.decodeJwt}}),Object.defineProperty(exports,"formatGooglePayPaymentData",{enumerable:!0,get:function(){return e.formatGooglePayPaymentData}}),Object.defineProperty(exports,"getEmbedOrigin",{enumerable:!0,get:function(){return e.getEmbedOrigin}}),exports.validateForm=i;
package/dist/index.mjs CHANGED
@@ -1,186 +1,131 @@
1
- var v = Object.defineProperty;
2
- var c = (t, r) => v(t, "name", { value: r, configurable: !0 });
3
- import { jsx as p } from "react/jsx-runtime";
4
- import { validateForm as D, confirmPaymentIntent as R, confirmSetupIntent as d, mountAmosCreditCardPaymentMethodForm as b, mountAmosBankAccountPaymentMethodForm as M, mountAmosGooglePayButton as B } from "@amos.com/amos-js";
5
- import { createMessage as z, decodeJwt as H, formatGooglePayPaymentData as K, getEmbedOrigin as L } from "@amos.com/amos-js";
6
- import { useRef as i, useEffect as a } from "react";
7
- function g(t) {
8
- return t ? t.current ?? null : null;
1
+ import { confirmPaymentIntent as e, confirmSetupIntent as t, createMessage as n, decodeJwt as r, formatGooglePayPaymentData as i, getEmbedOrigin as a, mountAmosBankAccountPaymentMethodForm as o, mountAmosCreditCardPaymentMethodForm as s, mountAmosGooglePayButton as c, validateForm as l } from "@amos.com/amos-js";
2
+ import { useEffect as u, useRef as d } from "react";
3
+ import { jsx as f } from "react/jsx-runtime";
4
+ //#region src/index.tsx
5
+ function p(e) {
6
+ return e ? e.current ?? null : null;
9
7
  }
10
- c(g, "resolveIframe");
11
- function G({
12
- iframeRef: t
13
- }) {
14
- return D({ iframe: g(t) });
8
+ function m({ iframeRef: e }) {
9
+ return l({ iframe: p(e) });
15
10
  }
16
- c(G, "validateForm");
17
- function O({
18
- iframeRef: t,
19
- token: r
20
- }) {
21
- R({ iframe: g(t), token: r });
11
+ function h({ iframeRef: t, token: n }) {
12
+ e({
13
+ iframe: p(t),
14
+ token: n
15
+ });
22
16
  }
23
- c(O, "confirmPaymentIntent");
24
- function $({
25
- iframeRef: t,
26
- token: r
27
- }) {
28
- d({ iframe: g(t), token: r });
17
+ function g({ iframeRef: e, token: n }) {
18
+ t({
19
+ iframe: p(e),
20
+ token: n
21
+ });
29
22
  }
30
- c($, "confirmSetupIntent");
31
- function A(t, r) {
32
- typeof t == "function" ? t(r) : t && (t.current = r);
23
+ function _(e, t) {
24
+ typeof e == "function" ? e(t) : e && (e.current = t);
33
25
  }
34
- c(A, "setForwardedRef");
35
- function P(t, { style: r, className: u, id: o, ...s }) {
36
- u != null && (t.className = u), o != null && (t.id = o), r != null && Object.assign(t.style, r);
37
- for (const [e, n] of Object.entries(s))
38
- n != null && (e in t ? Reflect.set(t, e, n) : t.setAttribute(e, String(n)));
26
+ function v(e, { style: t, className: n, id: r, ...i }) {
27
+ n != null && (e.className = n), r != null && (e.id = r), t != null && Object.assign(e.style, t);
28
+ for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
39
29
  }
40
- c(P, "applyIframePassthrough");
41
- function h({
42
- containerRef: t,
43
- iframeRef: r,
44
- mount: u,
45
- options: o,
46
- remountDeps: s,
47
- iframePassthrough: e,
48
- updateDeps: n
49
- }) {
50
- const m = i(null);
51
- a(() => {
52
- const f = t.current;
53
- if (!f)
54
- return;
55
- const l = u(f, o);
56
- return m.current = l, A(r, l.iframe), P(l.iframe, e), () => {
57
- l.destroy(), m.current = null, A(r, null);
58
- };
59
- }, [...s]), a(() => {
60
- m.current?.update(o);
61
- }, [...n]), a(() => {
62
- const f = m.current?.iframe;
63
- f && P(f, e);
64
- });
30
+ function y({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: o }) {
31
+ let s = d(null);
32
+ u(() => {
33
+ let i = e.current;
34
+ if (!i) return;
35
+ let o = n(i, r);
36
+ return s.current = o, _(t, o.iframe), v(o.iframe, a), () => {
37
+ o.destroy(), s.current = null, _(t, null);
38
+ };
39
+ }, [...i]), u(() => {
40
+ s.current?.update(r);
41
+ }, [...o]), u(() => {
42
+ let e = s.current?.iframe;
43
+ e && v(e, a);
44
+ });
65
45
  }
66
- c(h, "useAmosEmbed");
67
- function w({
68
- ref: t,
69
- renderToken: r,
70
- appearance: u,
71
- onPaymentIntentConfirmationSucceeded: o,
72
- onSetupIntentConfirmationSucceeded: s,
73
- onConfirmationFailed: e,
74
- additionalFields: n = { cardholderName: !1 },
75
- style: m,
76
- ...f
77
- }) {
78
- const l = i(null);
79
- return h({
80
- containerRef: l,
81
- iframeRef: t,
82
- mount: b,
83
- options: {
84
- renderToken: r,
85
- appearance: u,
86
- additionalFields: n,
87
- onPaymentIntentConfirmationSucceeded: o,
88
- onSetupIntentConfirmationSucceeded: s,
89
- onConfirmationFailed: e
90
- },
91
- remountDeps: [r, n.cardholderName],
92
- iframePassthrough: { style: m, ...f },
93
- updateDeps: [
94
- u,
95
- n,
96
- o,
97
- s,
98
- e
99
- ]
100
- }), /* @__PURE__ */ p("div", { ref: l });
46
+ function b({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: r, onSetupIntentConfirmationSucceeded: i, onConfirmationFailed: a, additionalFields: o = { cardholderName: !1 }, style: c, ...l }) {
47
+ let u = d(null);
48
+ return y({
49
+ containerRef: u,
50
+ iframeRef: e,
51
+ mount: s,
52
+ options: {
53
+ renderToken: t,
54
+ appearance: n,
55
+ additionalFields: o,
56
+ onPaymentIntentConfirmationSucceeded: r,
57
+ onSetupIntentConfirmationSucceeded: i,
58
+ onConfirmationFailed: a
59
+ },
60
+ remountDeps: [t, o.cardholderName],
61
+ iframePassthrough: {
62
+ style: c,
63
+ ...l
64
+ },
65
+ updateDeps: [
66
+ n,
67
+ o,
68
+ r,
69
+ i,
70
+ a
71
+ ]
72
+ }), /* @__PURE__ */ f("div", { ref: u });
101
73
  }
102
- c(w, "AmosCreditCardPaymentMethodForm");
103
- function I({
104
- ref: t,
105
- renderToken: r,
106
- appearance: u,
107
- onPaymentIntentConfirmationSucceeded: o,
108
- onSetupIntentConfirmationSucceeded: s,
109
- onConfirmationFailed: e,
110
- style: n,
111
- ...m
112
- }) {
113
- const f = i(null);
114
- return h({
115
- containerRef: f,
116
- iframeRef: t,
117
- mount: M,
118
- options: {
119
- renderToken: r,
120
- appearance: u,
121
- onPaymentIntentConfirmationSucceeded: o,
122
- onSetupIntentConfirmationSucceeded: s,
123
- onConfirmationFailed: e
124
- },
125
- remountDeps: [r],
126
- iframePassthrough: { style: n, ...m },
127
- updateDeps: [
128
- u,
129
- o,
130
- s,
131
- e
132
- ]
133
- }), /* @__PURE__ */ p("div", { ref: f });
74
+ function x({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: r, onSetupIntentConfirmationSucceeded: i, onConfirmationFailed: a, style: s, ...c }) {
75
+ let l = d(null);
76
+ return y({
77
+ containerRef: l,
78
+ iframeRef: e,
79
+ mount: o,
80
+ options: {
81
+ renderToken: t,
82
+ appearance: n,
83
+ onPaymentIntentConfirmationSucceeded: r,
84
+ onSetupIntentConfirmationSucceeded: i,
85
+ onConfirmationFailed: a
86
+ },
87
+ remountDeps: [t],
88
+ iframePassthrough: {
89
+ style: s,
90
+ ...c
91
+ },
92
+ updateDeps: [
93
+ n,
94
+ r,
95
+ i,
96
+ a
97
+ ]
98
+ }), /* @__PURE__ */ f("div", { ref: l });
134
99
  }
135
- c(I, "AmosBankAccountPaymentMethodForm");
136
- function J({
137
- ref: t,
138
- renderToken: r,
139
- amount: u,
140
- merchantName: o,
141
- appearance: s,
142
- onInitiatePaymentIntentRequest: e,
143
- onPaymentIntentConfirmationSucceeded: n,
144
- onConfirmationFailed: m,
145
- style: f,
146
- ...l
147
- }) {
148
- const y = i(null);
149
- return h({
150
- containerRef: y,
151
- iframeRef: t,
152
- mount: B,
153
- options: {
154
- renderToken: r,
155
- amount: u,
156
- merchantName: o,
157
- appearance: s,
158
- onInitiatePaymentIntentRequest: e,
159
- onPaymentIntentConfirmationSucceeded: n,
160
- onConfirmationFailed: m
161
- },
162
- remountDeps: [r],
163
- iframePassthrough: { style: f, ...l },
164
- updateDeps: [
165
- u,
166
- o,
167
- s,
168
- e,
169
- n,
170
- m
171
- ]
172
- }), /* @__PURE__ */ p("div", { ref: y });
100
+ function S({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: i, onInitiatePaymentIntentRequest: a, onPaymentIntentConfirmationSucceeded: o, onConfirmationFailed: s, style: l, ...u }) {
101
+ let p = d(null);
102
+ return y({
103
+ containerRef: p,
104
+ iframeRef: e,
105
+ mount: c,
106
+ options: {
107
+ renderToken: t,
108
+ amount: n,
109
+ merchantName: r,
110
+ appearance: i,
111
+ onInitiatePaymentIntentRequest: a,
112
+ onPaymentIntentConfirmationSucceeded: o,
113
+ onConfirmationFailed: s
114
+ },
115
+ remountDeps: [t],
116
+ iframePassthrough: {
117
+ style: l,
118
+ ...u
119
+ },
120
+ updateDeps: [
121
+ n,
122
+ r,
123
+ i,
124
+ a,
125
+ o,
126
+ s
127
+ ]
128
+ }), /* @__PURE__ */ f("div", { ref: p });
173
129
  }
174
- c(J, "AmosGooglePayButton");
175
- export {
176
- I as AmosBankAccountPaymentMethodForm,
177
- w as AmosCreditCardPaymentMethodForm,
178
- J as AmosGooglePayButton,
179
- O as confirmPaymentIntent,
180
- $ as confirmSetupIntent,
181
- z as createMessage,
182
- H as decodeJwt,
183
- K as formatGooglePayPaymentData,
184
- L as getEmbedOrigin,
185
- G as validateForm
186
- };
130
+ //#endregion
131
+ export { x as AmosBankAccountPaymentMethodForm, b as AmosCreditCardPaymentMethodForm, S as AmosGooglePayButton, h as confirmPaymentIntent, g as confirmSetupIntent, n as createMessage, r as decodeJwt, i as formatGooglePayPaymentData, a as getEmbedOrigin, m as validateForm };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@amos.com/react-amos-js",
3
- "version": "0.3.4",
3
+ "version": "0.3.6",
4
4
  "main": "dist/index.js",
5
5
  "repository": {
6
6
  "type": "git",
@@ -40,12 +40,12 @@
40
40
  "@types/node": "25.9.1",
41
41
  "@types/react": "19.2.15",
42
42
  "typescript": "6.0.3",
43
- "vite": "7.3.3",
43
+ "vite": "8.0.16",
44
44
  "vite-plugin-dts": "4.5.4"
45
45
  },
46
46
  "dependencies": {
47
- "@amos.com/amos-js": "0.3.4",
48
- "@amos.com/node": "0.1.9",
47
+ "@amos.com/amos-js": "0.3.6",
48
+ "@amos.com/node": "0.1.11",
49
49
  "@types/googlepay": "0.7.10"
50
50
  },
51
51
  "peerDependencies": {