htech-pay 0.1.1-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,5 +1,5 @@
1
1
  /*! HtechPay | MIT License */
2
- async function W(i, T = {}) {
2
+ async function W(i, C = {}) {
3
3
  const {
4
4
  environment: o = "qa",
5
5
  onViewForm: p,
@@ -8,49 +8,49 @@ async function W(i, T = {}) {
8
8
  on3dsChallengeOpen: v,
9
9
  onProcessPayment: P,
10
10
  onNeedCvv: w,
11
- isPaymentToken: C = !1,
11
+ isPaymentToken: U = !1,
12
12
  onClose: k
13
- } = T;
14
- let { type: r } = T;
15
- const s = {
13
+ } = C;
14
+ let { type: r } = C;
15
+ const a = {
16
16
  //qa: "http://localhost:5173",
17
17
  qa: "https://sp-checkout-qa.pagoshtechstage.com/index.html",
18
18
  stage: "https://sp-checkout-stage.pagoshtechstage.com/index.html",
19
19
  prod: "https://sp-checkout.pagoshtech.com/index.html"
20
20
  };
21
21
  let l = null;
22
- const U = "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 = {
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 = {
23
23
  defaultUrl: {
24
- url: `${s[o]}?orderId=${i}&theme=${_}`,
24
+ url: `${a[o]}?orderId=${i}&theme=${_}`,
25
25
  height: "670",
26
26
  style: ""
27
27
  },
28
28
  widget: {
29
- url: `${s[o]}?orderId=${i}#/widget`,
29
+ url: `${a[o]}?orderId=${i}#/widget`,
30
30
  height: "88",
31
31
  style: ""
32
32
  },
33
33
  paymentToken: {
34
- url: `${s[o]}?orderId=${i}&theme=${_}#/paymentToken`,
34
+ url: `${a[o]}?orderId=${i}&theme=${_}#/paymentToken`,
35
35
  height: "530",
36
- style: U
36
+ style: x
37
37
  },
38
38
  paymentTokenWidget: {
39
- url: `${s[o]}?orderId=${i}#/widgetPaymentToken`,
39
+ url: `${a[o]}?orderId=${i}#/widgetPaymentToken`,
40
40
  height: "88",
41
41
  style: ""
42
42
  }
43
43
  };
44
- m[r] || (r = "defaultUrl"), r === "widget" && C && (r = "paymentTokenWidget"), r === "defaultUrl" && C && (r = "paymentToken");
45
- let d = null, u = null, c = null, h = null, g = null, y = !1, x = !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;
46
46
  const n = document.createElement("iframe");
47
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;
48
- const V = () => {
49
- window.removeEventListener("message", F), n.remove();
50
- }, E = () => new Promise((e, t) => {
48
+ const T = () => {
49
+ window.removeEventListener("message", E), n.remove();
50
+ }, F = () => new Promise((e, t) => {
51
51
  d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
52
52
  "htechPayment_onPayment",
53
- new URL(s[o]).origin
53
+ new URL(a[o]).origin
54
54
  ), setTimeout(() => {
55
55
  y || e({
56
56
  status: "validation_error",
@@ -60,28 +60,28 @@ async function W(i, T = {}) {
60
60
  }), I = () => new Promise((e, t) => {
61
61
  u = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
62
62
  "htechPayment_onPaymentToken",
63
- new URL(s[o]).origin
63
+ new URL(a[o]).origin
64
64
  ), setTimeout(() => {
65
- x || e({
65
+ V || e({
66
66
  status: "validation_error",
67
67
  message: "Unknown error"
68
68
  });
69
69
  }, 600);
70
70
  }), b = () => new Promise((e) => {
71
- const t = (a) => {
72
- e({ needCvv: a });
71
+ const t = (s) => {
72
+ e({ needCvv: s });
73
73
  };
74
74
  if (l !== null) {
75
75
  t(l);
76
76
  return;
77
77
  }
78
- g = (a) => {
79
- t(a.needCvv);
78
+ g = (s) => {
79
+ t(s.needCvv);
80
80
  };
81
81
  }), L = () => new Promise((e, t) => {
82
82
  c = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
83
83
  "htechPayment_onValidateForm",
84
- new URL(s[o]).origin
84
+ new URL(a[o]).origin
85
85
  ), setTimeout(() => {
86
86
  y || e({
87
87
  status: "validation_error",
@@ -91,7 +91,7 @@ async function W(i, T = {}) {
91
91
  }), M = () => new Promise((e, t) => {
92
92
  h = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
93
93
  "htechPayment_onValidateFormCvv",
94
- new URL(s[o]).origin
94
+ new URL(a[o]).origin
95
95
  ), setTimeout(() => {
96
96
  y || e({
97
97
  status: "validation_error",
@@ -104,8 +104,8 @@ async function W(i, T = {}) {
104
104
  const t = e.data.payload || {};
105
105
  return d && (d(t), d = null), u && (u(t), u = null), f == null ? void 0 : f(t);
106
106
  },
107
- on3dsChallengeOpen: (e) => (r !== "defaultUrl" && e.isOpen && (n.style.cssText = U), !e.isOpen && r !== "paymentToken" && (n.style = ""), v == null ? void 0 : v(e.isOpen)),
108
- onProcessPayment: () => (x = !0, y = !0, P == null ? void 0 : P(!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)),
109
109
  onValidForm: (e) => {
110
110
  const t = {
111
111
  isValid: e.formIsValid,
@@ -123,13 +123,16 @@ async function W(i, T = {}) {
123
123
  onNeedCvv: (e) => (l = e.value, g && (g({
124
124
  needCvv: l
125
125
  }), g = null), w == null ? void 0 : w(e)),
126
- onClose: () => (V(), k == null ? void 0 : k(!0))
127
- }, F = (e) => {
128
- var a;
129
- const t = (a = e.data) == null ? void 0 : a.hook;
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;
130
133
  !t || !$[t] || $[t](e.data);
131
134
  };
132
- return window.addEventListener("message", F), {
135
+ return window.addEventListener("message", E), {
133
136
  mount: (e) => {
134
137
  const t = typeof e == "string" ? document.querySelector(e) : e;
135
138
  if (!t)
@@ -137,9 +140,9 @@ async function W(i, T = {}) {
137
140
  t.appendChild(n);
138
141
  },
139
142
  destroy: () => {
140
- V();
143
+ T();
141
144
  },
142
- processPayment: E,
145
+ processPayment: F,
143
146
  validateForm: L,
144
147
  verifyNeedCvv: b,
145
148
  processPaymentToken: I,
@@ -1 +1 @@
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:C="",on3dsChallengeOpen:w,onProcessPayment:k,onNeedCvv:T,isPaymentToken:U=!1,onClose:_}=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 V="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=${C}`,height:"670",style:""},widget:{url:`${i[r]}?orderId=${m}#/widget`,height:"88",style:""},paymentToken:{url:`${i[r]}?orderId=${m}&theme=${C}#/paymentToken`,height:"530",style:V},paymentTokenWidget:{url:`${i[r]}?orderId=${m}#/widgetPaymentToken`,height:"88",style:""}};u[o]||(o="defaultUrl"),o==="widget"&&U&&(o="paymentTokenWidget"),o==="defaultUrl"&&U&&(o="paymentToken");let c=null,h=null,f=null,y=null,p=null,g=!1,$=!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 b=()=>{window.removeEventListener("message",E),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(()=>{$||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)}),F={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=V),!e.isOpen&&o!=="paymentToken"&&(n.style=""),w==null?void 0:w(e.isOpen)),onProcessPayment:()=>($=!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:()=>(b(),_==null?void 0:_(!0))},E=e=>{var a;const t=(a=e.data)==null?void 0:a.hook;!t||!F[t]||F[t](e.data)};return window.addEventListener("message",E),{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:()=>{b()},processPayment:I,validateForm:L,verifyNeedCvv:j,processPaymentToken:M,validateFormCvv:S}}s.htechPay=l,Object.defineProperty(s,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.1-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",