@inflow_pay/sdk 0.0.1

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.
@@ -0,0 +1,459 @@
1
+ class E {
2
+ constructor(e) {
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
+ if (typeof e.container == "string") {
5
+ if (this.containerElement = document.querySelector(e.container), !this.containerElement)
6
+ throw new Error(`Container not found: ${e.container}`);
7
+ } else
8
+ this.containerElement = e.container;
9
+ }
10
+ /**
11
+ * Initialize and open the payment iframe
12
+ */
13
+ init() {
14
+ this.iframe || (this.createIframe(), this.addMessageListener(), this.sendConfigToIframe());
15
+ }
16
+ /**
17
+ * Create and append the iframe to the document
18
+ */
19
+ createIframe() {
20
+ const e = new URL(this.iframeUrl);
21
+ this.config.apiKey && e.searchParams.set("apiKey", this.config.apiKey), this.config.config?.paymentId && e.searchParams.set("paymentId", this.config.config.paymentId);
22
+ const t = e.toString();
23
+ if (this.usePopup) {
24
+ const i = document.createElement("div");
25
+ i.id = "inflowpay-sdk-overlay", i.style.cssText = `
26
+ position: fixed;
27
+ top: 0;
28
+ left: 0;
29
+ width: 100%;
30
+ height: 100%;
31
+ background-color: rgba(0, 0, 0, 0.5);
32
+ display: flex;
33
+ align-items: center;
34
+ justify-content: center;
35
+ z-index: 999999;
36
+ `;
37
+ const n = document.createElement("div");
38
+ n.style.cssText = `
39
+ position: relative;
40
+ width: 90%;
41
+ max-width: 500px;
42
+ height: 90%;
43
+ max-height: 600px;
44
+ background: white;
45
+ border-radius: 8px;
46
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
47
+ `;
48
+ const o = document.createElement("button");
49
+ o.innerHTML = "×", o.style.cssText = `
50
+ position: absolute;
51
+ top: 10px;
52
+ right: 10px;
53
+ width: 30px;
54
+ height: 30px;
55
+ border: none;
56
+ background: transparent;
57
+ font-size: 24px;
58
+ cursor: pointer;
59
+ z-index: 1000000;
60
+ color: #333;
61
+ display: flex;
62
+ align-items: center;
63
+ justify-content: center;
64
+ `, o.onclick = () => this.close(), this.iframe = document.createElement("iframe"), this.iframe.src = t, this.iframe.style.cssText = `
65
+ width: 100%;
66
+ height: 100%;
67
+ border: none;
68
+ border-radius: 8px;
69
+ `, this.iframe.setAttribute("allow", "payment"), n.appendChild(o), n.appendChild(this.iframe), i.appendChild(n), document.body.appendChild(i), i.addEventListener("click", (s) => {
70
+ s.target === i && this.close();
71
+ });
72
+ } else {
73
+ if (!this.containerElement)
74
+ throw new Error("Container element is required for inline mode");
75
+ if (this.containerElement.innerHTML = "", this.containerElement instanceof HTMLElement) {
76
+ const i = this.containerElement.getAttribute("style") || "";
77
+ i.includes("min-height") || (this.containerElement.style.minHeight = "300px"), i.includes("position") || (this.containerElement.style.position = "relative"), i.includes("overflow") || (this.containerElement.style.overflow = "hidden");
78
+ }
79
+ this.iframe = document.createElement("iframe"), this.iframe.src = t, this.iframe.style.cssText = `
80
+ width: 100%;
81
+ height: 100%;
82
+ min-height: 300px;
83
+ border: none;
84
+ display: block;
85
+ `, this.iframe.setAttribute("allow", "payment"), this.containerElement.appendChild(this.iframe);
86
+ }
87
+ }
88
+ /**
89
+ * Add message listener for communication with iframe
90
+ */
91
+ addMessageListener() {
92
+ this.messageListener = (e) => {
93
+ const t = new URL(this.iframeUrl).origin;
94
+ let n = e.origin === t;
95
+ 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) {
96
+ this.config.debug && console.warn("[SDK] Rejected message from unauthorized origin:", e.origin);
97
+ return;
98
+ }
99
+ const o = e.data;
100
+ if (!(!o || !o.type))
101
+ switch (o.type) {
102
+ case "close":
103
+ this.close();
104
+ break;
105
+ case "success":
106
+ this.config.onSuccess && this.config.onSuccess(o.data);
107
+ break;
108
+ case "error":
109
+ this.config.onError && this.config.onError(o.data);
110
+ break;
111
+ case "3ds-required":
112
+ 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((s) => {
113
+ if (this.config.debug && console.log("[SDK] 3DS modal closed, result:", s), this.iframe && this.iframe.contentWindow) {
114
+ const l = this.getTargetOrigin();
115
+ this.iframe.contentWindow.postMessage({
116
+ type: "3ds-result",
117
+ success: s,
118
+ paymentId: o.paymentId || this.config.config?.paymentId
119
+ }, l);
120
+ }
121
+ })) : this.config.debug && console.error("[SDK] 3DS required but no threeDsSessionUrl provided");
122
+ break;
123
+ default:
124
+ this.config.debug && console.log("SDK: Received message:", o);
125
+ }
126
+ }, window.addEventListener("message", this.messageListener);
127
+ }
128
+ /**
129
+ * Send configuration to the iframe
130
+ */
131
+ sendConfigToIframe() {
132
+ if (!this.iframe || !this.iframe.contentWindow) {
133
+ this.iframe && (this.iframe.onload = () => {
134
+ this.sendConfigToIframe();
135
+ });
136
+ return;
137
+ }
138
+ const e = {
139
+ type: "sdkData",
140
+ config: {
141
+ ...this.config.config || {},
142
+ paymentId: this.config.config?.paymentId
143
+ },
144
+ data: {
145
+ apiKey: this.config.apiKey
146
+ }
147
+ }, t = this.getTargetOrigin();
148
+ this.iframe.contentWindow.postMessage(e, t);
149
+ }
150
+ /**
151
+ * Close the iframe and cleanup
152
+ */
153
+ close() {
154
+ if (this.config.onClose && this.config.onClose(), this.messageListener && (window.removeEventListener("message", this.messageListener), this.messageListener = null), this.usePopup) {
155
+ const e = document.getElementById("inflowpay-sdk-overlay");
156
+ e && e.remove();
157
+ } else
158
+ this.containerElement && this.iframe && this.containerElement.removeChild(this.iframe);
159
+ this.iframe = null;
160
+ }
161
+ /**
162
+ * Open 3DS authentication modal
163
+ * Called when iframe requests 3DS authentication
164
+ */
165
+ open3DSModal(e) {
166
+ return this.config.debug && console.log("[SDK] open3DSModal called with URL:", e), new Promise((t) => {
167
+ const i = document.createElement("div");
168
+ i.id = "inflowpay-3ds-overlay", i.style.cssText = `
169
+ position: fixed;
170
+ top: 0;
171
+ left: 0;
172
+ width: 100%;
173
+ height: 100%;
174
+ background-color: rgba(0, 0, 0, 0.7);
175
+ display: flex;
176
+ align-items: center;
177
+ justify-content: center;
178
+ z-index: 999999;
179
+ `;
180
+ const n = document.createElement("div");
181
+ n.style.cssText = `
182
+ position: relative;
183
+ width: 90%;
184
+ max-width: 500px;
185
+ height: 90%;
186
+ max-height: 600px;
187
+ background: white;
188
+ border-radius: 8px;
189
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
190
+ display: flex;
191
+ flex-direction: column;
192
+ `;
193
+ const o = document.createElement("div");
194
+ o.style.cssText = `
195
+ display: flex;
196
+ align-items: center;
197
+ justify-content: space-between;
198
+ padding: 15px 20px;
199
+ border-bottom: 1px solid #e5e5e5;
200
+ `, o.innerHTML = `
201
+ <h3 style="margin: 0; font-size: 18px; font-weight: 600;">Secure Payment Authentication</h3>
202
+ <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>
203
+ `;
204
+ const s = document.createElement("div");
205
+ s.style.cssText = `
206
+ flex: 1;
207
+ position: relative;
208
+ overflow: hidden;
209
+ `;
210
+ const l = document.createElement("iframe");
211
+ l.src = e, l.style.cssText = `
212
+ width: 100%;
213
+ height: 100%;
214
+ border: none;
215
+ `, l.setAttribute("allow", "payment"), l.setAttribute("sandbox", "allow-forms allow-scripts allow-same-origin allow-popups"), s.appendChild(l), n.appendChild(o), n.appendChild(s), i.appendChild(n), document.body.appendChild(i);
216
+ const p = i.querySelector("#inflowpay-3ds-close"), g = () => {
217
+ i.remove(), window.removeEventListener("message", c), t(!1);
218
+ };
219
+ p?.addEventListener("click", g);
220
+ const c = (a) => {
221
+ if (!a.data) return;
222
+ const f = [
223
+ "https://dev.api.inflowpay.com",
224
+ "https://pre-prod.api.inflowpay.xyz",
225
+ "https://api.inflowpay.xyz"
226
+ ];
227
+ if (this.environment === "sandbox" || this.environment === "development") {
228
+ if (!(a.origin.includes("localhost") || a.origin.includes("127.0.0.1"))) {
229
+ if (!f.includes(a.origin)) {
230
+ this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", a.origin);
231
+ return;
232
+ }
233
+ }
234
+ } else if (!f.includes(a.origin)) {
235
+ this.config.debug && console.warn("[SDK] Rejected 3DS message from unauthorized origin:", a.origin);
236
+ return;
237
+ }
238
+ const d = a.data, m = d.type === "THREE_DS_COMPLETE" || d.type === "3ds-complete", h = d.status === "success", u = d.status === "failed" || d.status === "failure";
239
+ if (m && h) {
240
+ i.remove(), window.removeEventListener("message", c), t(!0);
241
+ return;
242
+ }
243
+ if (h && !m) {
244
+ i.remove(), window.removeEventListener("message", c), t(!0);
245
+ return;
246
+ }
247
+ if (m && u || d.type === "3ds-failed" || u) {
248
+ i.remove(), window.removeEventListener("message", c), t(!1);
249
+ return;
250
+ }
251
+ };
252
+ window.addEventListener("message", c);
253
+ });
254
+ }
255
+ /**
256
+ * Get target origin for postMessage based on environment
257
+ * In production/pre-prod: use exact origin for security
258
+ * In dev/sandbox: use wildcard for development flexibility
259
+ */
260
+ getTargetOrigin() {
261
+ return this.environment === "production" || this.environment === "preprod" ? new URL(this.iframeUrl).origin : "*";
262
+ }
263
+ /**
264
+ * Detect environment from API key
265
+ */
266
+ getEnvironmentFromApiKey(e) {
267
+ 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";
268
+ }
269
+ /**
270
+ * Public method to close the iframe
271
+ */
272
+ destroy() {
273
+ this.close();
274
+ }
275
+ }
276
+ class y {
277
+ constructor(e, t) {
278
+ this.mounted = !1;
279
+ let i;
280
+ if (typeof t.container == "string") {
281
+ if (i = document.querySelector(t.container), !i)
282
+ throw new Error(`Container not found: ${t.container}`);
283
+ } else
284
+ i = t.container;
285
+ this.container = i, this.sdk = new E({
286
+ iframeUrl: e.iframeUrl,
287
+ apiKey: e.apiKey,
288
+ container: this.container,
289
+ config: {
290
+ paymentId: t.paymentId
291
+ },
292
+ onSuccess: (n) => {
293
+ t.onComplete && t.onComplete({
294
+ status: n?.data?.transaction?.status || "CHECKOUT_SUCCESS",
295
+ data: n
296
+ });
297
+ },
298
+ onError: (n) => {
299
+ t.onError ? t.onError(n) : t.onComplete && t.onComplete({
300
+ status: "PAYMENT_FAILED",
301
+ error: n
302
+ });
303
+ },
304
+ onClose: () => {
305
+ t.onClose && t.onClose();
306
+ }
307
+ });
308
+ }
309
+ /**
310
+ * Mount the CardElement to the DOM
311
+ * This will create and display the iframe
312
+ */
313
+ mount() {
314
+ if (this.mounted)
315
+ throw new Error("CardElement is already mounted");
316
+ this.sdk.init(), this.mounted = !0;
317
+ }
318
+ /**
319
+ * Destroy the CardElement and cleanup
320
+ */
321
+ destroy() {
322
+ this.mounted && (this.sdk.destroy(), this.mounted = !1);
323
+ }
324
+ }
325
+ class w {
326
+ /**
327
+ * Initialize the InflowPay Payment SDK
328
+ *
329
+ * @param config - SDK configuration
330
+ *
331
+ * @example
332
+ * ```typescript
333
+ * const sdk = new PaymentSDK({
334
+ * apiKey: 'inflow_pub_local_xxx'
335
+ * });
336
+ * ```
337
+ */
338
+ constructor(e) {
339
+ if (!e.apiKey || typeof e.apiKey != "string")
340
+ throw new Error("API key is required");
341
+ let t = e.iframeUrl;
342
+ const i = this.getEnvironmentFromApiKey(e.apiKey);
343
+ 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");
344
+ const n = e.debug ?? !1;
345
+ n && (i === "production" || i === "preprod") && console.warn("[InflowPay SDK] Debug mode is not allowed in production/pre-prod environments. Debug mode disabled.");
346
+ const o = n && (i === "sandbox" || i === "development");
347
+ this.config = {
348
+ apiKey: e.apiKey,
349
+ iframeUrl: t,
350
+ timeout: e.timeout ?? 3e4,
351
+ debug: o
352
+ };
353
+ }
354
+ /**
355
+ * Create a CardElement for iframe-based payment UI
356
+ *
357
+ * @param options - CardElement configuration
358
+ * @returns CardElement instance
359
+ *
360
+ * @example
361
+ * ```typescript
362
+ * const cardElement = sdk.createCardElement({
363
+ * container: '#card-container',
364
+ * paymentId: 'pay_123',
365
+ * onComplete: (result) => {
366
+ * if (result.status === 'CHECKOUT_SUCCESS') {
367
+ * window.location.href = '/success';
368
+ * }
369
+ * }
370
+ * });
371
+ *
372
+ * cardElement.mount();
373
+ * ```
374
+ */
375
+ createCardElement(e) {
376
+ return new y(this.config, e);
377
+ }
378
+ /**
379
+ * Get the iframe URL being used
380
+ */
381
+ getIframeUrl() {
382
+ return this.config.iframeUrl;
383
+ }
384
+ /**
385
+ * Get the API key
386
+ */
387
+ getApiKey() {
388
+ return this.config.apiKey;
389
+ }
390
+ /**
391
+ * Auto-detect environment from API key
392
+ */
393
+ getEnvironmentFromApiKey(e) {
394
+ 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";
395
+ }
396
+ }
397
+ class x {
398
+ constructor(e) {
399
+ const t = {
400
+ apiKey: e.config.apiKey,
401
+ iframeUrl: e.config.iframeUrl,
402
+ timeout: e.config.timeout,
403
+ debug: e.config.debug
404
+ };
405
+ this.sdk = new w(t);
406
+ }
407
+ /**
408
+ * Create a CardElement (similar to React's <CardElement />)
409
+ *
410
+ * @param props - CardElement props (same as React SDK)
411
+ * @returns CardElement instance
412
+ */
413
+ createCardElement(e) {
414
+ let t;
415
+ if (e.container)
416
+ t = e.container;
417
+ else {
418
+ const o = document.createElement("div");
419
+ o.id = "inflowpay-card-element-container", document.body.appendChild(o), t = o;
420
+ }
421
+ const i = {
422
+ container: t,
423
+ paymentId: e.paymentId,
424
+ onComplete: (o) => {
425
+ e.onComplete && e.onComplete(o);
426
+ },
427
+ onError: e.onError,
428
+ onClose: e.onClose
429
+ }, n = this.sdk.createCardElement(i);
430
+ if (e.onReady) {
431
+ const o = n.mount.bind(n);
432
+ n.mount = () => {
433
+ o(), setTimeout(() => {
434
+ e.onReady && e.onReady();
435
+ }, 100);
436
+ };
437
+ }
438
+ return e.onChange && setTimeout(() => {
439
+ e.onChange && e.onChange({ complete: !1 });
440
+ }, 100), n;
441
+ }
442
+ /**
443
+ * Get the underlying PaymentSDK instance
444
+ */
445
+ getSDK() {
446
+ return this.sdk;
447
+ }
448
+ }
449
+ var C = /* @__PURE__ */ ((r) => (r.INITIATION = "INITIATION", r.CHECKOUT_PENDING = "CHECKOUT_PENDING", r.CHECKOUT_SUCCESS = "CHECKOUT_SUCCESS", r.CHECKOUT_CANCELED = "CHECKOUT_CANCELED", r.CANCELED = "CANCELED", r.PAYMENT_RECEIVED = "PAYMENT_RECEIVED", r.PAYMENT_SUCCESS = "PAYMENT_SUCCESS", r.PAYMENT_FAILED = "PAYMENT_FAILED", r))(C || {});
450
+ const b = "2.0.0";
451
+ export {
452
+ y as CardElement,
453
+ x as InflowPayProvider,
454
+ w as PaymentSDK,
455
+ C as PaymentStatus,
456
+ E as SDK,
457
+ b as VERSION
458
+ };
459
+ //# sourceMappingURL=sdk.esm.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"sdk.esm.js","sources":["../src/sdk.ts","../src/card-element.ts","../src/payment-sdk.ts","../src/inflowpay-provider.ts","../src/index.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 this.sendConfigToIframe();\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 // 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 = '300px';\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 this.iframe.style.cssText = `\n width: 100%;\n height: 100%;\n min-height: 300px;\n border: none;\n display: block;\n `;\n this.iframe.setAttribute('allow', 'payment');\n\n // Append to container\n this.containerElement.appendChild(this.iframe);\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 '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 * Close the iframe and cleanup\n */\n private close(): void {\n if (this.config.onClose) {\n this.config.onClose();\n }\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 && this.iframe) {\n this.containerElement.removeChild(this.iframe);\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 type { SDKConfig } from './types';\nimport { SDK } from './sdk';\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}\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 },\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 } 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 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","/**\n * InflowPayProvider - Compatibility layer for React SDK API\n * \n * Provides the same API structure as the original React SDK\n * but works with vanilla JavaScript\n */\n\nimport { PaymentSDK } from './payment-sdk';\nimport type { PaymentSDKConfig } from './payment-sdk';\nimport { CardElement } from './card-element';\nimport type { CardElementOptions } from './card-element';\n\nexport interface InflowPayProviderConfig {\n apiKey: string;\n iframeUrl?: string;\n timeout?: number;\n /** Enable debug logging (default: false, only allowed in local/dev environments) */\n debug?: boolean;\n}\n\nexport interface CardElementProps {\n paymentId: string;\n container?: string | HTMLElement;\n onComplete?: (result: { status: string; data?: any; error?: any }) => void;\n onError?: (error: any) => void;\n onClose?: () => void;\n onReady?: () => void;\n onChange?: (state: { complete: boolean }) => void;\n buttonText?: string;\n buttonStyle?: any;\n style?: any;\n placeholders?: {\n cardNumber?: string;\n expiry?: string;\n cvc?: string;\n };\n}\n\n/**\n * InflowPayProvider - Global SDK configuration\n * \n * Similar to React's InflowPayProvider but for vanilla JS\n * \n * @example\n * ```typescript\n * const provider = new InflowPayProvider({\n * config: { apiKey: 'inflow_pub_xxx' }\n * });\n * \n * const cardElement = provider.createCardElement({\n * paymentId: 'pay_xxx',\n * onComplete: (result) => {\n * if (result.status === 'CHECKOUT_SUCCESS') {\n * window.location.href = '/success';\n * }\n * }\n * });\n * \n * cardElement.mount();\n * ```\n */\nexport class InflowPayProvider {\n private sdk: PaymentSDK;\n\n constructor(options: { config: InflowPayProviderConfig }) {\n const config: PaymentSDKConfig = {\n apiKey: options.config.apiKey,\n iframeUrl: options.config.iframeUrl,\n timeout: options.config.timeout,\n debug: options.config.debug,\n };\n\n this.sdk = new PaymentSDK(config);\n }\n\n /**\n * Create a CardElement (similar to React's <CardElement />)\n * \n * @param props - CardElement props (same as React SDK)\n * @returns CardElement instance\n */\n createCardElement(props: CardElementProps): CardElement {\n let container: string | HTMLElement;\n if (props.container) {\n container = props.container;\n } else {\n const defaultContainer = document.createElement('div');\n defaultContainer.id = 'inflowpay-card-element-container';\n document.body.appendChild(defaultContainer);\n container = defaultContainer;\n }\n\n const cardElementOptions: CardElementOptions = {\n container: container,\n paymentId: props.paymentId,\n onComplete: (result) => {\n if (props.onComplete) {\n props.onComplete(result);\n }\n },\n onError: props.onError,\n onClose: props.onClose,\n };\n\n const cardElement = this.sdk.createCardElement(cardElementOptions);\n\n if (props.onReady) {\n const originalMount = cardElement.mount.bind(cardElement);\n cardElement.mount = () => {\n originalMount();\n setTimeout(() => {\n if (props.onReady) {\n props.onReady();\n }\n }, 100);\n };\n }\n\n if (props.onChange) {\n setTimeout(() => {\n if (props.onChange) {\n props.onChange({ complete: false });\n }\n }, 100);\n }\n\n return cardElement;\n }\n\n /**\n * Get the underlying PaymentSDK instance\n */\n getSDK(): PaymentSDK {\n return this.sdk;\n }\n}\n\n","/**\n * InflowPay SDK v2 - Entry point\n * \n * Provides the same API as the original React SDK but using iframe-based payment flow\n * Compatible with vanilla JavaScript and easy migration from React SDK\n */\n\nexport { InflowPayProvider } from './inflowpay-provider';\nexport type { CardElementProps, InflowPayProviderConfig } from './inflowpay-provider';\n\nexport { PaymentSDK } from './payment-sdk';\nexport type { PaymentSDKConfig } from './payment-sdk';\n\nexport { CardElement } from './card-element';\nexport type { CardElementOptions } from './card-element';\n\nexport { SDK } from './sdk';\n\nexport type { IframeMessage, PaymentConfig, TransactionData } from './types';\n\nexport enum PaymentStatus {\n INITIATION = 'INITIATION',\n CHECKOUT_PENDING = 'CHECKOUT_PENDING',\n CHECKOUT_SUCCESS = 'CHECKOUT_SUCCESS',\n CHECKOUT_CANCELED = 'CHECKOUT_CANCELED',\n CANCELED = 'CANCELED',\n PAYMENT_RECEIVED = 'PAYMENT_RECEIVED',\n PAYMENT_SUCCESS = 'PAYMENT_SUCCESS',\n PAYMENT_FAILED = 'PAYMENT_FAILED',\n}\n\nexport type PaymentResult = {\n status: string;\n data?: any;\n alreadyProcessed?: boolean;\n error?: {\n code: string;\n message: string;\n retryable: boolean;\n };\n};\n\nexport type PaymentError = {\n code: string;\n message: string;\n retryable: boolean;\n};\n\nexport type CardElementState = {\n complete: boolean;\n};\n\nexport const VERSION = '2.0.0';\n"],"names":["SDK","config","url","iframeSrc","overlay","container","closeButton","e","currentStyle","event","allowedOrigin","isAllowedOrigin","data","success","targetOrigin","message","challengeUrl","resolve","modal","header","content","iframe","closeBtn","closeHandler","messageHandler","allowed3DSOrigins","is3DSComplete","isSuccess","isFailure","apiKey","CardElement","options","containerElement","error","PaymentSDK","iframeUrl","environment","requestedDebug","debug","InflowPayProvider","props","defaultContainer","cardElementOptions","result","cardElement","originalMount","PaymentStatus","VERSION"],"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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AkB,mBAClBA,EAAA,iBAAiB,kBARPA,IAAAA,KAAA,CAAA,CAAA;AAgCL,MAAMC,IAAU;"}
@@ -0,0 +1,87 @@
1
+ (function(s,c){typeof exports=="object"&&typeof module<"u"?c(exports):typeof define=="function"&&define.amd?define(["exports"],c):(s=typeof globalThis<"u"?globalThis:s||self,c(s.InflowPaySDK={}))})(this,(function(s){"use strict";class c{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(),this.sendConfigToIframe())}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 o=document.createElement("button");o.innerHTML="×",o.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
+ `,o.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(o),n.appendChild(this.iframe),i.appendChild(n),document.body.appendChild(i),i.addEventListener("click",a=>{a.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 i=this.containerElement.getAttribute("style")||"";i.includes("min-height")||(this.containerElement.style.minHeight="300px"),i.includes("position")||(this.containerElement.style.position="relative"),i.includes("overflow")||(this.containerElement.style.overflow="hidden")}this.iframe=document.createElement("iframe"),this.iframe.src=t,this.iframe.style.cssText=`
42
+ width: 100%;
43
+ height: 100%;
44
+ min-height: 300px;
45
+ border: none;
46
+ display: block;
47
+ `,this.iframe.setAttribute("allow","payment"),this.containerElement.appendChild(this.iframe)}}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 o=e.data;if(!(!o||!o.type))switch(o.type){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 d=this.getTargetOrigin();this.iframe.contentWindow.postMessage({type:"3ds-result",success:a,paymentId:o.paymentId||this.config.config?.paymentId},d)}})):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 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)}close(){if(this.config.onClose&&this.config.onClose(),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.iframe&&this.containerElement.removeChild(this.iframe);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=`
48
+ position: fixed;
49
+ top: 0;
50
+ left: 0;
51
+ width: 100%;
52
+ height: 100%;
53
+ background-color: rgba(0, 0, 0, 0.7);
54
+ display: flex;
55
+ align-items: center;
56
+ justify-content: center;
57
+ z-index: 999999;
58
+ `;const n=document.createElement("div");n.style.cssText=`
59
+ position: relative;
60
+ width: 90%;
61
+ max-width: 500px;
62
+ height: 90%;
63
+ max-height: 600px;
64
+ background: white;
65
+ border-radius: 8px;
66
+ box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
67
+ display: flex;
68
+ flex-direction: column;
69
+ `;const o=document.createElement("div");o.style.cssText=`
70
+ display: flex;
71
+ align-items: center;
72
+ justify-content: space-between;
73
+ padding: 15px 20px;
74
+ border-bottom: 1px solid #e5e5e5;
75
+ `,o.innerHTML=`
76
+ <h3 style="margin: 0; font-size: 18px; font-weight: 600;">Secure Payment Authentication</h3>
77
+ <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>
78
+ `;const a=document.createElement("div");a.style.cssText=`
79
+ flex: 1;
80
+ position: relative;
81
+ overflow: hidden;
82
+ `;const d=document.createElement("iframe");d.src=e,d.style.cssText=`
83
+ width: 100%;
84
+ height: 100%;
85
+ border: none;
86
+ `,d.setAttribute("allow","payment"),d.setAttribute("sandbox","allow-forms allow-scripts allow-same-origin allow-popups"),a.appendChild(d),n.appendChild(o),n.appendChild(a),i.appendChild(n),document.body.appendChild(i);const x=i.querySelector("#inflowpay-3ds-close"),v=()=>{i.remove(),window.removeEventListener("message",m),t(!1)};x?.addEventListener("click",v);const m=l=>{if(!l.data)return;const y=["https://dev.api.inflowpay.com","https://pre-prod.api.inflowpay.xyz","https://api.inflowpay.xyz"];if(this.environment==="sandbox"||this.environment==="development"){if(!(l.origin.includes("localhost")||l.origin.includes("127.0.0.1"))){if(!y.includes(l.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",l.origin);return}}}else if(!y.includes(l.origin)){this.config.debug&&console.warn("[SDK] Rejected 3DS message from unauthorized origin:",l.origin);return}const f=l.data,h=f.type==="THREE_DS_COMPLETE"||f.type==="3ds-complete",E=f.status==="success",w=f.status==="failed"||f.status==="failure";if(h&&E){i.remove(),window.removeEventListener("message",m),t(!0);return}if(E&&!h){i.remove(),window.removeEventListener("message",m),t(!0);return}if(h&&w||f.type==="3ds-failed"||w){i.remove(),window.removeEventListener("message",m),t(!1);return}};window.addEventListener("message",m)})}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 u{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 c({iframeUrl:e.iframeUrl,apiKey:e.apiKey,container:this.container,config:{paymentId:t.paymentId},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 p{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 o=n&&(i==="sandbox"||i==="development");this.config={apiKey:e.apiKey,iframeUrl:t,timeout:e.timeout??3e4,debug:o}}createCardElement(e){return new u(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"}}class C{constructor(e){const t={apiKey:e.config.apiKey,iframeUrl:e.config.iframeUrl,timeout:e.config.timeout,debug:e.config.debug};this.sdk=new p(t)}createCardElement(e){let t;if(e.container)t=e.container;else{const o=document.createElement("div");o.id="inflowpay-card-element-container",document.body.appendChild(o),t=o}const i={container:t,paymentId:e.paymentId,onComplete:o=>{e.onComplete&&e.onComplete(o)},onError:e.onError,onClose:e.onClose},n=this.sdk.createCardElement(i);if(e.onReady){const o=n.mount.bind(n);n.mount=()=>{o(),setTimeout(()=>{e.onReady&&e.onReady()},100)}}return e.onChange&&setTimeout(()=>{e.onChange&&e.onChange({complete:!1})},100),n}getSDK(){return this.sdk}}var g=(r=>(r.INITIATION="INITIATION",r.CHECKOUT_PENDING="CHECKOUT_PENDING",r.CHECKOUT_SUCCESS="CHECKOUT_SUCCESS",r.CHECKOUT_CANCELED="CHECKOUT_CANCELED",r.CANCELED="CANCELED",r.PAYMENT_RECEIVED="PAYMENT_RECEIVED",r.PAYMENT_SUCCESS="PAYMENT_SUCCESS",r.PAYMENT_FAILED="PAYMENT_FAILED",r))(g||{});const b="2.0.0";s.CardElement=u,s.InflowPayProvider=C,s.PaymentSDK=p,s.PaymentStatus=g,s.SDK=c,s.VERSION=b,Object.defineProperty(s,Symbol.toStringTag,{value:"Module"})}));
87
+ //# sourceMappingURL=sdk.umd.js.map