@amos.com/react-amos-js 0.3.13 → 0.3.15
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.d.ts +1 -2
- package/dist/index.js +1 -1
- package/dist/index.mjs +67 -66
- package/package.json +3 -3
- package/src/index.tsx +1 -21
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,7 @@
|
|
|
2
2
|
import { Appearance, CreditCardAdditionalFields } from '@amos.com/amos-js';
|
|
3
3
|
import { components } from '@amos.com/node';
|
|
4
4
|
import { ComponentProps, RefObject } from 'react';
|
|
5
|
-
export
|
|
6
|
-
export { createMessage, decodeJwt, formatGooglePayPaymentData, getEmbedOrigin, } from '@amos.com/amos-js';
|
|
5
|
+
export * from '@amos.com/amos-js';
|
|
7
6
|
type IframeRef = RefObject<HTMLIFrameElement | null> | undefined;
|
|
8
7
|
/**
|
|
9
8
|
* Validate the embedded card/bank iframe form before payment
|
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},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.
|
|
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,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,131 +1,132 @@
|
|
|
1
|
-
import { confirmPaymentIntent as e, confirmSetupIntent as t,
|
|
2
|
-
import { useEffect as
|
|
3
|
-
import { jsx as
|
|
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";
|
|
4
|
+
export * from "@amos.com/amos-js";
|
|
4
5
|
//#region src/index.tsx
|
|
5
|
-
function
|
|
6
|
+
function l(e) {
|
|
6
7
|
return e ? e.current ?? null : null;
|
|
7
8
|
}
|
|
8
|
-
function
|
|
9
|
-
return
|
|
9
|
+
function u({ iframeRef: e }) {
|
|
10
|
+
return a({ iframe: l(e) });
|
|
10
11
|
}
|
|
11
|
-
function
|
|
12
|
+
function d({ iframeRef: t, token: n }) {
|
|
12
13
|
e({
|
|
13
|
-
iframe:
|
|
14
|
+
iframe: l(t),
|
|
14
15
|
token: n
|
|
15
16
|
});
|
|
16
17
|
}
|
|
17
|
-
function
|
|
18
|
+
function f({ iframeRef: e, token: n }) {
|
|
18
19
|
t({
|
|
19
|
-
iframe:
|
|
20
|
+
iframe: l(e),
|
|
20
21
|
token: n
|
|
21
22
|
});
|
|
22
23
|
}
|
|
23
|
-
function
|
|
24
|
+
function p(e, t) {
|
|
24
25
|
typeof e == "function" ? e(t) : e && (e.current = t);
|
|
25
26
|
}
|
|
26
|
-
function
|
|
27
|
+
function m(e, { style: t, className: n, id: r, ...i }) {
|
|
27
28
|
n != null && (e.className = n), r != null && (e.id = r), t != null && Object.assign(e.style, t);
|
|
28
29
|
for (let [t, n] of Object.entries(i)) n != null && (t in e ? Reflect.set(e, t, n) : e.setAttribute(t, String(n)));
|
|
29
30
|
}
|
|
30
|
-
function
|
|
31
|
-
let
|
|
32
|
-
|
|
31
|
+
function h({ containerRef: e, iframeRef: t, mount: n, options: r, remountDeps: i, iframePassthrough: a, updateDeps: c }) {
|
|
32
|
+
let l = s(null);
|
|
33
|
+
o(() => {
|
|
33
34
|
let i = e.current;
|
|
34
35
|
if (!i) return;
|
|
35
36
|
let o = n(i, r);
|
|
36
|
-
return
|
|
37
|
-
o.destroy(),
|
|
37
|
+
return l.current = o, p(t, o.iframe), m(o.iframe, a), () => {
|
|
38
|
+
o.destroy(), l.current = null, p(t, null);
|
|
38
39
|
};
|
|
39
|
-
}, [...i]),
|
|
40
|
-
|
|
41
|
-
}, [...
|
|
42
|
-
let e =
|
|
43
|
-
e &&
|
|
40
|
+
}, [...i]), o(() => {
|
|
41
|
+
l.current?.update(r);
|
|
42
|
+
}, [...c]), o(() => {
|
|
43
|
+
let e = l.current?.iframe;
|
|
44
|
+
e && m(e, a);
|
|
44
45
|
});
|
|
45
46
|
}
|
|
46
|
-
function
|
|
47
|
-
let
|
|
48
|
-
return
|
|
49
|
-
containerRef:
|
|
47
|
+
function g({ ref: e, renderToken: t, appearance: n, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, additionalFields: l = { cardholderName: !1 }, style: u, ...d }) {
|
|
48
|
+
let f = s(null);
|
|
49
|
+
return h({
|
|
50
|
+
containerRef: f,
|
|
50
51
|
iframeRef: e,
|
|
51
|
-
mount:
|
|
52
|
+
mount: r,
|
|
52
53
|
options: {
|
|
53
54
|
renderToken: t,
|
|
54
55
|
appearance: n,
|
|
55
|
-
additionalFields:
|
|
56
|
-
onPaymentIntentConfirmationSucceeded:
|
|
57
|
-
onSetupIntentConfirmationSucceeded:
|
|
58
|
-
onConfirmationFailed:
|
|
56
|
+
additionalFields: l,
|
|
57
|
+
onPaymentIntentConfirmationSucceeded: i,
|
|
58
|
+
onSetupIntentConfirmationSucceeded: a,
|
|
59
|
+
onConfirmationFailed: o
|
|
59
60
|
},
|
|
60
|
-
remountDeps: [t,
|
|
61
|
+
remountDeps: [t, l.cardholderName],
|
|
61
62
|
iframePassthrough: {
|
|
62
|
-
style:
|
|
63
|
-
...
|
|
63
|
+
style: u,
|
|
64
|
+
...d
|
|
64
65
|
},
|
|
65
66
|
updateDeps: [
|
|
66
67
|
n,
|
|
67
|
-
|
|
68
|
-
r,
|
|
68
|
+
l,
|
|
69
69
|
i,
|
|
70
|
-
a
|
|
70
|
+
a,
|
|
71
|
+
o
|
|
71
72
|
]
|
|
72
|
-
}), /* @__PURE__ */
|
|
73
|
+
}), /* @__PURE__ */ c("div", { ref: f });
|
|
73
74
|
}
|
|
74
|
-
function
|
|
75
|
-
let
|
|
76
|
-
return
|
|
77
|
-
containerRef:
|
|
75
|
+
function _({ ref: e, renderToken: t, appearance: r, onPaymentIntentConfirmationSucceeded: i, onSetupIntentConfirmationSucceeded: a, onConfirmationFailed: o, style: l, ...u }) {
|
|
76
|
+
let d = s(null);
|
|
77
|
+
return h({
|
|
78
|
+
containerRef: d,
|
|
78
79
|
iframeRef: e,
|
|
79
|
-
mount:
|
|
80
|
+
mount: n,
|
|
80
81
|
options: {
|
|
81
82
|
renderToken: t,
|
|
82
|
-
appearance:
|
|
83
|
-
onPaymentIntentConfirmationSucceeded:
|
|
84
|
-
onSetupIntentConfirmationSucceeded:
|
|
85
|
-
onConfirmationFailed:
|
|
83
|
+
appearance: r,
|
|
84
|
+
onPaymentIntentConfirmationSucceeded: i,
|
|
85
|
+
onSetupIntentConfirmationSucceeded: a,
|
|
86
|
+
onConfirmationFailed: o
|
|
86
87
|
},
|
|
87
88
|
remountDeps: [t],
|
|
88
89
|
iframePassthrough: {
|
|
89
|
-
style:
|
|
90
|
-
...
|
|
90
|
+
style: l,
|
|
91
|
+
...u
|
|
91
92
|
},
|
|
92
93
|
updateDeps: [
|
|
93
|
-
n,
|
|
94
94
|
r,
|
|
95
95
|
i,
|
|
96
|
-
a
|
|
96
|
+
a,
|
|
97
|
+
o
|
|
97
98
|
]
|
|
98
|
-
}), /* @__PURE__ */
|
|
99
|
+
}), /* @__PURE__ */ c("div", { ref: d });
|
|
99
100
|
}
|
|
100
|
-
function
|
|
101
|
-
let p =
|
|
102
|
-
return
|
|
101
|
+
function v({ ref: e, renderToken: t, amount: n, merchantName: r, appearance: a, onInitiatePaymentIntentRequest: o, onPaymentIntentConfirmationSucceeded: l, onConfirmationFailed: u, style: d, ...f }) {
|
|
102
|
+
let p = s(null);
|
|
103
|
+
return h({
|
|
103
104
|
containerRef: p,
|
|
104
105
|
iframeRef: e,
|
|
105
|
-
mount:
|
|
106
|
+
mount: i,
|
|
106
107
|
options: {
|
|
107
108
|
renderToken: t,
|
|
108
109
|
amount: n,
|
|
109
110
|
merchantName: r,
|
|
110
|
-
appearance:
|
|
111
|
-
onInitiatePaymentIntentRequest:
|
|
112
|
-
onPaymentIntentConfirmationSucceeded:
|
|
113
|
-
onConfirmationFailed:
|
|
111
|
+
appearance: a,
|
|
112
|
+
onInitiatePaymentIntentRequest: o,
|
|
113
|
+
onPaymentIntentConfirmationSucceeded: l,
|
|
114
|
+
onConfirmationFailed: u
|
|
114
115
|
},
|
|
115
116
|
remountDeps: [t],
|
|
116
117
|
iframePassthrough: {
|
|
117
|
-
style:
|
|
118
|
-
...
|
|
118
|
+
style: d,
|
|
119
|
+
...f
|
|
119
120
|
},
|
|
120
121
|
updateDeps: [
|
|
121
122
|
n,
|
|
122
123
|
r,
|
|
123
|
-
i,
|
|
124
124
|
a,
|
|
125
125
|
o,
|
|
126
|
-
|
|
126
|
+
l,
|
|
127
|
+
u
|
|
127
128
|
]
|
|
128
|
-
}), /* @__PURE__ */
|
|
129
|
+
}), /* @__PURE__ */ c("div", { ref: p });
|
|
129
130
|
}
|
|
130
131
|
//#endregion
|
|
131
|
-
export {
|
|
132
|
+
export { _ as AmosBankAccountPaymentMethodForm, g as AmosCreditCardPaymentMethodForm, v as AmosGooglePayButton, d as confirmPaymentIntent, f as confirmSetupIntent, u as validateForm };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@amos.com/react-amos-js",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.15",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"vite-plugin-dts": "5.0.2"
|
|
45
45
|
},
|
|
46
46
|
"dependencies": {
|
|
47
|
-
"@amos.com/amos-js": "0.3.
|
|
48
|
-
"@amos.com/node": "0.1.
|
|
47
|
+
"@amos.com/amos-js": "0.3.18",
|
|
48
|
+
"@amos.com/node": "0.1.22",
|
|
49
49
|
"@types/googlepay": "0.7.11"
|
|
50
50
|
},
|
|
51
51
|
"peerDependencies": {
|
package/src/index.tsx
CHANGED
|
@@ -19,27 +19,7 @@ import {
|
|
|
19
19
|
useRef,
|
|
20
20
|
} from "react";
|
|
21
21
|
|
|
22
|
-
export
|
|
23
|
-
Appearance,
|
|
24
|
-
AppearanceLabels,
|
|
25
|
-
CreateCustomerInput,
|
|
26
|
-
CreatePaymentIntentInput,
|
|
27
|
-
CreateSetupIntentInput,
|
|
28
|
-
CreditCardAdditionalFields,
|
|
29
|
-
EmbedToken,
|
|
30
|
-
EmbedTokenJwt,
|
|
31
|
-
Message,
|
|
32
|
-
PaymentIntent,
|
|
33
|
-
RenderTokenJwt,
|
|
34
|
-
SetupIntent,
|
|
35
|
-
ThemeVariable,
|
|
36
|
-
} from "@amos.com/amos-js";
|
|
37
|
-
export {
|
|
38
|
-
createMessage,
|
|
39
|
-
decodeJwt,
|
|
40
|
-
formatGooglePayPaymentData,
|
|
41
|
-
getEmbedOrigin,
|
|
42
|
-
} from "@amos.com/amos-js";
|
|
22
|
+
export * from "@amos.com/amos-js";
|
|
43
23
|
|
|
44
24
|
type IframeRef = RefObject<HTMLIFrameElement | null> | undefined;
|
|
45
25
|
|