@inflow_pay/sdk 0.7.0 → 1.0.0

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/react.umd.js CHANGED
@@ -1,4 +1,4 @@
1
- (function(_,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(_=typeof globalThis<"u"?globalThis:_||self,g(_.InflowPaySDKReact={},_.React))})(this,function(_,g){"use strict";var A={exports:{}},S={};/**
1
+ (function(T,g){typeof exports=="object"&&typeof module<"u"?g(exports,require("react")):typeof define=="function"&&define.amd?define(["exports","react"],g):(T=typeof globalThis<"u"?globalThis:T||self,g(T.InflowPaySDKReact={},T.React))})(this,function(T,g){"use strict";var j={exports:{}},O={};/**
2
2
  * @license React
3
3
  * react-jsx-runtime.production.js
4
4
  *
@@ -6,7 +6,7 @@
6
6
  *
7
7
  * This source code is licensed under the MIT license found in the
8
8
  * LICENSE file in the root directory of this source tree.
9
- */var N;function V(){if(N)return S;N=1;var d=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function n(r,i,o){var a=null;if(o!==void 0&&(a=""+o),i.key!==void 0&&(a=""+i.key),"key"in i){o={};for(var l in i)l!=="key"&&(o[l]=i[l])}else o=i;return i=o.ref,{$$typeof:d,type:r,key:a,ref:i!==void 0?i:null,props:o}}return S.Fragment=t,S.jsx=n,S.jsxs=n,S}var R={};/**
9
+ */var V;function ae(){if(V)return O;V=1;var n=Symbol.for("react.transitional.element"),t=Symbol.for("react.fragment");function r(a,o,i){var l=null;if(i!==void 0&&(l=""+i),o.key!==void 0&&(l=""+o.key),"key"in o){i={};for(var c in o)c!=="key"&&(i[c]=o[c])}else i=o;return o=i.ref,{$$typeof:n,type:a,key:l,ref:o!==void 0?o:null,props:i}}return O.Fragment=t,O.jsx=r,O.jsxs=r,O}var A={};/**
10
10
  * @license React
11
11
  * react-jsx-runtime.development.js
12
12
  *
@@ -14,186 +14,177 @@
14
14
  *
15
15
  * This source code is licensed under the MIT license found in the
16
16
  * LICENSE file in the root directory of this source tree.
17
- */var U;function G(){return U||(U=1,process.env.NODE_ENV!=="production"&&function(){function d(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ae?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case w:return"Fragment";case C:return"Profiler";case E:return"StrictMode";case re:return"Suspense";case ie:return"SuspenseList";case se:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case k:return"Portal";case te:return e.displayName||"Context";case ee:return(e._context.displayName||"Context")+".Consumer";case ne:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case oe:return s=e.displayName||null,s!==null?s:d(e.type)||"Memo";case D:s=e._payload,e=e._init;try{return d(e(s))}catch{}}return null}function t(e){return""+e}function n(e){try{t(e);var s=!1}catch{s=!0}if(s){s=console;var c=s.error,m=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return c.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",m),t(e)}}function r(e){if(e===w)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===D)return"<...>";try{var s=d(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function i(){var e=L.A;return e===null?null:e.getOwner()}function o(){return Error("react-stack-top-frame")}function a(e){if(W.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function l(e,s){function c(){K||(K=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}c.isReactWarning=!0,Object.defineProperty(e,"key",{get:c,configurable:!0})}function x(){var e=d(this.type);return Y[e]||(Y[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function v(e,s,c,m,P,j){var h=c.ref;return e={$$typeof:y,type:e,key:s,props:c,_owner:m},(h!==void 0?h:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:x}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:P}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:j}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function u(e,s,c,m,P,j){var h=s.children;if(h!==void 0)if(m)if(le(h)){for(m=0;m<h.length;m++)f(h[m]);Object.freeze&&Object.freeze(h)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else f(h);if(W.call(s,"key")){h=d(e);var T=Object.keys(s).filter(function(ce){return ce!=="key"});m=0<T.length?"{key: someKey, "+T.join(": ..., ")+": ...}":"{key: someKey}",B[h+m]||(T=0<T.length?"{"+T.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
17
+ */var X;function le(){return X||(X=1,process.env.NODE_ENV!=="production"&&function(){function n(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===Ge?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case R:return"Fragment";case M:return"Profiler";case $:return"StrictMode";case $e:return"Suspense";case Ye:return"SuspenseList";case ze:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case C:return"Portal";case Ke:return e.displayName||"Context";case x:return(e._context.displayName||"Context")+".Consumer";case Fe:var s=e.render;return e=e.displayName,e||(e=s.displayName||s.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case We:return s=e.displayName||null,s!==null?s:n(e.type)||"Memo";case Y:s=e._payload,e=e._init;try{return n(e(s))}catch{}}return null}function t(e){return""+e}function r(e){try{t(e);var s=!1}catch{s=!0}if(s){s=console;var d=s.error,f=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return d.call(s,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",f),t(e)}}function a(e){if(e===R)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===Y)return"<...>";try{var s=n(e);return s?"<"+s+">":"<...>"}catch{return"<...>"}}function o(){var e=W.A;return e===null?null:e.getOwner()}function i(){return Error("react-stack-top-frame")}function l(e){if(te.call(e,"key")){var s=Object.getOwnPropertyDescriptor(e,"key").get;if(s&&s.isReactWarning)return!1}return e.key!==void 0}function c(e,s){function d(){ne||(ne=!0,console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",s))}d.isReactWarning=!0,Object.defineProperty(e,"key",{get:d,configurable:!0})}function y(){var e=n(this.type);return re[e]||(re[e]=!0,console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")),e=this.props.ref,e!==void 0?e:null}function w(e,s,d,f,H,G){var m=d.ref;return e={$$typeof:v,type:e,key:s,props:d,_owner:f},(m!==void 0?m:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:y}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:H}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:G}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function S(e,s,d,f,H,G){var m=s.children;if(m!==void 0)if(f)if(Be(m)){for(f=0;f<m.length;f++)b(m[f]);Object.freeze&&Object.freeze(m)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else b(m);if(te.call(s,"key")){m=n(e);var D=Object.keys(s).filter(function(Ve){return Ve!=="key"});f=0<D.length?"{key: someKey, "+D.join(": ..., ")+": ...}":"{key: someKey}",se[m+f]||(D=0<D.length?"{"+D.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
18
18
  let props = %s;
19
19
  <%s {...props} />
20
20
  React keys must be passed directly to JSX without using spread:
21
21
  let props = %s;
22
- <%s key={someKey} {...props} />`,m,h,T,h),B[h+m]=!0)}if(h=null,c!==void 0&&(n(c),h=""+c),a(s)&&(n(s.key),h=""+s.key),"key"in s){c={};for(var M in s)M!=="key"&&(c[M]=s[M])}else c=s;return h&&l(c,typeof e=="function"?e.displayName||e.name||"Unknown":e),v(e,h,c,i(),P,j)}function f(e){b(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===D&&(e._payload.status==="fulfilled"?b(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function b(e){return typeof e=="object"&&e!==null&&e.$$typeof===y}var p=g,y=Symbol.for("react.transitional.element"),k=Symbol.for("react.portal"),w=Symbol.for("react.fragment"),E=Symbol.for("react.strict_mode"),C=Symbol.for("react.profiler"),ee=Symbol.for("react.consumer"),te=Symbol.for("react.context"),ne=Symbol.for("react.forward_ref"),re=Symbol.for("react.suspense"),ie=Symbol.for("react.suspense_list"),oe=Symbol.for("react.memo"),D=Symbol.for("react.lazy"),se=Symbol.for("react.activity"),ae=Symbol.for("react.client.reference"),L=p.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,W=Object.prototype.hasOwnProperty,le=Array.isArray,I=console.createTask?console.createTask:function(){return null};p={react_stack_bottom_frame:function(e){return e()}};var K,Y={},$=p.react_stack_bottom_frame.bind(p,o)(),H=I(r(o)),B={};R.Fragment=w,R.jsx=function(e,s,c){var m=1e4>L.recentlyCreatedOwnerStacks++;return u(e,s,c,!1,m?Error("react-stack-top-frame"):$,m?I(r(e)):H)},R.jsxs=function(e,s,c){var m=1e4>L.recentlyCreatedOwnerStacks++;return u(e,s,c,!0,m?Error("react-stack-top-frame"):$,m?I(r(e)):H)}}()),R}process.env.NODE_ENV==="production"?A.exports=V():A.exports=G();var z=A.exports;class J{constructor(t){if(this.iframe=null,this.messageListener=null,this.containerElement=null,this.config=t,this.iframeUrl=t.iframeUrl||"http://localhost:3000/iframe/checkout",this.environment=this.getEnvironmentFromApiKey(t.apiKey||""),this.usePopup=!t.container,t.container)if(typeof t.container=="string"){if(this.containerElement=document.querySelector(t.container),!this.containerElement)throw new Error(`Container not found: ${t.container}`)}else this.containerElement=t.container}init(){this.iframe||(this.createIframe(),this.addMessageListener())}createIframe(){const t=new URL(this.iframeUrl);this.config.apiKey&&t.searchParams.set("apiKey",this.config.apiKey),this.config.config?.paymentId&&t.searchParams.set("paymentId",this.config.config.paymentId);const n=t.toString();if(this.usePopup){const r=document.createElement("div");r.id="inflowpay-sdk-overlay",r.style.cssText=`
23
- position: fixed;
24
- top: 0;
25
- left: 0;
26
- width: 100%;
27
- height: 100%;
28
- background-color: rgba(0, 0, 0, 0.5);
29
- display: flex;
30
- align-items: center;
31
- justify-content: center;
32
- z-index: 999999;
33
- `;const i=document.createElement("div");i.style.cssText=`
34
- position: relative;
35
- width: 90%;
36
- max-width: 500px;
37
- height: 90%;
38
- max-height: 600px;
39
- background: white;
40
- border-radius: 8px;
41
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
42
- `;const o=document.createElement("button");o.innerHTML="×",o.style.cssText=`
43
- position: absolute;
44
- top: 10px;
45
- right: 10px;
46
- width: 30px;
47
- height: 30px;
48
- border: none;
49
- background: transparent;
50
- font-size: 24px;
51
- cursor: pointer;
52
- z-index: 1000000;
53
- color: #333;
54
- display: flex;
55
- align-items: center;
56
- justify-content: center;
57
- `,o.onclick=()=>this.close(),this.iframe=document.createElement("iframe"),this.iframe.src=n,this.iframe.style.cssText=`
58
- width: 100%;
59
- height: 100%;
60
- border: none;
61
- border-radius: 8px;
62
- `,this.iframe.setAttribute("allow","payment"),i.appendChild(o),i.appendChild(this.iframe),r.appendChild(i),document.body.appendChild(r),this.showLoader(i),r.addEventListener("click",a=>{a.target===r&&this.close()})}else{if(!this.containerElement)throw new Error("Container element is required for inline mode");if(this.containerElement.innerHTML="",this.containerElement instanceof HTMLElement){const o=this.containerElement.getAttribute("style")||"";o.includes("min-height")||(this.containerElement.style.minHeight="196px"),o.includes("position")||(this.containerElement.style.position="relative"),o.includes("overflow")||(this.containerElement.style.overflow="hidden")}this.iframe=document.createElement("iframe"),this.iframe.src=n;const r=this.config.config?.style?.fillParent?"100%":"344px",i=this.config.config?.style?.fillParent?"none":"100%";this.iframe.style.cssText=`
63
- width: ${r};
64
- max-width: ${i};
65
- height: 196px;
66
- min-height: 196px;
67
- border: none;
68
- display: block;
69
- transition: height 0.2s ease;
70
- `,this.iframe.setAttribute("allow","payment"),this.containerElement.appendChild(this.iframe),this.showLoader(this.containerElement)}}addMessageListener(){this.messageListener=t=>{const n=new URL(this.iframeUrl).origin;let i=t.origin===n;if(i||((this.environment==="sandbox"||this.environment==="development")&&(i=(t.origin.includes("localhost")||t.origin.includes("127.0.0.1"))&&(n.includes("localhost")||n.includes("127.0.0.1"))),i||(i=t.origin==="https://dev.api.inflowpay.com"||t.origin==="https://pre-prod.api.inflowpay.xyz"||t.origin==="https://api.inflowpay.xyz")),!i){this.config.debug&&console.warn("[SDK] Rejected message from unauthorized origin:",t.origin);return}const o=t.data;if(!(!o||!o.type))switch(o.type){case"iframe-ready":this.hideLoader(),this.sendConfigToIframe();break;case"content-height":if(o.height&&this.iframe){const a=Math.max(o.height,196);this.iframe.style.height=`${a}px`,this.containerElement&&(this.containerElement.style.minHeight=`${a}px`)}break;case"close":this.close();break;case"success":this.config.onSuccess&&this.config.onSuccess(o.data);break;case"error":this.config.onError&&this.config.onError(o.data);break;case"3ds-required":this.config.debug&&console.log("[SDK] Received 3DS request:",o.threeDsSessionUrl),o.threeDsSessionUrl?(this.config.debug&&console.log("[SDK] Opening 3DS modal..."),this.open3DSModal(o.threeDsSessionUrl).then(a=>{if(this.config.debug&&console.log("[SDK] 3DS modal closed, result:",a),this.iframe&&this.iframe.contentWindow){const l=this.getTargetOrigin();this.iframe.contentWindow.postMessage({type:"3ds-result",success:a,paymentId:o.paymentId||this.config.config?.paymentId},l)}})):this.config.debug&&console.error("[SDK] 3DS required but no threeDsSessionUrl provided");break;default:this.config.debug&&console.log("SDK: Received message:",o)}},window.addEventListener("message",this.messageListener)}sendConfigToIframe(){if(!this.iframe||!this.iframe.contentWindow){this.iframe&&(this.iframe.onload=()=>{this.sendConfigToIframe()});return}const t={type:"sdkData",config:{...this.config.config||{},paymentId:this.config.config?.paymentId},data:{apiKey:this.config.apiKey}},n=this.getTargetOrigin();this.iframe.contentWindow.postMessage(t,n)}showLoader(t){this.iframe&&(this.iframe.style.display="none");const n=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,r=n?"#2d2d2d":"#F5F5F5",i=n?"#3d3d3d":"#E5E5E5",a=`linear-gradient(90deg, ${i} 25%, ${n?"#4d4d4d":"#F0F0F0"} 50%, ${i} 75%)`,l=document.createElement("div");l.id="inflowpay-loader";const x=this.config.config?.style?.fillParent?"100%":"344px";l.style.cssText=`
71
- position: absolute;
72
- top: 0;
73
- left: 0;
74
- width: 100%;
75
- height: 100%;
76
- z-index: 1000;
77
- padding: 20px;
78
- box-sizing: border-box;
79
- display: flex;
80
- flex-direction: column;
81
- align-items: center;
82
- font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
83
- `;const v=document.createElement("div");v.style.cssText=`
84
- width: ${x};
85
- max-width: 100%;
86
- margin: 0 auto;
87
- font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
88
- `;const u=document.createElement("div");u.style.cssText=`
89
- display: flex;
90
- align-items: center;
91
- justify-content: center;
92
- gap: 6px;
93
- background-color: ${r};
94
- padding: 8px;
95
- border-radius: 8px;
96
- margin-bottom: 20px;
97
- `;const f=document.createElement("div");f.className="inflowpay-skeleton",f.style.cssText=`
98
- flex: 1;
99
- min-width: 0;
100
- height: 32px;
101
- border-radius: 6px;
102
- background: ${a};
103
- background-size: 200% 100%;
104
- animation: inflowpay-shimmer 1.5s infinite;
105
- `;const b=document.createElement("div");b.className="inflowpay-skeleton",b.style.cssText=`
106
- width: 21.5%;
107
- flex-shrink: 0;
108
- height: 32px;
109
- border-radius: 6px;
110
- background: ${a};
111
- background-size: 200% 100%;
112
- animation: inflowpay-shimmer 1.5s infinite;
113
- `;const p=document.createElement("div");p.className="inflowpay-skeleton",p.style.cssText=`
114
- width: 17.5%;
115
- flex-shrink: 0;
116
- height: 32px;
117
- border-radius: 6px;
118
- background: ${a};
119
- background-size: 200% 100%;
120
- animation: inflowpay-shimmer 1.5s infinite;
121
- `,u.appendChild(f),u.appendChild(b),u.appendChild(p);const y=document.createElement("div");y.className="inflowpay-skeleton",y.style.cssText=`
122
- width: 100%;
123
- height: 42px;
124
- border-radius: 8px;
125
- background: ${a};
126
- background-size: 200% 100%;
127
- animation: inflowpay-shimmer 1.5s infinite;
128
- margin-bottom: 16px;
129
- `;const k=document.createElement("div");k.style.cssText=`
130
- display: flex;
131
- flex-direction: column;
132
- align-items: center;
133
- gap: 4px;
134
- width: 100%;
135
- margin-top: 16px;
136
- `;const w=document.createElement("div");w.className="inflowpay-skeleton",w.style.cssText=`
137
- width: 10px;
138
- height: 10px;
139
- border-radius: 50%;
140
- background: ${a};
141
- background-size: 200% 100%;
142
- animation: inflowpay-shimmer 1.5s infinite;
143
- `;const E=document.createElement("div");if(E.className="inflowpay-skeleton",E.style.cssText=`
144
- width: 80%;
145
- height: 16px;
146
- border-radius: 4px;
147
- background: ${a};
148
- background-size: 200% 100%;
149
- animation: inflowpay-shimmer 1.5s infinite;
150
- `,k.appendChild(w),k.appendChild(E),v.appendChild(u),v.appendChild(y),v.appendChild(k),l.appendChild(v),!document.getElementById("inflowpay-loader-styles")){const C=document.createElement("style");C.id="inflowpay-loader-styles",C.textContent=`
151
- @keyframes inflowpay-shimmer {
152
- 0% {
153
- background-position: -200% 0;
154
- }
155
- 100% {
156
- background-position: 200% 0;
157
- }
158
- }
159
- `,document.head.appendChild(C)}t.appendChild(l)}hideLoader(){const t=document.getElementById("inflowpay-loader");t&&t.remove(),this.iframe&&(this.iframe.style.display="")}close(){if(this.config.onClose&&this.config.onClose(),this.hideLoader(),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.usePopup){const t=document.getElementById("inflowpay-sdk-overlay");t&&t.remove()}else this.containerElement&&(this.containerElement.innerHTML="");this.iframe=null}open3DSModal(t){return this.config.debug&&console.log("[SDK] open3DSModal called with URL:",t),new Promise(n=>{const r=document.createElement("div");r.id="inflowpay-3ds-overlay",r.style.cssText=`
160
- position: fixed;
161
- top: 0;
162
- left: 0;
163
- width: 100%;
164
- height: 100%;
165
- background-color: rgba(0, 0, 0, 0.7);
166
- display: flex;
167
- align-items: center;
168
- justify-content: center;
169
- z-index: 999999;
170
- `;const i=document.createElement("div");i.style.cssText=`
171
- position: relative;
172
- width: 90%;
173
- max-width: 500px;
174
- height: 90%;
175
- max-height: 600px;
176
- background: white;
177
- border-radius: 8px;
178
- box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
179
- display: flex;
180
- flex-direction: column;
181
- `;const o=document.createElement("div");o.style.cssText=`
182
- display: flex;
183
- align-items: center;
184
- justify-content: space-between;
185
- padding: 15px 20px;
186
- border-bottom: 1px solid #e5e5e5;
187
- `,o.innerHTML=`
22
+ <%s key={someKey} {...props} />`,f,m,D,m),se[m+f]=!0)}if(m=null,d!==void 0&&(r(d),m=""+d),l(s)&&(r(s.key),m=""+s.key),"key"in s){d={};for(var B in s)B!=="key"&&(d[B]=s[B])}else d=s;return m&&c(d,typeof e=="function"?e.displayName||e.name||"Unknown":e),w(e,m,d,o(),H,G)}function b(e){u(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===Y&&(e._payload.status==="fulfilled"?u(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function u(e){return typeof e=="object"&&e!==null&&e.$$typeof===v}var h=g,v=Symbol.for("react.transitional.element"),C=Symbol.for("react.portal"),R=Symbol.for("react.fragment"),$=Symbol.for("react.strict_mode"),M=Symbol.for("react.profiler"),x=Symbol.for("react.consumer"),Ke=Symbol.for("react.context"),Fe=Symbol.for("react.forward_ref"),$e=Symbol.for("react.suspense"),Ye=Symbol.for("react.suspense_list"),We=Symbol.for("react.memo"),Y=Symbol.for("react.lazy"),ze=Symbol.for("react.activity"),Ge=Symbol.for("react.client.reference"),W=h.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,te=Object.prototype.hasOwnProperty,Be=Array.isArray,z=console.createTask?console.createTask:function(){return null};h={react_stack_bottom_frame:function(e){return e()}};var ne,re={},ie=h.react_stack_bottom_frame.bind(h,i)(),oe=z(a(i)),se={};A.Fragment=R,A.jsx=function(e,s,d){var f=1e4>W.recentlyCreatedOwnerStacks++;return S(e,s,d,!1,f?Error("react-stack-top-frame"):ie,f?z(a(e)):oe)},A.jsxs=function(e,s,d){var f=1e4>W.recentlyCreatedOwnerStacks++;return S(e,s,d,!0,f?Error("react-stack-top-frame"):ie,f?z(a(e)):oe)}}()),A}process.env.NODE_ENV==="production"?j.exports=ae():j.exports=le();var J=j.exports;const P={OVERLAY:999999,MODAL:1e6,LOADER:1e3},p={MIN_HEIGHT:196,CONTAINER_MAX_WIDTH:"500px",CONTAINER_WIDTH_PERCENT:"90%",CONTAINER_HEIGHT_PERCENT:"90%",CONTAINER_MAX_HEIGHT:"600px",BUTTON_SIZE:30,DEFAULT_IFRAME_WIDTH:"344px"},ce=["https://dev.api.inflowpay.xyz","https://pre-prod.api.inflowpay.xyz","https://api.inflowpay.xyz"],I={OVERLAY:"inflowpay-sdk-overlay",LOADER:"inflowpay-loader",LOADER_STYLES:"inflowpay-loader-styles",THREE_DS_OVERLAY:"inflowpay-3ds-overlay"},N={PRODUCTION:"https://iframe.inflowpay.com/iframe/checkout",PREPROD:"https://preprod.iframe.inflowpay.com/iframe/checkout",DEVELOPMENT:"https://dev.iframe.inflowpay.com/iframe/checkout",LOCAL:"http://localhost:3010/iframe/checkout"};function de(n){return{inputBgColor:n?"#2d2d2d":"#F5F5F5",shimmerBase:n?"#3d3d3d":"#E5E5E5",shimmerLight:n?"#4d4d4d":"#F0F0F0"}}function ue(n){return`linear-gradient(90deg, ${n.shimmerBase} 25%, ${n.shimmerLight} 50%, ${n.shimmerBase} 75%)`}function fe(){return`
23
+ position: fixed;
24
+ top: 0;
25
+ left: 0;
26
+ width: 100%;
27
+ height: 100%;
28
+ background-color: rgba(0, 0, 0, 0.5);
29
+ display: flex;
30
+ align-items: center;
31
+ justify-content: center;
32
+ z-index: ${P.OVERLAY};
33
+ `}function me(){return`
34
+ position: relative;
35
+ width: ${p.CONTAINER_WIDTH_PERCENT};
36
+ max-width: ${p.CONTAINER_MAX_WIDTH};
37
+ height: ${p.CONTAINER_HEIGHT_PERCENT};
38
+ max-height: ${p.CONTAINER_MAX_HEIGHT};
39
+ background: white;
40
+ border-radius: 8px;
41
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
42
+ `}function he(){return`
43
+ position: absolute;
44
+ top: 10px;
45
+ right: 10px;
46
+ width: ${p.BUTTON_SIZE}px;
47
+ height: ${p.BUTTON_SIZE}px;
48
+ border: none;
49
+ background: transparent;
50
+ font-size: 24px;
51
+ cursor: pointer;
52
+ z-index: ${P.MODAL};
53
+ color: #333;
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ `}function pe(){return`
58
+ width: 100%;
59
+ height: 100%;
60
+ border: none;
61
+ border-radius: 8px;
62
+ `}function ge(n){return`
63
+ width: ${n?"100%":p.DEFAULT_IFRAME_WIDTH};
64
+ max-width: ${n?"none":"100%"};
65
+ height: ${p.MIN_HEIGHT}px;
66
+ min-height: ${p.MIN_HEIGHT}px;
67
+ border: none;
68
+ display: block;
69
+ transition: height 0.2s ease;
70
+ `}function Ee(){return`
71
+ position: absolute;
72
+ top: 0;
73
+ left: 0;
74
+ width: 100%;
75
+ height: 100%;
76
+ z-index: ${P.LOADER};
77
+ padding: 20px;
78
+ box-sizing: border-box;
79
+ display: flex;
80
+ flex-direction: column;
81
+ align-items: center;
82
+ `}function ye(n){return`
83
+ width: ${n?"100%":p.DEFAULT_IFRAME_WIDTH};
84
+ max-width: 100%;
85
+ margin: 0 auto;
86
+ `}function we(n){return`
87
+ display: flex;
88
+ align-items: center;
89
+ justify-content: center;
90
+ gap: 6px;
91
+ background-color: ${n};
92
+ padding: 8px;
93
+ border-radius: 8px;
94
+ margin-bottom: 20px;
95
+ `}function _(n){return`
96
+ background: ${n};
97
+ background-size: 200% 100%;
98
+ animation: inflowpay-shimmer 1.5s infinite;
99
+ `}function Se(n){return`
100
+ flex: 1;
101
+ min-width: 0;
102
+ height: 32px;
103
+ border-radius: 6px;
104
+ ${_(n)}
105
+ `}function be(n){return`
106
+ width: 21.5%;
107
+ flex-shrink: 0;
108
+ height: 32px;
109
+ border-radius: 6px;
110
+ ${_(n)}
111
+ `}function ve(n){return`
112
+ width: 17.5%;
113
+ flex-shrink: 0;
114
+ height: 32px;
115
+ border-radius: 6px;
116
+ ${_(n)}
117
+ `}function Te(n){return`
118
+ width: 100%;
119
+ height: 42px;
120
+ border-radius: 8px;
121
+ ${_(n)}
122
+ margin-bottom: 16px;
123
+ `}function xe(){return`
124
+ display: flex;
125
+ flex-direction: column;
126
+ align-items: center;
127
+ gap: 4px;
128
+ width: 100%;
129
+ margin-top: 16px;
130
+ `}function Ie(n){return`
131
+ width: 10px;
132
+ height: 10px;
133
+ border-radius: 50%;
134
+ ${_(n)}
135
+ `}function Re(n){return`
136
+ width: 80%;
137
+ height: 16px;
138
+ border-radius: 4px;
139
+ ${_(n)}
140
+ `}const _e=`
141
+ @keyframes inflowpay-shimmer {
142
+ 0% {
143
+ background-position: -200% 0;
144
+ }
145
+ 100% {
146
+ background-position: 200% 0;
147
+ }
148
+ }
149
+ `;function Ce(){return`
150
+ position: fixed;
151
+ top: 0;
152
+ left: 0;
153
+ width: 100%;
154
+ height: 100%;
155
+ background-color: rgba(0, 0, 0, 0.7);
156
+ display: flex;
157
+ align-items: center;
158
+ justify-content: center;
159
+ z-index: ${P.OVERLAY};
160
+ `}function De(){return`
161
+ position: relative;
162
+ width: ${p.CONTAINER_WIDTH_PERCENT};
163
+ max-width: ${p.CONTAINER_MAX_WIDTH};
164
+ height: ${p.CONTAINER_HEIGHT_PERCENT};
165
+ max-height: ${p.CONTAINER_MAX_HEIGHT};
166
+ background: white;
167
+ border-radius: 16px;
168
+ overflow: hidden;
169
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
170
+ display: flex;
171
+ flex-direction: column;
172
+ `}function Oe(){return`
173
+ display: flex;
174
+ align-items: center;
175
+ justify-content: space-between;
176
+ padding: 15px 20px;
177
+ border-bottom: 1px solid #e5e5e5;
178
+ `}function Ae(){return`
179
+ flex: 1;
180
+ position: relative;
181
+ overflow-y: auto;
182
+ overflow-x: hidden;
183
+ `}function ke(){return`
184
+ width: 100%;
185
+ height: 100%;
186
+ border: none;
187
+ `}class Z{constructor(t,r={}){this.loaderElement=null,this.container=t,this.config=r}show(t){t&&(t.style.display="none");const r=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,a=de(r),o=ue(a),i=document.createElement("div");i.id=I.LOADER,i.style.cssText=Ee();const l=document.createElement("div");l.style.cssText=ye(this.config.fillParent||!1);const c=document.createElement("div");c.style.cssText=we(a.inputBgColor);const y=document.createElement("div");y.className="inflowpay-skeleton",y.style.cssText=Se(o);const w=document.createElement("div");w.className="inflowpay-skeleton",w.style.cssText=be(o);const S=document.createElement("div");S.className="inflowpay-skeleton",S.style.cssText=ve(o),c.appendChild(y),c.appendChild(w),c.appendChild(S);const b=document.createElement("div");b.className="inflowpay-skeleton",b.style.cssText=Te(o);const u=document.createElement("div");u.style.cssText=xe();const h=document.createElement("div");h.className="inflowpay-skeleton",h.style.cssText=Ie(o);const v=document.createElement("div");v.className="inflowpay-skeleton",v.style.cssText=Re(o),u.appendChild(h),u.appendChild(v),l.appendChild(c),l.appendChild(b),l.appendChild(u),i.appendChild(l),this.injectShimmerStyles(),this.container.appendChild(i),this.loaderElement=i}hide(t){const r=document.getElementById(I.LOADER);r&&r.remove(),this.loaderElement=null,t&&(t.style.display="")}injectShimmerStyles(){if(!document.getElementById(I.LOADER_STYLES)){const t=document.createElement("style");t.id=I.LOADER_STYLES,t.textContent=_e,document.head.appendChild(t)}}}const E=class E{constructor(t){this.config=t}open(t,r,a){return this.config.debug&&(console.log("[SDK] open3DSModal called with URL:",t),console.log("[SDK] Session ID:",r,"Payment ID:",a)),E.activeModal&&(console.warn("[SDK] Closing existing modal before opening new one"),E.activeModal.overlay.remove(),E.activeModal=null),new Promise(o=>{const i=document.createElement("div");i.id=I.THREE_DS_OVERLAY,i.style.cssText=Ce();const l=document.createElement("div");l.style.cssText=De();const c=document.createElement("div");c.style.cssText=Oe(),c.innerHTML=`
188
188
  <h3 style="margin: 0; font-size: 18px; font-weight: 600;">Secure Payment Authentication</h3>
189
- <button id="inflowpay-3ds-close" style="background: none; border: none; font-size: 24px; cursor: pointer; padding: 0; width: 30px; height: 30px; display: flex; align-items: center; justify-content: center; color: #333;">×</button>
190
- `;const a=document.createElement("div");a.style.cssText=`
191
- flex: 1;
192
- position: relative;
193
- overflow: hidden;
194
- `;const l=document.createElement("iframe");l.src=t,l.style.cssText=`
195
- width: 100%;
196
- height: 100%;
197
- border: none;
198
- `,l.setAttribute("allow","payment"),l.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups"),a.appendChild(l),i.appendChild(o),i.appendChild(a),r.appendChild(i),document.body.appendChild(r);const x=r.querySelector("#inflowpay-3ds-close"),v=()=>{r.remove(),window.removeEventListener("message",u),n(!1)};x?.addEventListener("click",v);const u=f=>{if(!f.data)return;const b=["https://dev.api.inflowpay.com","https://pre-prod.api.inflowpay.xyz","https://api.inflowpay.xyz"];if(this.environment==="sandbox"||this.environment==="development"){if(!(f.origin.includes("localhost")||f.origin.includes("127.0.0.1"))){if(!b.includes(f.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",f.origin);return}}}else if(!b.includes(f.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",f.origin);return}const p=f.data,y=p.type==="THREE_DS_COMPLETE"||p.type==="3ds-complete",k=p.status==="success",w=p.status==="failed"||p.status==="failure";if(y&&k){r.remove(),window.removeEventListener("message",u),n(!0);return}if(k&&!y){r.remove(),window.removeEventListener("message",u),n(!0);return}if(y&&w||p.type==="3ds-failed"||w){r.remove(),window.removeEventListener("message",u),n(!1);return}};window.addEventListener("message",u)})}getTargetOrigin(){return this.environment==="production"||this.environment==="preprod"?new URL(this.iframeUrl).origin:"*"}getEnvironmentFromApiKey(t){return!t||t.includes("_local_")||t.startsWith("inflow_local_")?"sandbox":t.includes("_prod_")&&!t.includes("_preprod_")?"production":t.includes("_preprod_")||t.startsWith("inflow_preprod_")?"preprod":t.includes("_dev_")?"development":"sandbox"}destroy(){this.close()}}let q=class{constructor(t,n){this.mounted=!1;let r;if(typeof n.container=="string"){if(r=document.querySelector(n.container),!r)throw new Error(`Container not found: ${n.container}`)}else r=n.container;this.container=r,this.sdk=new J({iframeUrl:t.iframeUrl,apiKey:t.apiKey,container:this.container,config:{paymentId:n.paymentId,...n.style&&{style:n.style},...n.buttonText&&{buttonText:n.buttonText},...n.placeholders&&{placeholders:n.placeholders}},onSuccess:i=>{n.onComplete&&n.onComplete({status:i?.data?.transaction?.status||"CHECKOUT_SUCCESS",data:i})},onError:i=>{n.onError?n.onError(i):n.onComplete&&n.onComplete({status:"PAYMENT_FAILED",error:i})},onClose:()=>{n.onClose&&n.onClose()}})}mount(){if(this.mounted)throw new Error("CardElement is already mounted");this.sdk.init(),this.mounted=!0}destroy(){this.mounted&&(this.sdk.destroy(),this.mounted=!1)}};class F{constructor(t){if(!t.apiKey||typeof t.apiKey!="string")throw new Error("API key is required");let n=t.iframeUrl;const r=this.getEnvironmentFromApiKey(t.apiKey);n||(r==="production"?n="https://api.inflowpay.xyz/iframe/checkout":r==="preprod"?n="https://pre-prod.api.inflowpay.xyz/iframe/checkout":r==="development"?n="https://dev.api.inflowpay.com/iframe/checkout":n="http://localhost:3000/iframe/checkout");const i=t.debug??!1;i&&(r==="production"||r==="preprod")&&console.warn("[InflowPay SDK] Debug mode is not allowed in production/pre-prod environments. Debug mode disabled.");const o=i&&(r==="sandbox"||r==="development");this.config={apiKey:t.apiKey,iframeUrl:n,timeout:t.timeout??3e4,debug:o}}createCardElement(t){return new q(this.config,t)}getIframeUrl(){return this.config.iframeUrl}getApiKey(){return this.config.apiKey}getEnvironmentFromApiKey(t){return t.includes("_local_")||t.startsWith("inflow_local_")?"sandbox":t.includes("_prod_")&&!t.includes("_preprod_")?"production":t.includes("_preprod_")||t.startsWith("inflow_preprod_")?"preprod":t.includes("_dev_")?"development":"sandbox"}}const O=g.createContext(null);function X({config:d,children:t}){const[n]=g.useState(()=>{const r={apiKey:d.apiKey,iframeUrl:d.iframeUrl,timeout:d.timeout,debug:d.debug};return new F(r)});return z.jsx(O.Provider,{value:{sdk:n},children:t})}function Z(){const d=g.useContext(O);if(!d)throw new Error("useInflowPay must be used within InflowPayProvider");return d.sdk}function Q({paymentId:d,onReady:t,onChange:n,onComplete:r,onError:i,style:o,buttonText:a,placeholders:l,config:x}){const v=g.useContext(O),u=g.useRef(null),f=g.useRef(null),[b,p]=g.useState(!1),y=v?.sdk||(x?new F({apiKey:x.apiKey,iframeUrl:x.iframeUrl,timeout:x.timeout,debug:x.debug}):null);if(!y)throw new Error("CardElement must be used within InflowPayProvider or have a config prop");return g.useEffect(()=>{if(!u.current)return;u.current.id||(u.current.id=`inflowpay-card-element-${Date.now()}`);const k={container:u.current,paymentId:d,...o&&{style:o},...a&&{buttonText:a},...l&&{placeholders:l},onComplete:E=>{r&&r(E)},onError:E=>{i?i(E):r&&r({status:"PAYMENT_FAILED",error:E})},onClose:()=>{}},w=y.createCardElement(k);if(f.current=w,w.mount(),p(!0),t){const E=setTimeout(()=>{t()},100);return()=>clearTimeout(E)}},[d,y,r,i,t,o,a,l]),g.useEffect(()=>{n&&b&&n({complete:!1})},[b,n]),g.useEffect(()=>()=>{f.current&&(f.current.destroy(),f.current=null)},[]),z.jsx("div",{ref:u,style:{width:o?.fillParent?"100%":"344px"}})}_.CardElement=Q,_.InflowPayProvider=X,_.useInflowPay=Z,Object.defineProperty(_,Symbol.toStringTag,{value:"Module"})});
189
+ `;const y=document.createElement("div");y.style.cssText=Ae();const w=document.createElement("iframe");w.src=t,w.style.cssText=ke(),w.setAttribute("allow","payment"),w.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups"),y.appendChild(w),l.appendChild(c),l.appendChild(y),i.appendChild(l),document.body.appendChild(i),E.activeModal={overlay:i,sessionId:r,paymentId:a};const S=b=>{if(!b.data)return;if(!this.isAllowedOrigin(b.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",b.origin);return}const u=b.data,h=u.type==="THREE_DS_COMPLETE"||u.type==="3ds-complete",v=u.status==="success",C=u.status==="failed"||u.status==="failure";if(h&&v){i.remove(),window.removeEventListener("message",S),o(!0);return}if(v&&!h){i.remove(),window.removeEventListener("message",S),o(!0);return}if(h&&C||u.type==="3ds-failed"||C){i.remove(),window.removeEventListener("message",S),o(!1);return}};window.addEventListener("message",S)})}static close(t){if(!E.activeModal){console.log("[SDK] No active modal to close");return}if(t&&E.activeModal.sessionId!==t){console.warn(`[SDK] Session ID mismatch: webhook for ${t}, but modal is for ${E.activeModal.sessionId}. Ignoring close request.`);return}console.log("[SDK] Closing modal for session:",t||E.activeModal.sessionId),E.activeModal.overlay.remove(),E.activeModal=null}static isModalOpen(){return E.activeModal!==null}static getCurrentSessionId(){return E.activeModal?.sessionId||null}isAllowedOrigin(t){return!!(ce.includes(t)||(this.config.environment==="sandbox"||this.config.environment==="development")&&(t.includes("localhost")||t.includes("127.0.0.1")))}};E.activeModal=null;let k=E;class U{static createOverlay(t,r){const a=document.createElement("div");a.id=I.OVERLAY,a.style.cssText=fe();const o=document.createElement("div");o.style.cssText=me();const i=document.createElement("button");i.innerHTML="×",i.style.cssText=he(),i.onclick=r;const l=document.createElement("iframe");return l.src=t,l.style.cssText=pe(),l.setAttribute("allow","payment"),o.appendChild(i),o.appendChild(l),a.appendChild(o),a.addEventListener("click",c=>{c.target===a&&r()}),{overlay:a,container:o,iframe:l}}static removeOverlay(){const t=document.getElementById(I.OVERLAY);t&&t.remove()}}const Le=["en","de","es","fr","it","nl","pl","pt"];function Pe(){if(typeof window>"u")return"en";try{const t=(navigator.language||navigator.userLanguage||"").split("-")[0].toLowerCase();if(Le.includes(t))return t}catch{}return"en"}function K(n){return n.includes("_local_")||n.startsWith("inflow_local_")?"sandbox":n.includes("_prod_")&&!n.includes("_preprod_")?"production":n.includes("_preprod_")||n.startsWith("inflow_preprod_")?"preprod":n.includes("_dev_")?"development":"sandbox"}function q(n){switch(K(n)){case"production":return N.PRODUCTION;case"preprod":return N.PREPROD;case"development":return N.DEVELOPMENT;case"sandbox":default:return N.LOCAL}}class Ne{constructor(t){if(this.iframe=null,this.messageListener=null,this.containerElement=null,this.loaderManager=null,this.config=t,this.iframeUrl=t.iframeUrl||q(t.publicKey||""),this.environment=K(t.publicKey||""),this.usePopup=!t.container,t.container)if(typeof t.container=="string"){if(this.containerElement=document.querySelector(t.container),!this.containerElement)throw new Error(`Container not found: ${t.container}`)}else this.containerElement=t.container;this.modalManager=new k({environment:this.environment,debug:this.config.debug})}init(){this.iframe||(this.createIframe(),this.addMessageListener())}createIframe(){const t=new URL(this.iframeUrl);this.config.publicKey&&t.searchParams.set("publicKey",this.config.publicKey),this.config.config?.paymentId&&t.searchParams.set("paymentId",this.config.config.paymentId),this.config.locale&&t.searchParams.set("locale",this.config.locale);const r=t.toString();if(this.usePopup){const{overlay:a,container:o,iframe:i}=U.createOverlay(r,()=>this.close());this.iframe=i,document.body.appendChild(a),this.loaderManager=new Z(o,{fillParent:this.config.config?.style?.fillParent}),this.loaderManager.show(this.iframe)}else{if(!this.containerElement)throw new Error("Container element is required for inline mode");if(this.containerElement.innerHTML="",this.containerElement instanceof HTMLElement){const a=this.containerElement.getAttribute("style")||"";a.includes("min-height")||(this.containerElement.style.minHeight=`${p.MIN_HEIGHT}px`),a.includes("position")||(this.containerElement.style.position="relative"),a.includes("overflow")||(this.containerElement.style.overflow="hidden")}this.iframe=document.createElement("iframe"),this.iframe.src=r,this.iframe.style.cssText=ge(this.config.config?.style?.fillParent||!1),this.iframe.setAttribute("allow","payment"),this.containerElement.appendChild(this.iframe),this.loaderManager=new Z(this.containerElement,{fillParent:this.config.config?.style?.fillParent}),this.loaderManager.show(this.iframe)}}addMessageListener(){this.messageListener=t=>{const r=new URL(this.iframeUrl).origin;let o=t.origin===r;if(o||((this.environment==="sandbox"||this.environment==="development")&&(o=(t.origin.includes("localhost")||t.origin.includes("127.0.0.1"))&&(r.includes("localhost")||r.includes("127.0.0.1"))),o||(o=t.origin==="https://dev.iframe.inflowpay.com"||t.origin==="https://pre-prod.iframe.inflowpay.xyz"||t.origin==="https://iframe.inflowpay.xyz")),!o){this.config.debug&&console.warn("[SDK] Rejected message from unauthorized origin:",t.origin);return}const i=t.data;if(!(!i||!i.type))switch(i.type){case"iframe-ready":this.loaderManager&&this.loaderManager.hide(this.iframe||void 0),this.sendConfigToIframe();break;case"content-height":if(i.height&&this.iframe){const l=Math.max(i.height,p.MIN_HEIGHT);this.iframe.style.height=`${l}px`,this.containerElement&&(this.containerElement.style.minHeight=`${l}px`)}break;case"close":this.close();break;case"success":this.config.onSuccess&&this.config.onSuccess(i.data);break;case"error":this.config.onError&&this.config.onError(i.data);break;case"3ds-required":if(this.config.debug&&(console.log("[SDK] Received 3DS request:",i.threeDsSessionUrl),console.log("[SDK] Session ID:",i.sessionId)),i.threeDsSessionUrl){const l=i.sessionId,c=i.paymentId||this.config.config?.paymentId||"";i.sessionId||console.warn("[SDK] No session ID provided by iframe"),this.config.debug&&console.log("[SDK] Opening 3DS modal with session ID:",l),this.modalManager.open(i.threeDsSessionUrl,l,c).then(y=>{this.config.debug&&console.log("[SDK] 3DS modal closed, result:",y)})}else this.config.debug&&console.error("[SDK] 3DS required but no threeDsSessionUrl provided");break;case"3ds-success":this.config.debug&&(console.log("[SDK] 3DS completed, closing modal..."),console.log("[SDK] Session ID from webhook:",i.sessionId)),k.close(i.sessionId);break;case"3ds-failed":this.config.debug&&(console.log("[SDK] 3DS failed, closing modal..."),console.log("[SDK] Session ID from webhook:",i.sessionId)),k.close(i.sessionId);break;default:this.config.debug&&console.log("SDK: Received message:",i)}},window.addEventListener("message",this.messageListener)}sendConfigToIframe(){if(!this.iframe||!this.iframe.contentWindow){this.iframe&&(this.iframe.onload=()=>{this.sendConfigToIframe()});return}const t={type:"sdkData",config:{...this.config.config||{},paymentId:this.config.config?.paymentId},data:{publicKey:this.config.publicKey}},r=this.getTargetOrigin();this.iframe.contentWindow.postMessage(t,r)}close(){this.config.onClose&&this.config.onClose(),this.loaderManager&&(this.loaderManager.hide(this.iframe||void 0),this.loaderManager=null),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.usePopup?U.removeOverlay():this.containerElement&&(this.containerElement.innerHTML=""),this.iframe=null}switchToSuccessState(t){if(this.loaderManager&&(this.loaderManager.hide(this.iframe||void 0),this.loaderManager=null),this.messageListener&&(window.removeEventListener("message",this.messageListener),this.messageListener=null),this.usePopup){U.removeOverlay(),this.iframe=null;return}const r=this.config.config?.showDefaultSuccessUI??!0;!r&&this.containerElement&&(this.containerElement.innerHTML=""),r||(this.iframe=null)}getTargetOrigin(){return this.environment==="production"||this.environment==="preprod"?new URL(this.iframeUrl).origin:"*"}destroy(){this.close()}}let Me=class{constructor(t,r){this.mounted=!1;let a;if(typeof r.container=="string"){if(a=document.querySelector(r.container),!a)throw new Error(`Container not found: ${r.container}`)}else a=r.container;this.container=a,this.sdk=new Ne({publicKey:t.publicKey,container:this.container,locale:t.locale??Pe(),config:{paymentId:r.paymentId,...r.style&&{style:r.style},...r.buttonText&&{buttonText:r.buttonText},...r.placeholders&&{placeholders:r.placeholders},...r.showDefaultSuccessUI!==void 0&&{showDefaultSuccessUI:r.showDefaultSuccessUI}},onSuccess:o=>{r.onComplete&&r.onComplete({status:L.SUCCESS,paymentId:r.paymentId}),this.sdk.switchToSuccessState(o)},onError:o=>{r.onError?r.onError(o):r.onComplete&&r.onComplete({status:L.FAILED,paymentId:r.paymentId,error:o})},onClose:()=>{r.onClose&&r.onClose()}})}mount(){if(this.mounted)throw new Error("CardElement is already mounted");this.sdk.init(),this.mounted=!0}destroy(){this.mounted&&(this.sdk.destroy(),this.mounted=!1)}};class Q{constructor(t){if(!t.publicKey||typeof t.publicKey!="string")throw new Error("API key is required");this.config=t,this.timeout=3e4,this.iframeUrl=q(t.publicKey);const r=K(t.publicKey);this.debug=r==="sandbox"||r==="development"}createCardElement(t){return new Me({publicKey:this.config.publicKey,iframeUrl:this.iframeUrl,timeout:this.timeout,debug:this.debug,locale:this.config.locale},t)}getIframeUrl(){return this.iframeUrl}getApiKey(){return this.config.publicKey}}var L=(n=>(n.SUCCESS="SUCCESS",n.FAILED="FAILED",n))(L||{}),ee=(n=>(n.THREE_DS_FAILED="THREE_DS_FAILED",n.PAYMENT_PROCESSING_ERROR="PAYMENT_PROCESSING_ERROR",n))(ee||{});const F=g.createContext(null);function He({config:n,children:t}){const[r]=g.useState(()=>{const a={publicKey:n.publicKey,locale:n.locale};return new Q(a)});return J.jsx(F.Provider,{value:{sdk:r},children:t})}function je(){const n=g.useContext(F);if(!n)throw new Error("useInflowPay must be used within InflowPayProvider");return n.sdk}function Ue(n){const{paymentId:t,onReady:r,onChange:a,onComplete:o,onError:i,style:l,buttonText:c,placeholders:y,showDefaultSuccessUI:w,config:S}=n,b=g.useContext(F),u=g.useRef(null),h=g.useRef(null),[v,C]=g.useState(!1),R=b?.sdk||(S?new Q({publicKey:S.publicKey,locale:S.locale}):null);if(!R)throw new Error("CardElement must be used within InflowPayProvider or have a config prop");return g.useEffect(()=>{if(!u.current)return;u.current.id||(u.current.id=`inflowpay-card-element-${Date.now()}`);const $={container:u.current,paymentId:t,...l&&{style:l},...c&&{buttonText:c},...y&&{placeholders:y},...w!==void 0&&{showDefaultSuccessUI:w},onComplete:x=>{o&&o(x)},onError:x=>{i?i(x):o&&o({status:L.FAILED,paymentId:t,error:x})},onClose:()=>{}},M=R.createCardElement($);if(h.current=M,M.mount(),C(!0),r){const x=setTimeout(()=>{r()},100);return()=>clearTimeout(x)}},[t,R,o,i,r,l,c,y,w]),g.useEffect(()=>{a&&v&&a({complete:!1})},[v,a]),g.useEffect(()=>()=>{h.current&&(h.current.destroy(),h.current=null)},[]),J.jsx("div",{ref:u,style:{width:l?.fillParent?"100%":"344px"}})}T.CardElement=Ue,T.InflowPayProvider=He,T.PaymentResultErrorCode=ee,T.PaymentResultStatus=L,T.useInflowPay=je,Object.defineProperty(T,Symbol.toStringTag,{value:"Module"})});
199
190
  //# sourceMappingURL=react.umd.js.map