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 CHANGED
@@ -1,45 +1,47 @@
1
1
  /*! HtechPay | MIT License */
2
- async function b(u, x = {}) {
2
+ async function b(h, w = {}) {
3
3
  const {
4
- environment: o = "qa",
5
- onViewForm: h,
6
- onPaymentResult: c,
7
- theme: w = "",
8
- type: s = "defaultUrl",
9
- on3dsChallengeOpen: p,
10
- onProcessPayment: g,
11
- onNeedCvv: y
12
- } = x, i = {
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 f = {
20
+ const l = {
20
21
  defaultUrl: {
21
- url: `${i[o]}?orderId=${u}&theme=${w}`,
22
- height: "635",
22
+ url: `${s[i]}?orderId=${h}&theme=${P}`,
23
+ height: "670",
23
24
  style: "display"
24
25
  },
25
26
  widget: {
26
- url: `${i[o]}?orderId=${u}#/widget`,
27
+ url: `${s[i]}?orderId=${h}#/widget`,
27
28
  height: "88",
28
29
  style: ""
29
30
  },
30
31
  paymentToken: {
31
- url: `${i[o]}?orderId=${u}&theme=${w}#/paymentToken`,
32
+ url: `${s[i]}?orderId=${h}&theme=${P}#/paymentToken`,
32
33
  height: "520",
33
34
  style: "display:none"
34
35
  }
35
36
  };
36
- let m = null, l = null, d = null, v = !1;
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 = f[s].url, n.width = "100%", n.height = f[s].height, n.frameBorder = "0", n.allowFullscreen = !0, n.title = "Payment form", n.style = f[s].style;
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[o]).origin
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
- s === "paymentToken" && r && (n.style = ""), e({ needCvv: r });
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
- d = (r) => {
59
+ u = (r) => {
58
60
  t(r.needCvv);
59
61
  };
60
62
  }), _ = () => new Promise((e, t) => {
61
- l = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
63
+ d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
62
64
  "htechPayment_onValidateForm",
63
- new URL(i[o]).origin
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
- }), P = {
71
- onViewForm: () => h == null ? void 0 : h(!0),
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), c == null ? void 0 : c(t);
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 = ""), p == null ? void 0 : p(e.isOpen)),
77
- onProcessPayment: () => (v = !0, g == null ? void 0 : g(!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 l && (l(t), l = null), t;
85
+ return d && (d(t), d = null), t;
84
86
  },
85
- onNeedCvv: (e) => (a = e.value, d && (d({
87
+ onNeedCvv: (e) => (a = e.value, u && (u({
86
88
  needCvv: a
87
- }), d = null), y == null ? void 0 : y(e))
88
- }, k = (e) => {
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 || !P[t] || P[t](e.data);
93
+ !t || !k[t] || k[t](e.data);
92
94
  };
93
- return window.addEventListener("message", k), {
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", k), n.remove();
103
+ window.removeEventListener("message", x), n.remove();
102
104
  },
103
105
  processPayment: C,
104
106
  validateForm: _,
@@ -1 +1 @@
1
- (function(r,i){typeof exports=="object"&&typeof module<"u"?i(exports):typeof define=="function"&&define.amd?define(["exports"],i):(r=typeof globalThis<"u"?globalThis:r||self,i(r.HtechPay={}))})(this,function(r){"use strict";/*! HtechPay | MIT License */async function i(c,T={}){const{environment:s="qa",onViewForm:p,onPaymentResult:f,theme:k="",type:l="defaultUrl",on3dsChallengeOpen:y,onProcessPayment:g,onNeedCvv:v}=T,a={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 P={defaultUrl:{url:`${a[s]}?orderId=${c}&theme=${k}`,height:"635",style:"display"},widget:{url:`${a[s]}?orderId=${c}#/widget`,height:"88",style:""},paymentToken:{url:`${a[s]}?orderId=${c}&theme=${k}#/paymentToken`,height:"520",style:"display:none"}};let d=null,u=null,h=null,w=!1;const n=document.createElement("iframe");n.id="iframe_htechPay",n.src=P[l].url,n.width="100%",n.height=P[l].height,n.frameBorder="0",n.allowFullscreen=!0,n.title="Payment form",n.style=P[l].style;const C=()=>new Promise((e,t)=>{d=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onPayment",new URL(a[s]).origin),setTimeout(()=>{w||e({status:"validation_error",message:"Unknown error"})},600)}),$=()=>new Promise(e=>{const t=o=>{l==="paymentToken"&&o&&(n.style=""),e({needCvv:o})};if(m!==null){t(m);return}h=o=>{t(o.needCvv)}}),_=()=>new Promise((e,t)=>{u=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onValidateForm",new URL(a[s]).origin),setTimeout(()=>{w||e({status:"validation_error",message:"Unknown error"})},600)}),x={onViewForm:()=>p==null?void 0:p(!0),onPaymentResult:e=>{const t=e.data.payload||{};return d&&(d(t),d=null),f==null?void 0:f(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=""),y==null?void 0:y(e.isOpen)),onProcessPayment:()=>(w=!0,g==null?void 0:g(!0)),onValidForm:e=>{const t={isValid:e.formIsValid,errors:e.errors};return u&&(u(t),u=null),t},onNeedCvv:e=>(m=e.value,h&&(h({needCvv:m}),h=null),v==null?void 0:v(e))},b=e=>{var o;const t=(o=e.data)==null?void 0:o.hook;!t||!x[t]||x[t](e.data)};return window.addEventListener("message",b),{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",b),n.remove()},processPayment:C,validateForm:_,verifyNeedCvv:$}}r.htechPay=i,Object.defineProperty(r,Symbol.toStringTag,{value:"Module"})});
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"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "htech-pay",
3
3
  "private": false,
4
- "version": "0.0.6-beta",
4
+ "version": "0.0.7-beta",
5
5
  "description": "Payment SDK for HtechPay",
6
6
  "main": "dist/htechPay.umd.js",
7
7
  "module": "dist/htechPay.mjs",