@inflow_pay/sdk 0.1.0 → 0.2.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.
@@ -1,4 +1,4 @@
1
- class y {
1
+ class x {
2
2
  constructor(e) {
3
3
  if (this.iframe = null, this.messageListener = null, this.containerElement = null, this.config = e, this.iframeUrl = e.iframeUrl || "http://localhost:3000/iframe/checkout", this.environment = this.getEnvironmentFromApiKey(e.apiKey || ""), this.usePopup = !e.container, e.container)
4
4
  if (typeof e.container == "string") {
@@ -66,15 +66,15 @@ class y {
66
66
  height: 100%;
67
67
  border: none;
68
68
  border-radius: 8px;
69
- `, this.iframe.setAttribute("allow", "payment"), n.appendChild(s), n.appendChild(this.iframe), i.appendChild(n), document.body.appendChild(i), i.addEventListener("click", (r) => {
70
- r.target === i && this.close();
69
+ `, this.iframe.setAttribute("allow", "payment"), n.appendChild(s), n.appendChild(this.iframe), i.appendChild(n), document.body.appendChild(i), this.showLoader(n), i.addEventListener("click", (o) => {
70
+ o.target === i && this.close();
71
71
  });
72
72
  } else {
73
73
  if (!this.containerElement)
74
74
  throw new Error("Container element is required for inline mode");
75
75
  if (this.containerElement.innerHTML = "", this.containerElement instanceof HTMLElement) {
76
76
  const s = this.containerElement.getAttribute("style") || "";
77
- s.includes("min-height") || (this.containerElement.style.minHeight = "175px"), s.includes("position") || (this.containerElement.style.position = "relative"), s.includes("overflow") || (this.containerElement.style.overflow = "hidden");
77
+ s.includes("min-height") || (this.containerElement.style.minHeight = "196px"), s.includes("position") || (this.containerElement.style.position = "relative"), s.includes("overflow") || (this.containerElement.style.overflow = "hidden");
78
78
  }
79
79
  this.iframe = document.createElement("iframe"), this.iframe.src = t;
80
80
  const i = this.config.config?.style?.fillParent ? "100%" : "344px", n = this.config.config?.style?.fillParent ? "none" : "100%";
@@ -82,10 +82,10 @@ class y {
82
82
  width: ${i};
83
83
  max-width: ${n};
84
84
  height: 100%;
85
- min-height: 175px;
85
+ min-height: 196px;
86
86
  border: none;
87
87
  display: block;
88
- `, this.iframe.setAttribute("allow", "payment"), this.containerElement.appendChild(this.iframe);
88
+ `, this.iframe.setAttribute("allow", "payment"), this.containerElement.appendChild(this.iframe), this.showLoader(this.containerElement);
89
89
  }
90
90
  }
91
91
  /**
@@ -103,7 +103,7 @@ class y {
103
103
  if (!(!s || !s.type))
104
104
  switch (s.type) {
105
105
  case "iframe-ready":
106
- this.sendConfigToIframe();
106
+ this.hideLoader(), this.sendConfigToIframe();
107
107
  break;
108
108
  case "close":
109
109
  this.close();
@@ -115,14 +115,14 @@ class y {
115
115
  this.config.onError && this.config.onError(s.data);
116
116
  break;
117
117
  case "3ds-required":
118
- this.config.debug && console.log("[SDK] Received 3DS request:", s.threeDsSessionUrl), s.threeDsSessionUrl ? (this.config.debug && console.log("[SDK] Opening 3DS modal..."), this.open3DSModal(s.threeDsSessionUrl).then((r) => {
119
- if (this.config.debug && console.log("[SDK] 3DS modal closed, result:", r), this.iframe && this.iframe.contentWindow) {
120
- const a = this.getTargetOrigin();
118
+ this.config.debug && console.log("[SDK] Received 3DS request:", s.threeDsSessionUrl), s.threeDsSessionUrl ? (this.config.debug && console.log("[SDK] Opening 3DS modal..."), this.open3DSModal(s.threeDsSessionUrl).then((o) => {
119
+ if (this.config.debug && console.log("[SDK] 3DS modal closed, result:", o), this.iframe && this.iframe.contentWindow) {
120
+ const r = this.getTargetOrigin();
121
121
  this.iframe.contentWindow.postMessage({
122
122
  type: "3ds-result",
123
- success: r,
123
+ success: o,
124
124
  paymentId: s.paymentId || this.config.config?.paymentId
125
- }, a);
125
+ }, r);
126
126
  }
127
127
  })) : this.config.debug && console.error("[SDK] 3DS required but no threeDsSessionUrl provided");
128
128
  break;
@@ -153,15 +153,143 @@ class y {
153
153
  }, t = this.getTargetOrigin();
154
154
  this.iframe.contentWindow.postMessage(e, t);
155
155
  }
156
+ /**
157
+ * Show skeleton loader while iframe is connecting
158
+ */
159
+ showLoader(e) {
160
+ this.iframe && (this.iframe.style.display = "none");
161
+ const t = window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches, i = t ? "#2d2d2d" : "#F5F5F5", n = t ? "#3d3d3d" : "#E5E5E5", o = `linear-gradient(90deg, ${n} 25%, ${t ? "#4d4d4d" : "#F0F0F0"} 50%, ${n} 75%)`, r = document.createElement("div");
162
+ r.id = "inflowpay-loader";
163
+ const u = this.config.config?.style?.fillParent ? "100%" : "344px";
164
+ r.style.cssText = `
165
+ position: absolute;
166
+ top: 0;
167
+ left: 0;
168
+ width: 100%;
169
+ height: 100%;
170
+ z-index: 1000;
171
+ padding: 20px;
172
+ box-sizing: border-box;
173
+ display: flex;
174
+ flex-direction: column;
175
+ align-items: center;
176
+ font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
177
+ `;
178
+ const c = document.createElement("div");
179
+ c.style.cssText = `
180
+ width: ${u};
181
+ max-width: 100%;
182
+ margin: 0 auto;
183
+ font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
184
+ `;
185
+ const l = document.createElement("div");
186
+ l.style.cssText = `
187
+ display: flex;
188
+ align-items: center;
189
+ justify-content: center;
190
+ gap: 6px;
191
+ background-color: ${i};
192
+ padding: 8px;
193
+ border-radius: 8px;
194
+ margin-bottom: 20px;
195
+ `;
196
+ const a = document.createElement("div");
197
+ a.className = "inflowpay-skeleton", a.style.cssText = `
198
+ flex: 1;
199
+ min-width: 0;
200
+ height: 32px;
201
+ border-radius: 6px;
202
+ background: ${o};
203
+ background-size: 200% 100%;
204
+ animation: inflowpay-shimmer 1.5s infinite;
205
+ `;
206
+ const p = document.createElement("div");
207
+ p.className = "inflowpay-skeleton", p.style.cssText = `
208
+ width: 21.5%;
209
+ flex-shrink: 0;
210
+ height: 32px;
211
+ border-radius: 6px;
212
+ background: ${o};
213
+ background-size: 200% 100%;
214
+ animation: inflowpay-shimmer 1.5s infinite;
215
+ `;
216
+ const d = document.createElement("div");
217
+ d.className = "inflowpay-skeleton", d.style.cssText = `
218
+ width: 17.5%;
219
+ flex-shrink: 0;
220
+ height: 32px;
221
+ border-radius: 6px;
222
+ background: ${o};
223
+ background-size: 200% 100%;
224
+ animation: inflowpay-shimmer 1.5s infinite;
225
+ `, l.appendChild(a), l.appendChild(p), l.appendChild(d);
226
+ const m = document.createElement("div");
227
+ m.className = "inflowpay-skeleton", m.style.cssText = `
228
+ width: 100%;
229
+ height: 42px;
230
+ border-radius: 8px;
231
+ background: ${o};
232
+ background-size: 200% 100%;
233
+ animation: inflowpay-shimmer 1.5s infinite;
234
+ margin-bottom: 16px;
235
+ `;
236
+ const h = document.createElement("div");
237
+ h.style.cssText = `
238
+ display: flex;
239
+ flex-direction: column;
240
+ align-items: center;
241
+ gap: 4px;
242
+ width: 100%;
243
+ margin-top: 16px;
244
+ `;
245
+ const f = document.createElement("div");
246
+ f.className = "inflowpay-skeleton", f.style.cssText = `
247
+ width: 10px;
248
+ height: 10px;
249
+ border-radius: 50%;
250
+ background: ${o};
251
+ background-size: 200% 100%;
252
+ animation: inflowpay-shimmer 1.5s infinite;
253
+ `;
254
+ const g = document.createElement("div");
255
+ if (g.className = "inflowpay-skeleton", g.style.cssText = `
256
+ width: 80%;
257
+ height: 16px;
258
+ border-radius: 4px;
259
+ background: ${o};
260
+ background-size: 200% 100%;
261
+ animation: inflowpay-shimmer 1.5s infinite;
262
+ `, h.appendChild(f), h.appendChild(g), c.appendChild(l), c.appendChild(m), c.appendChild(h), r.appendChild(c), !document.getElementById("inflowpay-loader-styles")) {
263
+ const y = document.createElement("style");
264
+ y.id = "inflowpay-loader-styles", y.textContent = `
265
+ @keyframes inflowpay-shimmer {
266
+ 0% {
267
+ background-position: -200% 0;
268
+ }
269
+ 100% {
270
+ background-position: 200% 0;
271
+ }
272
+ }
273
+ `, document.head.appendChild(y);
274
+ }
275
+ e.appendChild(r);
276
+ }
277
+ /**
278
+ * Hide loader
279
+ */
280
+ hideLoader() {
281
+ const e = document.getElementById("inflowpay-loader");
282
+ e && e.remove(), this.iframe && (this.iframe.style.display = "");
283
+ }
156
284
  /**
157
285
  * Close the iframe and cleanup
158
286
  */
159
287
  close() {
160
- if (this.config.onClose && this.config.onClose(), this.messageListener && (window.removeEventListener("message", this.messageListener), this.messageListener = null), this.usePopup) {
288
+ if (this.config.onClose && this.config.onClose(), this.hideLoader(), this.messageListener && (window.removeEventListener("message", this.messageListener), this.messageListener = null), this.usePopup) {
161
289
  const e = document.getElementById("inflowpay-sdk-overlay");
162
290
  e && e.remove();
163
291
  } else
164
- this.containerElement && this.iframe && this.containerElement.removeChild(this.iframe);
292
+ this.containerElement && (this.containerElement.innerHTML = "");
165
293
  this.iframe = null;
166
294
  }
167
295
  /**
@@ -207,55 +335,55 @@ class y {
207
335
  <h3 style="margin: 0; font-size: 18px; font-weight: 600;">Secure Payment Authentication</h3>
208
336
  <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>
209
337
  `;
210
- const r = document.createElement("div");
211
- r.style.cssText = `
338
+ const o = document.createElement("div");
339
+ o.style.cssText = `
212
340
  flex: 1;
213
341
  position: relative;
214
342
  overflow: hidden;
215
343
  `;
216
- const a = document.createElement("iframe");
217
- a.src = e, a.style.cssText = `
344
+ const r = document.createElement("iframe");
345
+ r.src = e, r.style.cssText = `
218
346
  width: 100%;
219
347
  height: 100%;
220
348
  border: none;
221
- `, a.setAttribute("allow", "payment"), a.setAttribute("sandbox", "allow-forms allow-scripts allow-same-origin allow-popups"), r.appendChild(a), n.appendChild(s), n.appendChild(r), i.appendChild(n), document.body.appendChild(i);
222
- const u = i.querySelector("#inflowpay-3ds-close"), g = () => {
223
- i.remove(), window.removeEventListener("message", d), t(!1);
349
+ `, r.setAttribute("allow", "payment"), r.setAttribute("sandbox", "allow-forms allow-scripts allow-same-origin allow-popups"), o.appendChild(r), n.appendChild(s), n.appendChild(o), i.appendChild(n), document.body.appendChild(i);
350
+ const u = i.querySelector("#inflowpay-3ds-close"), c = () => {
351
+ i.remove(), window.removeEventListener("message", l), t(!1);
224
352
  };
225
- u?.addEventListener("click", g);
226
- const d = (o) => {
227
- if (!o.data) return;
228
- const f = [
353
+ u?.addEventListener("click", c);
354
+ const l = (a) => {
355
+ if (!a.data) return;
356
+ const p = [
229
357
  "https://dev.api.inflowpay.com",
230
358
  "https://pre-prod.api.inflowpay.xyz",
231
359
  "https://api.inflowpay.xyz"
232
360
  ];
233
361
  if (this.environment === "sandbox" || this.environment === "development") {
234
- if (!(o.origin.includes("localhost") || o.origin.includes("127.0.0.1"))) {
235
- if (!f.includes(o.origin)) {
236
- this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", o.origin);
362
+ if (!(a.origin.includes("localhost") || a.origin.includes("127.0.0.1"))) {
363
+ if (!p.includes(a.origin)) {
364
+ this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", a.origin);
237
365
  return;
238
366
  }
239
367
  }
240
- } else if (!f.includes(o.origin)) {
241
- this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", o.origin);
368
+ } else if (!p.includes(a.origin)) {
369
+ this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", a.origin);
242
370
  return;
243
371
  }
244
- const l = o.data, c = l.type === "THREE_DS_COMPLETE" || l.type === "3ds-complete", m = l.status === "success", p = l.status === "failed" || l.status === "failure";
245
- if (c && m) {
246
- i.remove(), window.removeEventListener("message", d), t(!0);
372
+ const d = a.data, m = d.type === "THREE_DS_COMPLETE" || d.type === "3ds-complete", h = d.status === "success", f = d.status === "failed" || d.status === "failure";
373
+ if (m && h) {
374
+ i.remove(), window.removeEventListener("message", l), t(!0);
247
375
  return;
248
376
  }
249
- if (m && !c) {
250
- i.remove(), window.removeEventListener("message", d), t(!0);
377
+ if (h && !m) {
378
+ i.remove(), window.removeEventListener("message", l), t(!0);
251
379
  return;
252
380
  }
253
- if (c && p || l.type === "3ds-failed" || p) {
254
- i.remove(), window.removeEventListener("message", d), t(!1);
381
+ if (m && f || d.type === "3ds-failed" || f) {
382
+ i.remove(), window.removeEventListener("message", l), t(!1);
255
383
  return;
256
384
  }
257
385
  };
258
- window.addEventListener("message", d);
386
+ window.addEventListener("message", l);
259
387
  });
260
388
  }
261
389
  /**
@@ -279,7 +407,7 @@ class y {
279
407
  this.close();
280
408
  }
281
409
  }
282
- class w {
410
+ class b {
283
411
  constructor(e, t) {
284
412
  this.mounted = !1;
285
413
  let i;
@@ -288,7 +416,7 @@ class w {
288
416
  throw new Error(`Container not found: ${t.container}`);
289
417
  } else
290
418
  i = t.container;
291
- this.container = i, this.sdk = new y({
419
+ this.container = i, this.sdk = new x({
292
420
  iframeUrl: e.iframeUrl,
293
421
  apiKey: e.apiKey,
294
422
  container: this.container,
@@ -331,7 +459,7 @@ class w {
331
459
  this.mounted && (this.sdk.destroy(), this.mounted = !1);
332
460
  }
333
461
  }
334
- class x {
462
+ class E {
335
463
  /**
336
464
  * Initialize the InflowPay Payment SDK
337
465
  *
@@ -382,7 +510,7 @@ class x {
382
510
  * ```
383
511
  */
384
512
  createCardElement(e) {
385
- return new w(this.config, e);
513
+ return new b(this.config, e);
386
514
  }
387
515
  /**
388
516
  * Get the iframe URL being used
@@ -404,8 +532,8 @@ class x {
404
532
  }
405
533
  }
406
534
  export {
407
- w as C,
408
- x as P,
409
- y as S
535
+ b as C,
536
+ E as P,
537
+ x as S
410
538
  };
411
- //# sourceMappingURL=payment-sdk-CH8ugKck.mjs.map
539
+ //# sourceMappingURL=payment-sdk-DCTbabp6.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payment-sdk-DCTbabp6.mjs","sources":["../src/sdk.ts","../src/card-element.ts","../src/payment-sdk.ts"],"sourcesContent":["/**\n * InflowPay SDK v2 - Iframe-based Payment SDK\n * \n * This SDK creates an iframe and communicates with a React payment application\n * using postMessage API for secure cross-origin communication.\n */\n\nimport type { SDKConfig, IframeMessage } from './types';\n\nexport class SDK {\n private iframe: HTMLIFrameElement | null = null;\n private iframeUrl: string;\n private config: SDKConfig;\n private messageListener: ((event: MessageEvent) => void) | null = null;\n private containerElement: HTMLElement | null = null;\n private usePopup: boolean;\n private environment: 'sandbox' | 'production' | 'development' | 'preprod';\n\n constructor(config: SDKConfig) {\n this.config = config;\n this.iframeUrl = config.iframeUrl || 'http://localhost:3000/iframe/checkout';\n this.environment = this.getEnvironmentFromApiKey(config.apiKey || '');\n\n // Determine if we should use popup or inline\n this.usePopup = !config.container;\n\n // Resolve container if provided\n if (config.container) {\n if (typeof config.container === 'string') {\n this.containerElement = document.querySelector(config.container);\n if (!this.containerElement) {\n throw new Error(`Container not found: ${config.container}`);\n }\n } else {\n this.containerElement = config.container;\n }\n }\n }\n\n /**\n * Initialize and open the payment iframe\n */\n init(): void {\n if (this.iframe) {\n return;\n }\n\n this.createIframe();\n this.addMessageListener();\n }\n\n /**\n * Create and append the iframe to the document\n */\n private createIframe(): void {\n // Build iframe URL with API key and paymentId as query parameters\n const url = new URL(this.iframeUrl);\n if (this.config.apiKey) {\n url.searchParams.set('apiKey', this.config.apiKey);\n }\n if (this.config.config?.paymentId) {\n url.searchParams.set('paymentId', this.config.config.paymentId);\n }\n const iframeSrc = url.toString();\n\n if (this.usePopup) {\n // Create overlay for popup mode\n const overlay = document.createElement('div');\n overlay.id = 'inflowpay-sdk-overlay';\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 999999;\n `;\n\n // Create iframe container\n const container = document.createElement('div');\n container.style.cssText = `\n position: relative;\n width: 90%;\n max-width: 500px;\n height: 90%;\n max-height: 600px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n `;\n\n // Create close button\n const closeButton = document.createElement('button');\n closeButton.innerHTML = '×';\n closeButton.style.cssText = `\n position: absolute;\n top: 10px;\n right: 10px;\n width: 30px;\n height: 30px;\n border: none;\n background: transparent;\n font-size: 24px;\n cursor: pointer;\n z-index: 1000000;\n color: #333;\n display: flex;\n align-items: center;\n justify-content: center;\n `;\n closeButton.onclick = () => this.close();\n\n // Create iframe\n this.iframe = document.createElement('iframe');\n this.iframe.src = iframeSrc;\n this.iframe.style.cssText = `\n width: 100%;\n height: 100%;\n border: none;\n border-radius: 8px;\n `;\n this.iframe.setAttribute('allow', 'payment');\n\n // Assemble structure\n container.appendChild(closeButton);\n container.appendChild(this.iframe);\n overlay.appendChild(container);\n document.body.appendChild(overlay);\n\n // Show loader\n this.showLoader(container);\n\n // Close on overlay click (but not on container click)\n overlay.addEventListener('click', (e) => {\n if (e.target === overlay) {\n this.close();\n }\n });\n } else {\n // Inline mode - mount directly in container\n if (!this.containerElement) {\n throw new Error('Container element is required for inline mode');\n }\n\n // Clear container\n this.containerElement.innerHTML = '';\n\n // Set container styles for seamless integration\n if (this.containerElement instanceof HTMLElement) {\n const currentStyle = this.containerElement.getAttribute('style') || '';\n if (!currentStyle.includes('min-height')) {\n this.containerElement.style.minHeight = '196px';\n }\n if (!currentStyle.includes('position')) {\n this.containerElement.style.position = 'relative';\n }\n if (!currentStyle.includes('overflow')) {\n this.containerElement.style.overflow = 'hidden';\n }\n }\n\n // Create iframe\n this.iframe = document.createElement('iframe');\n this.iframe.src = iframeSrc;\n\n const iframeWidth = this.config.config?.style?.fillParent ? '100%' : '344px';\n const iframeMaxWidth = this.config.config?.style?.fillParent ? 'none' : '100%';\n\n this.iframe.style.cssText = `\n width: ${iframeWidth};\n max-width: ${iframeMaxWidth};\n height: 100%;\n min-height: 196px;\n border: none;\n display: block;\n `;\n\n this.iframe.setAttribute('allow', 'payment');\n\n // Append to container\n this.containerElement.appendChild(this.iframe);\n\n // Show loader\n this.showLoader(this.containerElement);\n }\n }\n\n /**\n * Add message listener for communication with iframe\n */\n private addMessageListener(): void {\n this.messageListener = (event: MessageEvent) => {\n const allowedOrigin = new URL(this.iframeUrl).origin;\n const isExactMatch = event.origin === allowedOrigin;\n\n let isAllowedOrigin = isExactMatch;\n\n if (!isAllowedOrigin) {\n if (this.environment === 'sandbox' || this.environment === 'development') {\n const isLocalhostDev =\n (event.origin.includes('localhost') || event.origin.includes('127.0.0.1')) &&\n (allowedOrigin.includes('localhost') || allowedOrigin.includes('127.0.0.1'));\n isAllowedOrigin = isLocalhostDev;\n }\n\n if (!isAllowedOrigin) {\n const isAllowedApiOrigin =\n event.origin === 'https://dev.api.inflowpay.com' ||\n event.origin === 'https://pre-prod.api.inflowpay.xyz' ||\n event.origin === 'https://api.inflowpay.xyz';\n isAllowedOrigin = isAllowedApiOrigin;\n }\n }\n\n if (!isAllowedOrigin) {\n if (this.config.debug) {\n console.warn('[SDK] Rejected message from unauthorized origin:', event.origin);\n }\n return;\n }\n\n const data = event.data as IframeMessage;\n\n if (!data || !data.type) {\n return;\n }\n\n switch (data.type) {\n case 'iframe-ready':\n // Wait for iframe's javascript to be ready before sending config\n this.hideLoader();\n this.sendConfigToIframe();\n break;\n\n case 'close':\n this.close();\n break;\n\n case 'success':\n if (this.config.onSuccess) {\n this.config.onSuccess(data.data);\n }\n break;\n\n case 'error':\n if (this.config.onError) {\n this.config.onError(data.data);\n }\n break;\n\n case '3ds-required':\n // Iframe requests SDK to open 3DS popup\n if (this.config.debug) {\n console.log('[SDK] Received 3DS request:', data.threeDsSessionUrl);\n }\n if (data.threeDsSessionUrl) {\n if (this.config.debug) {\n console.log('[SDK] Opening 3DS modal...');\n }\n this.open3DSModal(data.threeDsSessionUrl).then((success) => {\n if (this.config.debug) {\n console.log('[SDK] 3DS modal closed, result:', success);\n }\n if (this.iframe && this.iframe.contentWindow) {\n const targetOrigin = this.getTargetOrigin();\n this.iframe.contentWindow.postMessage({\n type: '3ds-result',\n success: success,\n paymentId: data.paymentId || this.config.config?.paymentId,\n }, targetOrigin);\n }\n });\n } else {\n if (this.config.debug) {\n console.error('[SDK] 3DS required but no threeDsSessionUrl provided');\n }\n }\n break;\n\n default:\n if (this.config.debug) {\n console.log('SDK: Received message:', data);\n }\n }\n };\n\n window.addEventListener('message', this.messageListener);\n }\n\n /**\n * Send configuration to the iframe\n */\n private sendConfigToIframe(): void {\n if (!this.iframe || !this.iframe.contentWindow) {\n // Wait for iframe to load\n if (this.iframe) {\n this.iframe.onload = () => {\n this.sendConfigToIframe();\n };\n }\n return;\n }\n\n const message: IframeMessage = {\n type: 'sdkData',\n config: {\n ...(this.config.config || {}),\n paymentId: this.config.config?.paymentId\n },\n data: {\n apiKey: this.config.apiKey,\n },\n };\n\n const targetOrigin = this.getTargetOrigin();\n this.iframe.contentWindow.postMessage(message, targetOrigin);\n }\n\n /**\n * Show skeleton loader while iframe is connecting\n */\n private showLoader(container: HTMLElement): void {\n // Hide iframe while loader is showing\n if (this.iframe) {\n this.iframe.style.display = 'none';\n }\n \n // Detect dark mode\n const isDarkMode = window.matchMedia && window.matchMedia('(prefers-color-scheme: dark)').matches;\n \n // Color scheme based on dark mode\n const inputBgColor = isDarkMode ? '#2d2d2d' : '#F5F5F5';\n const shimmerBase = isDarkMode ? '#3d3d3d' : '#E5E5E5';\n const shimmerLight = isDarkMode ? '#4d4d4d' : '#F0F0F0';\n const shimmerGradient = `linear-gradient(90deg, ${shimmerBase} 25%, ${shimmerLight} 50%, ${shimmerBase} 75%)`;\n \n const loader = document.createElement('div');\n loader.id = 'inflowpay-loader';\n \n // Get container width to match SDK structure\n const containerWidth = this.config.config?.style?.fillParent ? '100%' : '344px';\n \n loader.style.cssText = `\n position: absolute;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n z-index: 1000;\n padding: 20px;\n box-sizing: border-box;\n display: flex;\n flex-direction: column;\n align-items: center;\n font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n `;\n\n // Skeleton card element container (matching .inflowpay-card-element)\n const skeletonCard = document.createElement('div');\n skeletonCard.style.cssText = `\n width: ${containerWidth};\n max-width: 100%;\n margin: 0 auto;\n font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;\n `;\n\n // Input container skeleton (matching .inflowpay-card-inp-wrap)\n const inputWrap = document.createElement('div');\n inputWrap.style.cssText = `\n display: flex;\n align-items: center;\n justify-content: center;\n gap: 6px;\n background-color: ${inputBgColor};\n padding: 8px;\n border-radius: 8px;\n margin-bottom: 20px;\n `;\n\n // Card number skeleton (flex: 1)\n const cardNumberSkeleton = document.createElement('div');\n cardNumberSkeleton.className = 'inflowpay-skeleton';\n cardNumberSkeleton.style.cssText = `\n flex: 1;\n min-width: 0;\n height: 32px;\n border-radius: 6px;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n `;\n\n // Expiry skeleton (21.5% width)\n const expirySkeleton = document.createElement('div');\n expirySkeleton.className = 'inflowpay-skeleton';\n expirySkeleton.style.cssText = `\n width: 21.5%;\n flex-shrink: 0;\n height: 32px;\n border-radius: 6px;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n `;\n\n // CVC skeleton (17.5% width)\n const cvcSkeleton = document.createElement('div');\n cvcSkeleton.className = 'inflowpay-skeleton';\n cvcSkeleton.style.cssText = `\n width: 17.5%;\n flex-shrink: 0;\n height: 32px;\n border-radius: 6px;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n `;\n\n inputWrap.appendChild(cardNumberSkeleton);\n inputWrap.appendChild(expirySkeleton);\n inputWrap.appendChild(cvcSkeleton);\n\n // Button skeleton (matching .inflowpay-button)\n const buttonSkeleton = document.createElement('div');\n buttonSkeleton.className = 'inflowpay-skeleton';\n buttonSkeleton.style.cssText = `\n width: 100%;\n height: 42px;\n border-radius: 8px;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n margin-bottom: 16px;\n `;\n\n // Disclaimer skeleton (matching .inflowpay-disclaimer)\n const disclaimerSkeleton = document.createElement('div');\n disclaimerSkeleton.style.cssText = `\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 4px;\n width: 100%;\n margin-top: 16px;\n `;\n\n const disclaimerIconSkeleton = document.createElement('div');\n disclaimerIconSkeleton.className = 'inflowpay-skeleton';\n disclaimerIconSkeleton.style.cssText = `\n width: 10px;\n height: 10px;\n border-radius: 50%;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n `;\n\n const disclaimerTextSkeleton = document.createElement('div');\n disclaimerTextSkeleton.className = 'inflowpay-skeleton';\n disclaimerTextSkeleton.style.cssText = `\n width: 80%;\n height: 16px;\n border-radius: 4px;\n background: ${shimmerGradient};\n background-size: 200% 100%;\n animation: inflowpay-shimmer 1.5s infinite;\n `;\n\n disclaimerSkeleton.appendChild(disclaimerIconSkeleton);\n disclaimerSkeleton.appendChild(disclaimerTextSkeleton);\n\n skeletonCard.appendChild(inputWrap);\n skeletonCard.appendChild(buttonSkeleton);\n skeletonCard.appendChild(disclaimerSkeleton);\n loader.appendChild(skeletonCard);\n\n // Add shimmer animation keyframes\n if (!document.getElementById('inflowpay-loader-styles')) {\n const style = document.createElement('style');\n style.id = 'inflowpay-loader-styles';\n style.textContent = `\n @keyframes inflowpay-shimmer {\n 0% {\n background-position: -200% 0;\n }\n 100% {\n background-position: 200% 0;\n }\n }\n `;\n document.head.appendChild(style);\n }\n\n container.appendChild(loader);\n }\n\n /**\n * Hide loader\n */\n private hideLoader(): void {\n const loader = document.getElementById('inflowpay-loader');\n if (loader) {\n loader.remove();\n }\n \n // Show iframe again when loader is hidden\n if (this.iframe) {\n this.iframe.style.display = '';\n }\n }\n\n /**\n * Close the iframe and cleanup\n */\n private close(): void {\n if (this.config.onClose) {\n this.config.onClose();\n }\n\n // Hide loader\n this.hideLoader();\n\n // Remove message listener\n if (this.messageListener) {\n window.removeEventListener('message', this.messageListener);\n this.messageListener = null;\n }\n\n if (this.usePopup) {\n // Remove overlay\n const overlay = document.getElementById('inflowpay-sdk-overlay');\n if (overlay) {\n overlay.remove();\n }\n } else {\n // Clear container\n if (this.containerElement) {\n this.containerElement.innerHTML = '';\n }\n }\n\n this.iframe = null;\n }\n\n /**\n * Open 3DS authentication modal\n * Called when iframe requests 3DS authentication\n */\n private open3DSModal(challengeUrl: string): Promise<boolean> {\n if (this.config.debug) {\n console.log('[SDK] open3DSModal called with URL:', challengeUrl);\n }\n return new Promise((resolve) => {\n // Create overlay\n const overlay = document.createElement('div');\n overlay.id = 'inflowpay-3ds-overlay';\n overlay.style.cssText = `\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background-color: rgba(0, 0, 0, 0.7);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: 999999;\n `;\n\n // Create modal\n const modal = document.createElement('div');\n modal.style.cssText = `\n position: relative;\n width: 90%;\n max-width: 500px;\n height: 90%;\n max-height: 600px;\n background: white;\n border-radius: 8px;\n box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);\n display: flex;\n flex-direction: column;\n `;\n\n // Create header\n const header = document.createElement('div');\n header.style.cssText = `\n display: flex;\n align-items: center;\n justify-content: space-between;\n padding: 15px 20px;\n border-bottom: 1px solid #e5e5e5;\n `;\n header.innerHTML = `\n <h3 style=\"margin: 0; font-size: 18px; font-weight: 600;\">Secure Payment Authentication</h3>\n <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>\n `;\n\n // Create content with iframe\n const content = document.createElement('div');\n content.style.cssText = `\n flex: 1;\n position: relative;\n overflow: hidden;\n `;\n const iframe = document.createElement('iframe');\n iframe.src = challengeUrl;\n iframe.style.cssText = `\n width: 100%;\n height: 100%;\n border: none;\n `;\n iframe.setAttribute('allow', 'payment');\n iframe.setAttribute('sandbox', 'allow-forms allow-scripts allow-same-origin allow-popups');\n content.appendChild(iframe);\n\n modal.appendChild(header);\n modal.appendChild(content);\n overlay.appendChild(modal);\n document.body.appendChild(overlay);\n\n // Close button handler\n const closeBtn = overlay.querySelector('#inflowpay-3ds-close');\n const closeHandler = () => {\n overlay.remove();\n window.removeEventListener('message', messageHandler);\n resolve(false);\n };\n closeBtn?.addEventListener('click', closeHandler);\n\n const messageHandler = (event: MessageEvent) => {\n if (!event.data) return;\n\n const allowed3DSOrigins = [\n 'https://dev.api.inflowpay.com',\n 'https://pre-prod.api.inflowpay.xyz',\n 'https://api.inflowpay.xyz',\n ];\n\n if (this.environment === 'sandbox' || this.environment === 'development') {\n if (event.origin.includes('localhost') || event.origin.includes('127.0.0.1')) {\n // Allow localhost in dev/sandbox\n } else if (!allowed3DSOrigins.includes(event.origin)) {\n if (this.config.debug) {\n console.warn('[SDK] Rejected 3DS message from unauthorized origin:', event.origin);\n }\n return;\n }\n } else {\n if (!allowed3DSOrigins.includes(event.origin)) {\n if (this.config.debug) {\n console.warn('[SDK] Rejected 3DS message from unauthorized origin:', event.origin);\n }\n return;\n }\n }\n\n const data = event.data;\n const is3DSComplete = data.type === 'THREE_DS_COMPLETE' || data.type === '3ds-complete';\n const isSuccess = data.status === 'success';\n const isFailure = data.status === 'failed' || data.status === 'failure';\n\n // Success case\n if (is3DSComplete && isSuccess) {\n overlay.remove();\n window.removeEventListener('message', messageHandler);\n resolve(true);\n return;\n }\n\n // Also handle legacy format\n if (isSuccess && !is3DSComplete) {\n overlay.remove();\n window.removeEventListener('message', messageHandler);\n resolve(true);\n return;\n }\n\n // Failure case\n if ((is3DSComplete && isFailure) || data.type === '3ds-failed' || isFailure) {\n overlay.remove();\n window.removeEventListener('message', messageHandler);\n resolve(false);\n return;\n }\n };\n\n window.addEventListener('message', messageHandler);\n });\n }\n\n /**\n * Get target origin for postMessage based on environment\n * In production/pre-prod: use exact origin for security\n * In dev/sandbox: use wildcard for development flexibility\n */\n private getTargetOrigin(): string {\n if (this.environment === 'production' || this.environment === 'preprod') {\n return new URL(this.iframeUrl).origin;\n }\n return '*';\n }\n\n /**\n * Detect environment from API key\n */\n private getEnvironmentFromApiKey(apiKey: string): 'sandbox' | 'production' | 'development' | 'preprod' {\n if (!apiKey) return 'sandbox';\n if (apiKey.includes('_local_') || apiKey.startsWith('inflow_local_')) {\n return 'sandbox';\n } else if (apiKey.includes('_prod_') && !apiKey.includes('_preprod_')) {\n return 'production';\n } else if (apiKey.includes('_preprod_') || apiKey.startsWith('inflow_preprod_')) {\n return 'preprod';\n } else if (apiKey.includes('_dev_')) {\n return 'development';\n }\n return 'sandbox';\n }\n\n /**\n * Public method to close the iframe\n */\n public destroy(): void {\n this.close();\n }\n}\n\n","/**\n * CardElement - Iframe-based payment element\n * \n * Mounts an iframe with the payment checkout form\n */\n\nimport { SDK } from './sdk';\n\nimport type { CSSProperties } from './types';\n\nexport interface CardElementOptions {\n /** Container element or CSS selector where the iframe will be mounted */\n container: string | HTMLElement;\n /** Payment ID for this transaction */\n paymentId: string;\n /** Callback when payment completes */\n onComplete?: (result: { status: string; data?: any; error?: any }) => void;\n /** Callback when payment fails */\n onError?: (error: any) => void;\n /** Callback when user closes the payment */\n onClose?: () => void;\n /** Custom styling for the card element */\n style?: CSSProperties;\n /** Custom button text (default: \"Complete Payment\") */\n buttonText?: string;\n /** Custom placeholder text for inputs */\n placeholders?: {\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n };\n}\n\ninterface InternalSDKConfig {\n apiKey: string;\n iframeUrl: string;\n timeout: number;\n debug: boolean;\n}\n\nexport class CardElement {\n private sdk: SDK;\n private container: HTMLElement;\n private mounted: boolean = false;\n\n constructor(\n config: InternalSDKConfig,\n options: CardElementOptions\n ) {\n let containerElement: HTMLElement | null;\n if (typeof options.container === 'string') {\n containerElement = document.querySelector(options.container);\n if (!containerElement) {\n throw new Error(`Container not found: ${options.container}`);\n }\n } else {\n containerElement = options.container;\n }\n this.container = containerElement;\n\n this.sdk = new SDK({\n iframeUrl: config.iframeUrl,\n apiKey: config.apiKey,\n container: this.container,\n config: {\n paymentId: options.paymentId,\n ...(options.style && { style: options.style }),\n ...(options.buttonText && { buttonText: options.buttonText }),\n ...(options.placeholders && { placeholders: options.placeholders }),\n },\n onSuccess: (data) => {\n if (options.onComplete) {\n options.onComplete({\n status: data?.data?.transaction?.status || 'CHECKOUT_SUCCESS',\n data: data,\n });\n }\n },\n onError: (error) => {\n if (options.onError) {\n options.onError(error);\n } else if (options.onComplete) {\n options.onComplete({\n status: 'PAYMENT_FAILED',\n error: error,\n });\n }\n },\n onClose: () => {\n if (options.onClose) {\n options.onClose();\n }\n },\n });\n }\n\n /**\n * Mount the CardElement to the DOM\n * This will create and display the iframe\n */\n mount(): void {\n if (this.mounted) {\n throw new Error('CardElement is already mounted');\n }\n\n this.sdk.init();\n this.mounted = true;\n }\n\n /**\n * Destroy the CardElement and cleanup\n */\n destroy(): void {\n if (this.mounted) {\n this.sdk.destroy();\n this.mounted = false;\n }\n }\n}\n","/**\n * InflowPay Payment SDK v2\n * \n * Provider class that manages global SDK configuration\n * Similar to the original SDK but uses iframe-based payment flow\n */\n\nimport type { SDKConfig, PaymentConfig, CSSProperties } from './types';\nimport { CardElement } from './card-element';\n\nexport interface PaymentSDKConfig {\n /** Public API key */\n apiKey: string;\n /** Backend API URL (optional, auto-detected from API key) */\n iframeUrl?: string;\n /** Request timeout in milliseconds (default: 30000) */\n timeout?: number;\n /** Enable debug logging (default: false, only allowed in local/dev environments) */\n debug?: boolean;\n}\n\nexport class PaymentSDK {\n private config: PaymentSDKConfig & { iframeUrl: string; timeout: number; debug: boolean };\n\n /**\n * Initialize the InflowPay Payment SDK\n * \n * @param config - SDK configuration\n * \n * @example\n * ```typescript\n * const sdk = new PaymentSDK({\n * apiKey: 'inflow_pub_local_xxx'\n * });\n * ```\n */\n constructor(config: PaymentSDKConfig) {\n // Validate API key\n if (!config.apiKey || typeof config.apiKey !== 'string') {\n throw new Error('API key is required');\n }\n\n // Auto-detect iframe URL from API key if not provided\n let iframeUrl = config.iframeUrl;\n const environment = this.getEnvironmentFromApiKey(config.apiKey);\n \n if (!iframeUrl) {\n if (environment === 'production') {\n iframeUrl = 'https://api.inflowpay.xyz/iframe/checkout';\n } else if (environment === 'preprod') {\n iframeUrl = 'https://pre-prod.api.inflowpay.xyz/iframe/checkout';\n } else if (environment === 'development') {\n iframeUrl = 'https://dev.api.inflowpay.com/iframe/checkout';\n } else {\n // sandbox/local\n iframeUrl = 'http://localhost:3000/iframe/checkout';\n }\n }\n\n // Validate debug mode - only allowed in local/dev environments\n const requestedDebug = config.debug ?? false;\n if (requestedDebug && (environment === 'production' || environment === 'preprod')) {\n console.warn('[InflowPay SDK] Debug mode is not allowed in production/pre-prod environments. Debug mode disabled.');\n }\n const debug = requestedDebug && (environment === 'sandbox' || environment === 'development');\n\n this.config = {\n apiKey: config.apiKey,\n iframeUrl,\n timeout: config.timeout ?? 30000,\n debug,\n };\n }\n\n /**\n * Create a CardElement for iframe-based payment UI\n * \n * @param options - CardElement configuration\n * @returns CardElement instance\n * \n * @example\n * ```typescript\n * const cardElement = sdk.createCardElement({\n * container: '#card-container',\n * paymentId: 'pay_123',\n * onComplete: (result) => {\n * if (result.status === 'CHECKOUT_SUCCESS') {\n * window.location.href = '/success';\n * }\n * }\n * });\n * \n * cardElement.mount();\n * ```\n */\n createCardElement(options: {\n container: string | HTMLElement;\n paymentId: string;\n style?: CSSProperties;\n buttonText?: string;\n placeholders?: {\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n };\n onComplete?: (result: { status: string; data?: any; error?: any }) => void;\n onError?: (error: any) => void;\n onClose?: () => void;\n }): CardElement {\n return new CardElement(this.config, options);\n }\n\n /**\n * Get the iframe URL being used\n */\n getIframeUrl(): string {\n return this.config.iframeUrl;\n }\n\n /**\n * Get the API key\n */\n getApiKey(): string {\n return this.config.apiKey;\n }\n\n /**\n * Auto-detect environment from API key\n */\n private getEnvironmentFromApiKey(apiKey: string): 'sandbox' | 'production' | 'development' | 'preprod' {\n if (apiKey.includes('_local_') || apiKey.startsWith('inflow_local_')) {\n return 'sandbox';\n } else if (apiKey.includes('_prod_') && !apiKey.includes('_preprod_')) {\n return 'production';\n } else if (apiKey.includes('_preprod_') || apiKey.startsWith('inflow_preprod_')) {\n return 'preprod';\n } else if (apiKey.includes('_dev_')) {\n return 'development';\n }\n return 'sandbox';\n }\n}\n\n"],"names":["SDK","config","url","iframeSrc","overlay","container","closeButton","e","currentStyle","iframeWidth","iframeMaxWidth","event","allowedOrigin","isAllowedOrigin","data","success","targetOrigin","message","isDarkMode","inputBgColor","shimmerBase","shimmerGradient","loader","containerWidth","skeletonCard","inputWrap","cardNumberSkeleton","expirySkeleton","cvcSkeleton","buttonSkeleton","disclaimerSkeleton","disclaimerIconSkeleton","disclaimerTextSkeleton","style","challengeUrl","resolve","modal","header","content","iframe","closeBtn","closeHandler","messageHandler","allowed3DSOrigins","is3DSComplete","isSuccess","isFailure","apiKey","CardElement","options","containerElement","error","PaymentSDK","iframeUrl","environment","requestedDebug","debug"],"mappings":"AASO,MAAMA,EAAI;AAAA,EASf,YAAYC,GAAmB;AAS7B,QAjBF,KAAQ,SAAmC,MAG3C,KAAQ,kBAA0D,MAClE,KAAQ,mBAAuC,MAK7C,KAAK,SAASA,GACd,KAAK,YAAYA,EAAO,aAAa,yCACrC,KAAK,cAAc,KAAK,yBAAyBA,EAAO,UAAU,EAAE,GAGpE,KAAK,WAAW,CAACA,EAAO,WAGpBA,EAAO;AACT,UAAI,OAAOA,EAAO,aAAc;AAE9B,YADA,KAAK,mBAAmB,SAAS,cAAcA,EAAO,SAAS,GAC3D,CAAC,KAAK;AACR,gBAAM,IAAI,MAAM,wBAAwBA,EAAO,SAAS,EAAE;AAAA;AAG5D,aAAK,mBAAmBA,EAAO;AAAA,EAGrC;AAAA;AAAA;AAAA;AAAA,E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AAsE;AACrG,WAAIA,EAAO,SAAS,SAAS,KAAKA,EAAO,WAAW,eAAe,IAC1D,YACEA,EAAO,SAAS,QAAQ,KAAK,CAACA,EAAO,SAAS,WAAW,IAC3D,eACEA,EAAO,SAAS,WAAW,KAAKA,EAAO,WAAW,iBAAiB,IACrE,YACEA,EAAO,SAAS,OAAO,IACzB,gBAEF;AAAA,EACT;AACF;"}
@@ -0,0 +1,177 @@
1
+ "use strict";class x{constructor(e){if(this.iframe=null,this.messageListener=null,this.containerElement=null,this.config=e,this.iframeUrl=e.iframeUrl||"http://localhost:3000/iframe/checkout",this.environment=this.getEnvironmentFromApiKey(e.apiKey||""),this.usePopup=!e.container,e.container)if(typeof e.container=="string"){if(this.containerElement=document.querySelector(e.container),!this.containerElement)throw new Error(`Container not found: ${e.container}`)}else this.containerElement=e.container}init(){this.iframe||(this.createIframe(),this.addMessageListener())}createIframe(){const e=new URL(this.iframeUrl);this.config.apiKey&&e.searchParams.set("apiKey",this.config.apiKey),this.config.config?.paymentId&&e.searchParams.set("paymentId",this.config.config.paymentId);const t=e.toString();if(this.usePopup){const i=document.createElement("div");i.id="inflowpay-sdk-overlay",i.style.cssText=`
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ width: 100%;
6
+ height: 100%;
7
+ background-color: rgba(0, 0, 0, 0.5);
8
+ display: flex;
9
+ align-items: center;
10
+ justify-content: center;
11
+ z-index: 999999;
12
+ `;const n=document.createElement("div");n.style.cssText=`
13
+ position: relative;
14
+ width: 90%;
15
+ max-width: 500px;
16
+ height: 90%;
17
+ max-height: 600px;
18
+ background: white;
19
+ border-radius: 8px;
20
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
21
+ `;const s=document.createElement("button");s.innerHTML="×",s.style.cssText=`
22
+ position: absolute;
23
+ top: 10px;
24
+ right: 10px;
25
+ width: 30px;
26
+ height: 30px;
27
+ border: none;
28
+ background: transparent;
29
+ font-size: 24px;
30
+ cursor: pointer;
31
+ z-index: 1000000;
32
+ color: #333;
33
+ display: flex;
34
+ align-items: center;
35
+ justify-content: center;
36
+ `,s.onclick=()=>this.close(),this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.style.cssText=`
37
+ width: 100%;
38
+ height: 100%;
39
+ border: none;
40
+ border-radius: 8px;
41
+ `,this.iframe.setAttribute("allow","payment"),n.appendChild(s),n.appendChild(this.iframe),i.appendChild(n),document.body.appendChild(i),this.showLoader(n),i.addEventListener("click",o=>{o.target===i&&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 s=this.containerElement.getAttribute("style")||"";s.includes("min-height")||(this.containerElement.style.minHeight="196px"),s.includes("position")||(this.containerElement.style.position="relative"),s.includes("overflow")||(this.containerElement.style.overflow="hidden")}this.iframe=document.createElement("iframe"),this.iframe.src=t;const i=this.config.config?.style?.fillParent?"100%":"344px",n=this.config.config?.style?.fillParent?"none":"100%";this.iframe.style.cssText=`
42
+ width: ${i};
43
+ max-width: ${n};
44
+ height: 100%;
45
+ min-height: 196px;
46
+ border: none;
47
+ display: block;
48
+ `,this.iframe.setAttribute("allow","payment"),this.containerElement.appendChild(this.iframe),this.showLoader(this.containerElement)}}addMessageListener(){this.messageListener=e=>{const t=new URL(this.iframeUrl).origin;let n=e.origin===t;if(n||((this.environment==="sandbox"||this.environment==="development")&&(n=(e.origin.includes("localhost")||e.origin.includes("127.0.0.1"))&&(t.includes("localhost")||t.includes("127.0.0.1"))),n||(n=e.origin==="https://dev.api.inflowpay.com"||e.origin==="https://pre-prod.api.inflowpay.xyz"||e.origin==="https://api.inflowpay.xyz")),!n){this.config.debug&&console.warn("[SDK] Rejected message from unauthorized origin:",e.origin);return}const s=e.data;if(!(!s||!s.type))switch(s.type){case"iframe-ready":this.hideLoader(),this.sendConfigToIframe();break;case"close":this.close();break;case"success":this.config.onSuccess&&this.config.onSuccess(s.data);break;case"error":this.config.onError&&this.config.onError(s.data);break;case"3ds-required":this.config.debug&&console.log("[SDK] Received 3DS request:",s.threeDsSessionUrl),s.threeDsSessionUrl?(this.config.debug&&console.log("[SDK] Opening 3DS modal..."),this.open3DSModal(s.threeDsSessionUrl).then(o=>{if(this.config.debug&&console.log("[SDK] 3DS modal closed, result:",o),this.iframe&&this.iframe.contentWindow){const r=this.getTargetOrigin();this.iframe.contentWindow.postMessage({type:"3ds-result",success:o,paymentId:s.paymentId||this.config.config?.paymentId},r)}})):this.config.debug&&console.error("[SDK] 3DS required but no threeDsSessionUrl provided");break;default:this.config.debug&&console.log("SDK: Received message:",s)}},window.addEventListener("message",this.messageListener)}sendConfigToIframe(){if(!this.iframe||!this.iframe.contentWindow){this.iframe&&(this.iframe.onload=()=>{this.sendConfigToIframe()});return}const e={type:"sdkData",config:{...this.config.config||{},paymentId:this.config.config?.paymentId},data:{apiKey:this.config.apiKey}},t=this.getTargetOrigin();this.iframe.contentWindow.postMessage(e,t)}showLoader(e){this.iframe&&(this.iframe.style.display="none");const t=window.matchMedia&&window.matchMedia("(prefers-color-scheme: dark)").matches,i=t?"#2d2d2d":"#F5F5F5",n=t?"#3d3d3d":"#E5E5E5",o=`linear-gradient(90deg, ${n} 25%, ${t?"#4d4d4d":"#F0F0F0"} 50%, ${n} 75%)`,r=document.createElement("div");r.id="inflowpay-loader";const u=this.config.config?.style?.fillParent?"100%":"344px";r.style.cssText=`
49
+ position: absolute;
50
+ top: 0;
51
+ left: 0;
52
+ width: 100%;
53
+ height: 100%;
54
+ z-index: 1000;
55
+ padding: 20px;
56
+ box-sizing: border-box;
57
+ display: flex;
58
+ flex-direction: column;
59
+ align-items: center;
60
+ font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
61
+ `;const c=document.createElement("div");c.style.cssText=`
62
+ width: ${u};
63
+ max-width: 100%;
64
+ margin: 0 auto;
65
+ font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
66
+ `;const l=document.createElement("div");l.style.cssText=`
67
+ display: flex;
68
+ align-items: center;
69
+ justify-content: center;
70
+ gap: 6px;
71
+ background-color: ${i};
72
+ padding: 8px;
73
+ border-radius: 8px;
74
+ margin-bottom: 20px;
75
+ `;const a=document.createElement("div");a.className="inflowpay-skeleton",a.style.cssText=`
76
+ flex: 1;
77
+ min-width: 0;
78
+ height: 32px;
79
+ border-radius: 6px;
80
+ background: ${o};
81
+ background-size: 200% 100%;
82
+ animation: inflowpay-shimmer 1.5s infinite;
83
+ `;const p=document.createElement("div");p.className="inflowpay-skeleton",p.style.cssText=`
84
+ width: 21.5%;
85
+ flex-shrink: 0;
86
+ height: 32px;
87
+ border-radius: 6px;
88
+ background: ${o};
89
+ background-size: 200% 100%;
90
+ animation: inflowpay-shimmer 1.5s infinite;
91
+ `;const d=document.createElement("div");d.className="inflowpay-skeleton",d.style.cssText=`
92
+ width: 17.5%;
93
+ flex-shrink: 0;
94
+ height: 32px;
95
+ border-radius: 6px;
96
+ background: ${o};
97
+ background-size: 200% 100%;
98
+ animation: inflowpay-shimmer 1.5s infinite;
99
+ `,l.appendChild(a),l.appendChild(p),l.appendChild(d);const m=document.createElement("div");m.className="inflowpay-skeleton",m.style.cssText=`
100
+ width: 100%;
101
+ height: 42px;
102
+ border-radius: 8px;
103
+ background: ${o};
104
+ background-size: 200% 100%;
105
+ animation: inflowpay-shimmer 1.5s infinite;
106
+ margin-bottom: 16px;
107
+ `;const h=document.createElement("div");h.style.cssText=`
108
+ display: flex;
109
+ flex-direction: column;
110
+ align-items: center;
111
+ gap: 4px;
112
+ width: 100%;
113
+ margin-top: 16px;
114
+ `;const f=document.createElement("div");f.className="inflowpay-skeleton",f.style.cssText=`
115
+ width: 10px;
116
+ height: 10px;
117
+ border-radius: 50%;
118
+ background: ${o};
119
+ background-size: 200% 100%;
120
+ animation: inflowpay-shimmer 1.5s infinite;
121
+ `;const g=document.createElement("div");if(g.className="inflowpay-skeleton",g.style.cssText=`
122
+ width: 80%;
123
+ height: 16px;
124
+ border-radius: 4px;
125
+ background: ${o};
126
+ background-size: 200% 100%;
127
+ animation: inflowpay-shimmer 1.5s infinite;
128
+ `,h.appendChild(f),h.appendChild(g),c.appendChild(l),c.appendChild(m),c.appendChild(h),r.appendChild(c),!document.getElementById("inflowpay-loader-styles")){const y=document.createElement("style");y.id="inflowpay-loader-styles",y.textContent=`
129
+ @keyframes inflowpay-shimmer {
130
+ 0% {
131
+ background-position: -200% 0;
132
+ }
133
+ 100% {
134
+ background-position: 200% 0;
135
+ }
136
+ }
137
+ `,document.head.appendChild(y)}e.appendChild(r)}hideLoader(){const e=document.getElementById("inflowpay-loader");e&&e.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 e=document.getElementById("inflowpay-sdk-overlay");e&&e.remove()}else this.containerElement&&(this.containerElement.innerHTML="");this.iframe=null}open3DSModal(e){return this.config.debug&&console.log("[SDK] open3DSModal called with URL:",e),new Promise(t=>{const i=document.createElement("div");i.id="inflowpay-3ds-overlay",i.style.cssText=`
138
+ position: fixed;
139
+ top: 0;
140
+ left: 0;
141
+ width: 100%;
142
+ height: 100%;
143
+ background-color: rgba(0, 0, 0, 0.7);
144
+ display: flex;
145
+ align-items: center;
146
+ justify-content: center;
147
+ z-index: 999999;
148
+ `;const n=document.createElement("div");n.style.cssText=`
149
+ position: relative;
150
+ width: 90%;
151
+ max-width: 500px;
152
+ height: 90%;
153
+ max-height: 600px;
154
+ background: white;
155
+ border-radius: 8px;
156
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
157
+ display: flex;
158
+ flex-direction: column;
159
+ `;const s=document.createElement("div");s.style.cssText=`
160
+ display: flex;
161
+ align-items: center;
162
+ justify-content: space-between;
163
+ padding: 15px 20px;
164
+ border-bottom: 1px solid #e5e5e5;
165
+ `,s.innerHTML=`
166
+ <h3 style="margin: 0; font-size: 18px; font-weight: 600;">Secure Payment Authentication</h3>
167
+ <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>
168
+ `;const o=document.createElement("div");o.style.cssText=`
169
+ flex: 1;
170
+ position: relative;
171
+ overflow: hidden;
172
+ `;const r=document.createElement("iframe");r.src=e,r.style.cssText=`
173
+ width: 100%;
174
+ height: 100%;
175
+ border: none;
176
+ `,r.setAttribute("allow","payment"),r.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups"),o.appendChild(r),n.appendChild(s),n.appendChild(o),i.appendChild(n),document.body.appendChild(i);const u=i.querySelector("#inflowpay-3ds-close"),c=()=>{i.remove(),window.removeEventListener("message",l),t(!1)};u?.addEventListener("click",c);const l=a=>{if(!a.data)return;const p=["https://dev.api.inflowpay.com","https://pre-prod.api.inflowpay.xyz","https://api.inflowpay.xyz"];if(this.environment==="sandbox"||this.environment==="development"){if(!(a.origin.includes("localhost")||a.origin.includes("127.0.0.1"))){if(!p.includes(a.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",a.origin);return}}}else if(!p.includes(a.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",a.origin);return}const d=a.data,m=d.type==="THREE_DS_COMPLETE"||d.type==="3ds-complete",h=d.status==="success",f=d.status==="failed"||d.status==="failure";if(m&&h){i.remove(),window.removeEventListener("message",l),t(!0);return}if(h&&!m){i.remove(),window.removeEventListener("message",l),t(!0);return}if(m&&f||d.type==="3ds-failed"||f){i.remove(),window.removeEventListener("message",l),t(!1);return}};window.addEventListener("message",l)})}getTargetOrigin(){return this.environment==="production"||this.environment==="preprod"?new URL(this.iframeUrl).origin:"*"}getEnvironmentFromApiKey(e){return!e||e.includes("_local_")||e.startsWith("inflow_local_")?"sandbox":e.includes("_prod_")&&!e.includes("_preprod_")?"production":e.includes("_preprod_")||e.startsWith("inflow_preprod_")?"preprod":e.includes("_dev_")?"development":"sandbox"}destroy(){this.close()}}class b{constructor(e,t){this.mounted=!1;let i;if(typeof t.container=="string"){if(i=document.querySelector(t.container),!i)throw new Error(`Container not found: ${t.container}`)}else i=t.container;this.container=i,this.sdk=new x({iframeUrl:e.iframeUrl,apiKey:e.apiKey,container:this.container,config:{paymentId:t.paymentId,...t.style&&{style:t.style},...t.buttonText&&{buttonText:t.buttonText},...t.placeholders&&{placeholders:t.placeholders}},onSuccess:n=>{t.onComplete&&t.onComplete({status:n?.data?.transaction?.status||"CHECKOUT_SUCCESS",data:n})},onError:n=>{t.onError?t.onError(n):t.onComplete&&t.onComplete({status:"PAYMENT_FAILED",error:n})},onClose:()=>{t.onClose&&t.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 E{constructor(e){if(!e.apiKey||typeof e.apiKey!="string")throw new Error("API key is required");let t=e.iframeUrl;const i=this.getEnvironmentFromApiKey(e.apiKey);t||(i==="production"?t="https://api.inflowpay.xyz/iframe/checkout":i==="preprod"?t="https://pre-prod.api.inflowpay.xyz/iframe/checkout":i==="development"?t="https://dev.api.inflowpay.com/iframe/checkout":t="http://localhost:3000/iframe/checkout");const n=e.debug??!1;n&&(i==="production"||i==="preprod")&&console.warn("[InflowPay SDK] Debug mode is not allowed in production/pre-prod environments. Debug mode disabled.");const s=n&&(i==="sandbox"||i==="development");this.config={apiKey:e.apiKey,iframeUrl:t,timeout:e.timeout??3e4,debug:s}}createCardElement(e){return new b(this.config,e)}getIframeUrl(){return this.config.iframeUrl}getApiKey(){return this.config.apiKey}getEnvironmentFromApiKey(e){return e.includes("_local_")||e.startsWith("inflow_local_")?"sandbox":e.includes("_prod_")&&!e.includes("_preprod_")?"production":e.includes("_preprod_")||e.startsWith("inflow_preprod_")?"preprod":e.includes("_dev_")?"development":"sandbox"}}exports.CardElement=b;exports.PaymentSDK=E;exports.SDK=x;
177
+ //# sourceMappingURL=payment-sdk-DRIfoXw9.js.map