htech-pay 0.1.0-beta → 0.1.2-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,98 +1,138 @@
1
1
  /*! HtechPay | MIT License */
2
- async function b(c, w = {}) {
2
+ async function W(i, C = {}) {
3
3
  const {
4
- environment: i = "qa",
5
- onViewForm: h,
6
- onPaymentResult: p,
7
- theme: P = "",
8
- on3dsChallengeOpen: g,
9
- onProcessPayment: f,
10
- onNeedCvv: y
11
- } = w;
12
- let { type: r } = w;
13
- const s = {
4
+ environment: o = "qa",
5
+ onViewForm: p,
6
+ onPaymentResult: f,
7
+ theme: _ = "",
8
+ on3dsChallengeOpen: v,
9
+ onProcessPayment: P,
10
+ onNeedCvv: w,
11
+ isPaymentToken: U = !1,
12
+ onClose: k
13
+ } = C;
14
+ let { type: r } = C;
15
+ const a = {
14
16
  //qa: "http://localhost:5173",
15
17
  qa: "https://sp-checkout-qa.pagoshtechstage.com/index.html",
16
18
  stage: "https://sp-checkout-stage.pagoshtechstage.com/index.html",
17
19
  prod: "https://sp-checkout.pagoshtech.com/index.html"
18
20
  };
19
- let a = null;
20
- const m = {
21
+ let l = null;
22
+ const x = "position: fixed !important; z-index: 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", m = {
21
23
  defaultUrl: {
22
- url: `${s[i]}?orderId=${c}&theme=${P}`,
24
+ url: `${a[o]}?orderId=${i}&theme=${_}`,
23
25
  height: "670",
24
26
  style: ""
25
27
  },
26
28
  widget: {
27
- url: `${s[i]}?orderId=${c}#/widget`,
29
+ url: `${a[o]}?orderId=${i}#/widget`,
28
30
  height: "88",
29
31
  style: ""
30
32
  },
31
33
  paymentToken: {
32
- url: `${s[i]}?orderId=${c}&theme=${P}#/paymentToken`,
33
- height: "520",
34
+ url: `${a[o]}?orderId=${i}&theme=${_}#/paymentToken`,
35
+ height: "530",
36
+ style: x
37
+ },
38
+ paymentTokenWidget: {
39
+ url: `${a[o]}?orderId=${i}#/widgetPaymentToken`,
40
+ height: "88",
34
41
  style: ""
35
42
  }
36
43
  };
37
- m[r] || (r = "defaultUrl");
38
- let l = null, d = null, u = null, v = !1;
44
+ m[r] || (r = "defaultUrl"), r === "widget" && U && (r = "paymentTokenWidget"), r === "defaultUrl" && U && (r = "paymentToken");
45
+ let d = null, u = null, c = null, h = null, g = null, y = !1, V = !1;
39
46
  const n = document.createElement("iframe");
40
47
  n.id = "iframe_htechPay", n.src = m[r].url, n.width = "100%", n.height = m[r].height, n.frameBorder = "0", n.allowFullscreen = !0, n.title = "Payment form", n.style = m[r].style;
41
- const C = () => new Promise((e, t) => {
42
- l = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
48
+ const T = () => {
49
+ window.removeEventListener("message", E), n.remove();
50
+ }, F = () => new Promise((e, t) => {
51
+ d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
43
52
  "htechPayment_onPayment",
44
- new URL(s[i]).origin
53
+ new URL(a[o]).origin
54
+ ), setTimeout(() => {
55
+ y || e({
56
+ status: "validation_error",
57
+ message: "Unknown error"
58
+ });
59
+ }, 600);
60
+ }), I = () => new Promise((e, t) => {
61
+ u = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
62
+ "htechPayment_onPaymentToken",
63
+ new URL(a[o]).origin
45
64
  ), setTimeout(() => {
46
- v || e({
65
+ V || e({
47
66
  status: "validation_error",
48
67
  message: "Unknown error"
49
68
  });
50
69
  }, 600);
51
- }), $ = () => new Promise((e) => {
52
- const t = (o) => {
53
- e({ needCvv: o });
70
+ }), b = () => new Promise((e) => {
71
+ const t = (s) => {
72
+ e({ needCvv: s });
54
73
  };
55
- if (a !== null) {
56
- t(a);
74
+ if (l !== null) {
75
+ t(l);
57
76
  return;
58
77
  }
59
- u = (o) => {
60
- t(o.needCvv);
78
+ g = (s) => {
79
+ t(s.needCvv);
61
80
  };
62
- }), _ = () => new Promise((e, t) => {
63
- d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
81
+ }), L = () => new Promise((e, t) => {
82
+ c = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
64
83
  "htechPayment_onValidateForm",
65
- new URL(s[i]).origin
84
+ new URL(a[o]).origin
85
+ ), setTimeout(() => {
86
+ y || e({
87
+ status: "validation_error",
88
+ message: "Unknown error"
89
+ });
90
+ }, 600);
91
+ }), M = () => new Promise((e, t) => {
92
+ h = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
93
+ "htechPayment_onValidateFormCvv",
94
+ new URL(a[o]).origin
66
95
  ), setTimeout(() => {
67
- v || e({
96
+ y || e({
68
97
  status: "validation_error",
69
98
  message: "Unknown error"
70
99
  });
71
100
  }, 600);
72
- }), k = {
73
- onViewForm: () => h == null ? void 0 : h(!0),
101
+ }), $ = {
102
+ onViewForm: () => p == null ? void 0 : p(!0),
74
103
  onPaymentResult: (e) => {
75
104
  const t = e.data.payload || {};
76
- return l && (l(t), l = null), p == null ? void 0 : p(t);
105
+ return d && (d(t), d = null), u && (u(t), u = null), f == null ? void 0 : f(t);
77
106
  },
78
- on3dsChallengeOpen: (e) => (r === "widget" && e.isOpen && (n.style.cssText = "position: fixed !important; z-index: 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, f == null ? void 0 : f(!0)),
107
+ on3dsChallengeOpen: (e) => (r !== "defaultUrl" && e.isOpen && (n.style.cssText = x), !e.isOpen && r !== "paymentToken" && (n.style = ""), v == null ? void 0 : v(e.isOpen)),
108
+ onProcessPayment: () => (V = !0, y = !0, P == null ? void 0 : P(!0)),
80
109
  onValidForm: (e) => {
81
110
  const t = {
82
111
  isValid: e.formIsValid,
83
112
  errors: e.errors
84
113
  };
85
- return d && (d(t), d = null), t;
114
+ return c && (c(t), c = null), t;
115
+ },
116
+ onValidFormCvv: (e) => {
117
+ const t = {
118
+ isValid: e.formIsValid,
119
+ errors: e.errors
120
+ };
121
+ return h && (h(t), h = null), t;
86
122
  },
87
- onNeedCvv: (e) => (a = e.value, u && (u({
88
- needCvv: a
89
- }), u = null), y == null ? void 0 : y(e))
90
- }, x = (e) => {
91
- var o;
92
- const t = (o = e.data) == null ? void 0 : o.hook;
93
- !t || !k[t] || k[t](e.data);
123
+ onNeedCvv: (e) => (l = e.value, g && (g({
124
+ needCvv: l
125
+ }), g = null), w == null ? void 0 : w(e)),
126
+ onClose: () => (T(), k == null ? void 0 : k(!0)),
127
+ onConfigError: () => {
128
+ console.error("htech-pay: Configuration error"), T();
129
+ }
130
+ }, E = (e) => {
131
+ var s;
132
+ const t = (s = e.data) == null ? void 0 : s.hook;
133
+ !t || !$[t] || $[t](e.data);
94
134
  };
95
- return window.addEventListener("message", x), {
135
+ return window.addEventListener("message", E), {
96
136
  mount: (e) => {
97
137
  const t = typeof e == "string" ? document.querySelector(e) : e;
98
138
  if (!t)
@@ -100,13 +140,15 @@ async function b(c, w = {}) {
100
140
  t.appendChild(n);
101
141
  },
102
142
  destroy: () => {
103
- window.removeEventListener("message", x), n.remove();
143
+ T();
104
144
  },
105
- processPayment: C,
106
- validateForm: _,
107
- verifyNeedCvv: $
145
+ processPayment: F,
146
+ validateForm: L,
147
+ verifyNeedCvv: b,
148
+ processPaymentToken: I,
149
+ validateFormCvv: M
108
150
  };
109
151
  }
110
152
  export {
111
- b as htechPay
153
+ W as htechPay
112
154
  };
@@ -1 +1 @@
1
- (function(o,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(o=typeof globalThis<"u"?globalThis:o||self,s(o.HtechPay={}))})(this,function(o){"use strict";/*! HtechPay | MIT License */async function s(p,k={}){const{environment:a="qa",onViewForm:f,onPaymentResult:g,theme:x="",on3dsChallengeOpen:y,onProcessPayment:v,onNeedCvv:w}=k;let{type:r}=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:""},widget:{url:`${l[a]}?orderId=${p}#/widget`,height:"88",style:""},paymentToken:{url:`${l[a]}?orderId=${p}&theme=${x}#/paymentToken`,height:"520",style:""}};d[r]||(r="defaultUrl");let u=null,c=null,h=null,P=!1;const n=document.createElement("iframe");n.id="iframe_htechPay",n.src=d[r].url,n.width="100%",n.height=d[r].height,n.frameBorder="0",n.allowFullscreen=!0,n.title="Payment form",n.style=d[r].style;const C=()=>new Promise((e,t)=>{u=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onPayment",new URL(l[a]).origin),setTimeout(()=>{P||e({status:"validation_error",message:"Unknown error"})},600)}),$=()=>new Promise(e=>{const t=i=>{e({needCvv:i})};if(m!==null){t(m);return}h=i=>{t(i.needCvv)}}),_=()=>new Promise((e,t)=>{c=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onValidateForm",new URL(l[a]).origin),setTimeout(()=>{P||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),g==null?void 0:g(t)},on3dsChallengeOpen:e=>(r==="widget"&&e.isOpen&&(n.style.cssText="position: fixed !important; z-index: 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:()=>(P=!0,v==null?void 0:v(!0)),onValidForm:e=>{const t={isValid:e.formIsValid,errors:e.errors};return c&&(c(t),c=null),t},onNeedCvv:e=>(m=e.value,h&&(h({needCvv:m}),h=null),w==null?void 0:w(e))},T=e=>{var i;const t=(i=e.data)==null?void 0:i.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:$}}o.htechPay=s,Object.defineProperty(o,Symbol.toStringTag,{value:"Module"})});
1
+ (function(s,l){typeof exports=="object"&&typeof module<"u"?l(exports):typeof define=="function"&&define.amd?define(["exports"],l):(s=typeof globalThis<"u"?globalThis:s||self,l(s.HtechPay={}))})(this,function(s){"use strict";/*! HtechPay | MIT License */async function l(m,x={}){const{environment:r="qa",onViewForm:v,onPaymentResult:P,theme:U="",on3dsChallengeOpen:w,onProcessPayment:k,onNeedCvv:T,isPaymentToken:V=!1,onClose:C}=x;let{type:o}=x;const i={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 d=null;const $="position: fixed !important; z-index: 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",u={defaultUrl:{url:`${i[r]}?orderId=${m}&theme=${U}`,height:"670",style:""},widget:{url:`${i[r]}?orderId=${m}#/widget`,height:"88",style:""},paymentToken:{url:`${i[r]}?orderId=${m}&theme=${U}#/paymentToken`,height:"530",style:$},paymentTokenWidget:{url:`${i[r]}?orderId=${m}#/widgetPaymentToken`,height:"88",style:""}};u[o]||(o="defaultUrl"),o==="widget"&&V&&(o="paymentTokenWidget"),o==="defaultUrl"&&V&&(o="paymentToken");let c=null,h=null,f=null,y=null,p=null,g=!1,b=!1;const n=document.createElement("iframe");n.id="iframe_htechPay",n.src=u[o].url,n.width="100%",n.height=u[o].height,n.frameBorder="0",n.allowFullscreen=!0,n.title="Payment form",n.style=u[o].style;const _=()=>{window.removeEventListener("message",F),n.remove()},I=()=>new Promise((e,t)=>{c=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onPayment",new URL(i[r]).origin),setTimeout(()=>{g||e({status:"validation_error",message:"Unknown error"})},600)}),M=()=>new Promise((e,t)=>{h=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onPaymentToken",new URL(i[r]).origin),setTimeout(()=>{b||e({status:"validation_error",message:"Unknown error"})},600)}),j=()=>new Promise(e=>{const t=a=>{e({needCvv:a})};if(d!==null){t(d);return}p=a=>{t(a.needCvv)}}),L=()=>new Promise((e,t)=>{f=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onValidateForm",new URL(i[r]).origin),setTimeout(()=>{g||e({status:"validation_error",message:"Unknown error"})},600)}),S=()=>new Promise((e,t)=>{y=e,document.getElementById("iframe_htechPay").contentWindow.postMessage("htechPayment_onValidateFormCvv",new URL(i[r]).origin),setTimeout(()=>{g||e({status:"validation_error",message:"Unknown error"})},600)}),E={onViewForm:()=>v==null?void 0:v(!0),onPaymentResult:e=>{const t=e.data.payload||{};return c&&(c(t),c=null),h&&(h(t),h=null),P==null?void 0:P(t)},on3dsChallengeOpen:e=>(o!=="defaultUrl"&&e.isOpen&&(n.style.cssText=$),!e.isOpen&&o!=="paymentToken"&&(n.style=""),w==null?void 0:w(e.isOpen)),onProcessPayment:()=>(b=!0,g=!0,k==null?void 0:k(!0)),onValidForm:e=>{const t={isValid:e.formIsValid,errors:e.errors};return f&&(f(t),f=null),t},onValidFormCvv:e=>{const t={isValid:e.formIsValid,errors:e.errors};return y&&(y(t),y=null),t},onNeedCvv:e=>(d=e.value,p&&(p({needCvv:d}),p=null),T==null?void 0:T(e)),onClose:()=>(_(),C==null?void 0:C(!0)),onConfigError:()=>{console.error("htech-pay: Configuration error"),_()}},F=e=>{var a;const t=(a=e.data)==null?void 0:a.hook;!t||!E[t]||E[t](e.data)};return window.addEventListener("message",F),{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:()=>{_()},processPayment:I,validateForm:L,verifyNeedCvv:j,processPaymentToken:M,validateFormCvv:S}}s.htechPay=l,Object.defineProperty(s,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.1.0-beta",
4
+ "version": "0.1.2-beta",
5
5
  "description": "Payment SDK for HtechPay",
6
6
  "main": "dist/htechPay.umd.js",
7
7
  "module": "dist/htechPay.mjs",
@@ -40,6 +40,6 @@
40
40
  "vite": "^5.4.1"
41
41
  },
42
42
  "dependencies": {
43
- "htech-pay": "^0.0.9-beta"
43
+ "htech-pay": "^0.1.0-beta"
44
44
  }
45
45
  }