htech-pay 0.0.29-alpha → 0.1.0-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,112 @@
1
1
  /*! HtechPay | MIT License */
2
- async function g(c, h = {}) {
2
+ async function b(c, w = {}) {
3
3
  const {
4
4
  environment: i = "qa",
5
- isPaymentWithToken: d = !1,
6
- onViewForm: n,
7
- onPaymentResult: a,
8
- theme: l = ""
9
- } = h, u = `${{
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 = {
14
+ //qa: "http://localhost:5173",
10
15
  qa: "https://sp-checkout-qa.pagoshtechstage.com/index.html",
11
16
  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);
17
+ prod: "https://sp-checkout.pagoshtech.com/index.html"
22
18
  };
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);
19
+ let a = null;
20
+ const m = {
21
+ defaultUrl: {
22
+ url: `${s[i]}?orderId=${c}&theme=${P}`,
23
+ height: "670",
24
+ style: ""
31
25
  },
32
- destroy: () => {
33
- window.removeEventListener("message", s), e.remove();
26
+ widget: {
27
+ url: `${s[i]}?orderId=${c}#/widget`,
28
+ height: "88",
29
+ style: ""
30
+ },
31
+ paymentToken: {
32
+ url: `${s[i]}?orderId=${c}&theme=${P}#/paymentToken`,
33
+ height: "520",
34
+ style: ""
34
35
  }
35
36
  };
37
+ m[r] || (r = "defaultUrl");
38
+ let l = null, d = null, u = null, v = !1;
39
+ const n = document.createElement("iframe");
40
+ 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(
43
+ "htechPayment_onPayment",
44
+ new URL(s[i]).origin
45
+ ), setTimeout(() => {
46
+ v || e({
47
+ status: "validation_error",
48
+ message: "Unknown error"
49
+ });
50
+ }, 600);
51
+ }), $ = () => new Promise((e) => {
52
+ const t = (o) => {
53
+ e({ needCvv: o });
54
+ };
55
+ if (a !== null) {
56
+ t(a);
57
+ return;
58
+ }
59
+ u = (o) => {
60
+ t(o.needCvv);
61
+ };
62
+ }), _ = () => new Promise((e, t) => {
63
+ d = e, document.getElementById("iframe_htechPay").contentWindow.postMessage(
64
+ "htechPayment_onValidateForm",
65
+ new URL(s[i]).origin
66
+ ), setTimeout(() => {
67
+ v || e({
68
+ status: "validation_error",
69
+ message: "Unknown error"
70
+ });
71
+ }, 600);
72
+ }), k = {
73
+ onViewForm: () => h == null ? void 0 : h(!0),
74
+ onPaymentResult: (e) => {
75
+ const t = e.data.payload || {};
76
+ return l && (l(t), l = null), p == null ? void 0 : p(t);
77
+ },
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)),
80
+ onValidForm: (e) => {
81
+ const t = {
82
+ isValid: e.formIsValid,
83
+ errors: e.errors
84
+ };
85
+ return d && (d(t), d = null), t;
86
+ },
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);
94
+ };
95
+ return window.addEventListener("message", x), {
96
+ mount: (e) => {
97
+ const t = typeof e == "string" ? document.querySelector(e) : e;
98
+ if (!t)
99
+ throw new Error("The container to mount the form could not be found");
100
+ t.appendChild(n);
101
+ },
102
+ destroy: () => {
103
+ window.removeEventListener("message", x), n.remove();
104
+ },
105
+ processPayment: C,
106
+ validateForm: _,
107
+ verifyNeedCvv: $
108
+ };
36
109
  }
37
110
  export {
38
- g as htechPay
111
+ b as htechPay
39
112
  };
@@ -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(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"})});
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.0-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.0.9-beta"
41
44
  }
42
45
  }