htech-pay 0.0.6-beta → 0.0.7-beta
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/htechPay.mjs +36 -34
- package/dist/htechPay.umd.js +1 -1
- package/package.json +1 -1
package/dist/htechPay.mjs
CHANGED
|
@@ -1,45 +1,47 @@
|
|
|
1
1
|
/*! HtechPay | MIT License */
|
|
2
|
-
async function b(
|
|
2
|
+
async function b(h, w = {}) {
|
|
3
3
|
const {
|
|
4
|
-
environment:
|
|
5
|
-
onViewForm:
|
|
6
|
-
onPaymentResult:
|
|
7
|
-
theme:
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
environment: i = "qa",
|
|
5
|
+
onViewForm: c,
|
|
6
|
+
onPaymentResult: p,
|
|
7
|
+
theme: P = "",
|
|
8
|
+
on3dsChallengeOpen: g,
|
|
9
|
+
onProcessPayment: y,
|
|
10
|
+
onNeedCvv: f
|
|
11
|
+
} = w;
|
|
12
|
+
let { type: o } = w;
|
|
13
|
+
const s = {
|
|
13
14
|
//qa: "http://localhost:5173",
|
|
14
15
|
qa: "https://sp-checkout-qa.pagoshtechstage.com/index.html",
|
|
15
16
|
stage: "https://sp-checkout-stage.pagoshtechstage.com/index.html",
|
|
16
17
|
prod: "https://sp-checkout.pagoshtech.com/index.html"
|
|
17
18
|
};
|
|
18
19
|
let a = null;
|
|
19
|
-
const
|
|
20
|
+
const l = {
|
|
20
21
|
defaultUrl: {
|
|
21
|
-
url: `${i
|
|
22
|
-
height: "
|
|
22
|
+
url: `${s[i]}?orderId=${h}&theme=${P}`,
|
|
23
|
+
height: "670",
|
|
23
24
|
style: "display"
|
|
24
25
|
},
|
|
25
26
|
widget: {
|
|
26
|
-
url: `${i
|
|
27
|
+
url: `${s[i]}?orderId=${h}#/widget`,
|
|
27
28
|
height: "88",
|
|
28
29
|
style: ""
|
|
29
30
|
},
|
|
30
31
|
paymentToken: {
|
|
31
|
-
url: `${i
|
|
32
|
+
url: `${s[i]}?orderId=${h}&theme=${P}#/paymentToken`,
|
|
32
33
|
height: "520",
|
|
33
34
|
style: "display:none"
|
|
34
35
|
}
|
|
35
36
|
};
|
|
36
|
-
|
|
37
|
+
l[o] || (o = "defaultUrl");
|
|
38
|
+
let m = null, d = null, u = null, v = !1;
|
|
37
39
|
const n = document.createElement("iframe");
|
|
38
|
-
n.id = "iframe_htechPay", n.src =
|
|
40
|
+
n.id = "iframe_htechPay", n.src = l[o].url, n.width = "100%", n.height = l[o].height, n.frameBorder = "0", n.allowFullscreen = !0, n.title = "Payment form", n.style = l[o].style;
|
|
39
41
|
const C = () => new Promise((e, t) => {
|
|
40
42
|
m = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
|
|
41
43
|
"htechPayment_onPayment",
|
|
42
|
-
new URL(i
|
|
44
|
+
new URL(s[i]).origin
|
|
43
45
|
), setTimeout(() => {
|
|
44
46
|
v || e({
|
|
45
47
|
status: "validation_error",
|
|
@@ -48,49 +50,49 @@ async function b(u, x = {}) {
|
|
|
48
50
|
}, 600);
|
|
49
51
|
}), $ = () => new Promise((e) => {
|
|
50
52
|
const t = (r) => {
|
|
51
|
-
|
|
53
|
+
o === "paymentToken" && r && (n.style = ""), e({ needCvv: r });
|
|
52
54
|
};
|
|
53
55
|
if (a !== null) {
|
|
54
56
|
t(a);
|
|
55
57
|
return;
|
|
56
58
|
}
|
|
57
|
-
|
|
59
|
+
u = (r) => {
|
|
58
60
|
t(r.needCvv);
|
|
59
61
|
};
|
|
60
62
|
}), _ = () => new Promise((e, t) => {
|
|
61
|
-
|
|
63
|
+
d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
|
|
62
64
|
"htechPayment_onValidateForm",
|
|
63
|
-
new URL(i
|
|
65
|
+
new URL(s[i]).origin
|
|
64
66
|
), setTimeout(() => {
|
|
65
67
|
v || e({
|
|
66
68
|
status: "validation_error",
|
|
67
69
|
message: "Unknown error"
|
|
68
70
|
});
|
|
69
71
|
}, 600);
|
|
70
|
-
}),
|
|
71
|
-
onViewForm: () =>
|
|
72
|
+
}), k = {
|
|
73
|
+
onViewForm: () => c == null ? void 0 : c(!0),
|
|
72
74
|
onPaymentResult: (e) => {
|
|
73
75
|
const t = e.data.payload || {};
|
|
74
|
-
return m && (m(t), m = null),
|
|
76
|
+
return m && (m(t), m = null), p == null ? void 0 : p(t);
|
|
75
77
|
},
|
|
76
|
-
on3dsChallengeOpen: (e) => (e.isOpen && (n.style = "position: fixed !important; z-inde: 2147483647 !important; background: rgba(40, 40, 40, 0.75) !important; transition: background 400ms !important; will-change: background !important; inset: 0px !important; margin: 0px !important; padding: 0px !important; border-radius: 0px; height:100vh"), e.isOpen || (n.style = ""),
|
|
77
|
-
onProcessPayment: () => (v = !0,
|
|
78
|
+
on3dsChallengeOpen: (e) => (e.isOpen && (n.style = "position: fixed !important; z-inde: 2147483647 !important; background: rgba(40, 40, 40, 0.75) !important; transition: background 400ms !important; will-change: background !important; inset: 0px !important; margin: 0px !important; padding: 0px !important; border-radius: 0px; height:100vh"), e.isOpen || (n.style = ""), g == null ? void 0 : g(e.isOpen)),
|
|
79
|
+
onProcessPayment: () => (v = !0, y == null ? void 0 : y(!0)),
|
|
78
80
|
onValidForm: (e) => {
|
|
79
81
|
const t = {
|
|
80
82
|
isValid: e.formIsValid,
|
|
81
83
|
errors: e.errors
|
|
82
84
|
};
|
|
83
|
-
return
|
|
85
|
+
return d && (d(t), d = null), t;
|
|
84
86
|
},
|
|
85
|
-
onNeedCvv: (e) => (a = e.value,
|
|
87
|
+
onNeedCvv: (e) => (a = e.value, u && (u({
|
|
86
88
|
needCvv: a
|
|
87
|
-
}),
|
|
88
|
-
},
|
|
89
|
+
}), u = null), f == null ? void 0 : f(e))
|
|
90
|
+
}, x = (e) => {
|
|
89
91
|
var r;
|
|
90
92
|
const t = (r = e.data) == null ? void 0 : r.hook;
|
|
91
|
-
!t || !
|
|
93
|
+
!t || !k[t] || k[t](e.data);
|
|
92
94
|
};
|
|
93
|
-
return window.addEventListener("message",
|
|
95
|
+
return window.addEventListener("message", x), {
|
|
94
96
|
mount: (e) => {
|
|
95
97
|
const t = typeof e == "string" ? document.querySelector(e) : e;
|
|
96
98
|
if (!t)
|
|
@@ -98,7 +100,7 @@ async function b(u, x = {}) {
|
|
|
98
100
|
t.appendChild(n);
|
|
99
101
|
},
|
|
100
102
|
destroy: () => {
|
|
101
|
-
window.removeEventListener("message",
|
|
103
|
+
window.removeEventListener("message", x), n.remove();
|
|
102
104
|
},
|
|
103
105
|
processPayment: C,
|
|
104
106
|
validateForm: _,
|
package/dist/htechPay.umd.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
(function(r,
|
|
1
|
+
(function(r,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(r=typeof globalThis<"u"?globalThis:r||self,s(r.HtechPay={}))})(this,function(r){"use strict";/*! HtechPay | MIT License */async function s(p,k={}){const{environment:a="qa",onViewForm:f,onPaymentResult:y,theme:x="",on3dsChallengeOpen:g,onProcessPayment:v,onNeedCvv:P}=k;let{type:i}=k;const l={qa:"https://sp-checkout-qa.pagoshtechstage.com/index.html",stage:"https://sp-checkout-stage.pagoshtechstage.com/index.html",prod:"https://sp-checkout.pagoshtech.com/index.html"};let m=null;const d={defaultUrl:{url:`${l[a]}?orderId=${p}&theme=${x}`,height:"670",style:"display"},widget:{url:`${l[a]}?orderId=${p}#/widget`,height:"88",style:""},paymentToken:{url:`${l[a]}?orderId=${p}&theme=${x}#/paymentToken`,height:"520",style:"display:none"}};d[i]||(i="defaultUrl");let u=null,h=null,c=null,w=!1;const n=document.createElement("iframe");n.id="iframe_htechPay",n.src=d[i].url,n.width="100%",n.height=d[i].height,n.frameBorder="0",n.allowFullscreen=!0,n.title="Payment form",n.style=d[i].style;const C=()=>new Promise((e,t)=>{u=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onPayment",new URL(l[a]).origin),setTimeout(()=>{w||e({status:"validation_error",message:"Unknown error"})},600)}),$=()=>new Promise(e=>{const t=o=>{i==="paymentToken"&&o&&(n.style=""),e({needCvv:o})};if(m!==null){t(m);return}c=o=>{t(o.needCvv)}}),_=()=>new Promise((e,t)=>{h=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onValidateForm",new URL(l[a]).origin),setTimeout(()=>{w||e({status:"validation_error",message:"Unknown error"})},600)}),b={onViewForm:()=>f==null?void 0:f(!0),onPaymentResult:e=>{const t=e.data.payload||{};return u&&(u(t),u=null),y==null?void 0:y(t)},on3dsChallengeOpen:e=>(e.isOpen&&(n.style="position: fixed !important; z-inde: 2147483647 !important; background: rgba(40, 40, 40, 0.75) !important; transition: background 400ms !important; will-change: background !important; inset: 0px !important; margin: 0px !important; padding: 0px !important; border-radius: 0px; height:100vh"),e.isOpen||(n.style=""),g==null?void 0:g(e.isOpen)),onProcessPayment:()=>(w=!0,v==null?void 0:v(!0)),onValidForm:e=>{const t={isValid:e.formIsValid,errors:e.errors};return h&&(h(t),h=null),t},onNeedCvv:e=>(m=e.value,c&&(c({needCvv:m}),c=null),P==null?void 0:P(e))},T=e=>{var o;const t=(o=e.data)==null?void 0:o.hook;!t||!b[t]||b[t](e.data)};return window.addEventListener("message",T),{mount:e=>{const t=typeof e=="string"?document.querySelector(e):e;if(!t)throw new Error("The container to mount the form could not be found");t.appendChild(n)},destroy:()=>{window.removeEventListener("message",T),n.remove()},processPayment:C,validateForm:_,verifyNeedCvv:$}}r.htechPay=s,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
|