htech-pay 0.0.29-alpha → 0.1.1-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/README.md CHANGED
@@ -8,4 +8,4 @@ HTechPay JS is a library designed to facilitate the integration of HTechPay paym
8
8
 
9
9
  Ver [Htetch Desarrolladores](https://htech.com/desarrolladores)
10
10
 
11
- Sección: Carta de pago/Insertar carta de pago
11
+ Sección: Paqueteria para su integración/JS HetchPay - Web
package/dist/htechPay.mjs CHANGED
@@ -1,39 +1,151 @@
1
1
  /*! HtechPay | MIT License */
2
- async function g(c, h = {}) {
2
+ async function W(i, T = {}) {
3
3
  const {
4
- environment: i = "qa",
5
- isPaymentWithToken: d = !1,
6
- onViewForm: n,
7
- onPaymentResult: a,
8
- theme: l = ""
9
- } = h, u = `${{
4
+ environment: o = "qa",
5
+ onViewForm: p,
6
+ onPaymentResult: f,
7
+ theme: _ = "",
8
+ on3dsChallengeOpen: v,
9
+ onProcessPayment: P,
10
+ onNeedCvv: w,
11
+ isPaymentToken: C = !1,
12
+ onClose: k
13
+ } = T;
14
+ let { type: r } = T;
15
+ const s = {
16
+ //qa: "http://localhost:5173",
10
17
  qa: "https://sp-checkout-qa.pagoshtechstage.com/index.html",
11
18
  stage: "https://sp-checkout-stage.pagoshtechstage.com/index.html",
12
- prod: ""
13
- }[i]}?orderId=${c}&theme=${l}${d ? "#/paymentToken" : ""}`, e = document.createElement("iframe");
14
- e.src = u, e.width = "100%", e.height = "635", e.frameBorder = "0", e.allowFullscreen = !0, e.title = "Payment form";
15
- const r = {
16
- onViewForm: () => n == null ? void 0 : n(!0),
17
- onPaymentResult: (t) => a == null ? void 0 : a(t.data.payload || {})
18
- }, s = (t) => {
19
- var m;
20
- const o = (m = t.data) == null ? void 0 : m.hook;
21
- !o || !r[o] || r[o](t.data);
19
+ prod: "https://sp-checkout.pagoshtech.com/index.html"
22
20
  };
23
- return window.addEventListener("message", s), {
24
- mount: (t) => {
25
- const o = typeof t == "string" ? document.querySelector(t) : t;
26
- if (!o)
27
- throw new Error(
28
- "No se encontró el contenedor para montar el formulario"
29
- );
30
- o.appendChild(e);
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 = {
23
+ defaultUrl: {
24
+ url: `${s[o]}?orderId=${i}&theme=${_}`,
25
+ height: "670",
26
+ style: ""
31
27
  },
32
- destroy: () => {
33
- window.removeEventListener("message", s), e.remove();
28
+ widget: {
29
+ url: `${s[o]}?orderId=${i}#/widget`,
30
+ height: "88",
31
+ style: ""
32
+ },
33
+ paymentToken: {
34
+ url: `${s[o]}?orderId=${i}&theme=${_}#/paymentToken`,
35
+ height: "530",
36
+ style: U
37
+ },
38
+ paymentTokenWidget: {
39
+ url: `${s[o]}?orderId=${i}#/widgetPaymentToken`,
40
+ height: "88",
41
+ style: ""
34
42
  }
35
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;
46
+ const n = document.createElement("iframe");
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) => {
51
+ d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
52
+ "htechPayment_onPayment",
53
+ new URL(s[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(s[o]).origin
64
+ ), setTimeout(() => {
65
+ x || e({
66
+ status: "validation_error",
67
+ message: "Unknown error"
68
+ });
69
+ }, 600);
70
+ }), b = () => new Promise((e) => {
71
+ const t = (a) => {
72
+ e({ needCvv: a });
73
+ };
74
+ if (l !== null) {
75
+ t(l);
76
+ return;
77
+ }
78
+ g = (a) => {
79
+ t(a.needCvv);
80
+ };
81
+ }), L = () => new Promise((e, t) => {
82
+ c = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
83
+ "htechPayment_onValidateForm",
84
+ new URL(s[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(s[o]).origin
95
+ ), setTimeout(() => {
96
+ y || e({
97
+ status: "validation_error",
98
+ message: "Unknown error"
99
+ });
100
+ }, 600);
101
+ }), $ = {
102
+ onViewForm: () => p == null ? void 0 : p(!0),
103
+ onPaymentResult: (e) => {
104
+ const t = e.data.payload || {};
105
+ return d && (d(t), d = null), u && (u(t), u = null), f == null ? void 0 : f(t);
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)),
109
+ onValidForm: (e) => {
110
+ const t = {
111
+ isValid: e.formIsValid,
112
+ errors: e.errors
113
+ };
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;
122
+ },
123
+ onNeedCvv: (e) => (l = e.value, g && (g({
124
+ needCvv: l
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;
130
+ !t || !$[t] || $[t](e.data);
131
+ };
132
+ return window.addEventListener("message", F), {
133
+ mount: (e) => {
134
+ const t = typeof e == "string" ? document.querySelector(e) : e;
135
+ if (!t)
136
+ throw new Error("The container to mount the form could not be found");
137
+ t.appendChild(n);
138
+ },
139
+ destroy: () => {
140
+ V();
141
+ },
142
+ processPayment: E,
143
+ validateForm: L,
144
+ verifyNeedCvv: b,
145
+ processPaymentToken: I,
146
+ validateFormCvv: M
147
+ };
36
148
  }
37
149
  export {
38
- g as htechPay
150
+ W as htechPay
39
151
  };
@@ -1 +1 @@
1
- (function(n,s){typeof exports=="object"&&typeof module<"u"?s(exports):typeof define=="function"&&define.amd?define(["exports"],s):(n=typeof globalThis<"u"?globalThis:n||self,s(n.HtechPay={}))})(this,function(n){"use strict";/*! HtechPay | MIT License */async function s(h,m={}){const{environment:u="qa",isPaymentWithToken:f=!1,onViewForm:a,onPaymentResult:r,theme:l=""}=m,p=`${{qa:"https://sp-checkout-qa.pagoshtechstage.com/index.html",stage:"https://sp-checkout-stage.pagoshtechstage.com/index.html",prod:""}[u]}?orderId=${h}&theme=${l}${f?"#/paymentToken":""}`,e=document.createElement("iframe");e.src=p,e.width="100%",e.height="635",e.frameBorder="0",e.allowFullscreen=!0,e.title="Payment form";const i={onViewForm:()=>a==null?void 0:a(!0),onPaymentResult:t=>r==null?void 0:r(t.data.payload||{})},d=t=>{var c;const o=(c=t.data)==null?void 0:c.hook;!o||!i[o]||i[o](t.data)};return window.addEventListener("message",d),{mount:t=>{const o=typeof t=="string"?document.querySelector(t):t;if(!o)throw new Error("No se encontró el contenedor para montar el formulario");o.appendChild(e)},destroy:()=>{window.removeEventListener("message",d),e.remove()}}}n.htechPay=s,Object.defineProperty(n,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: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"})});
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "htech-pay",
3
3
  "private": false,
4
- "version": "0.0.29-alpha",
4
+ "version": "0.1.1-beta",
5
5
  "description": "Payment SDK for HtechPay",
6
6
  "main": "dist/htechPay.umd.js",
7
7
  "module": "dist/htechPay.mjs",
@@ -38,5 +38,8 @@
38
38
  "react": "^18.3.1",
39
39
  "react-dom": "^18.3.1",
40
40
  "vite": "^5.4.1"
41
+ },
42
+ "dependencies": {
43
+ "htech-pay": "^0.1.0-beta"
41
44
  }
42
45
  }