pay-sdk-web9 1.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,1372 @@
1
+ import React, { useState, useEffect } from 'react';
2
+
3
+ const HasAccountSummary = ({
4
+ onClose
5
+ }) => {
6
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
7
+ className: "popup-content"
8
+ }, /*#__PURE__*/React.createElement("div", {
9
+ className: "popup-header"
10
+ }, /*#__PURE__*/React.createElement("div", {
11
+ className: "logo"
12
+ }, /*#__PURE__*/React.createElement("img", {
13
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
14
+ alt: "EvZone Logo",
15
+ className: "header-icon"
16
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
17
+ className: "evzone"
18
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
19
+ className: "pay"
20
+ }, " Pay")), /*#__PURE__*/React.createElement("button", {
21
+ className: "close-btn",
22
+ onClick: onClose
23
+ }, /*#__PURE__*/React.createElement("span", null, "\xD7"))), /*#__PURE__*/React.createElement("div", {
24
+ className: "error-content"
25
+ }, /*#__PURE__*/React.createElement("div", {
26
+ className: "message-container"
27
+ }, /*#__PURE__*/React.createElement("div", {
28
+ className: "info-icon"
29
+ }, "i"), /*#__PURE__*/React.createElement("div", {
30
+ className: "message-text"
31
+ }, /*#__PURE__*/React.createElement("h3", null, "EVzone requires you to sign in to proceed with this transaction"))), /*#__PURE__*/React.createElement("button", {
32
+ onClick: onClose,
33
+ className: "submit-button"
34
+ }, "Sign in"))), /*#__PURE__*/React.createElement("style", null, `
35
+ .popup-content {
36
+ display: flex;
37
+ flex-direction: column;
38
+ align-items: center;
39
+ background: white;
40
+ border-radius: 10px;
41
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
42
+ max-width: 400px;
43
+ width: 90%;
44
+ text-align: center;
45
+ border: 1px solid #ddd;
46
+ font-family: Arial, sans-serif;
47
+ }
48
+
49
+ .popup-header {
50
+ display: flex;
51
+ align-items: center;
52
+ justify-content: space-between;
53
+ margin-bottom: 15px;
54
+ width: 100%;
55
+ padding: 10px 15px;
56
+ border-bottom: 1px solid #ddd;
57
+ }
58
+
59
+ .logo {
60
+ width: 40px;
61
+ height: 40px;
62
+ display: flex;
63
+ align-items: center;
64
+ justify-content: center;
65
+ margin-right: 10px;
66
+ border-radius: 50%;
67
+ overflow: hidden;
68
+ }
69
+
70
+ .header-icon {
71
+ width: 100%;
72
+ height: auto;
73
+ }
74
+
75
+ .popup-header h2 {
76
+ font-size: 1.2em;
77
+ color: #080808;
78
+ margin: 0;
79
+ font-weight: bold;
80
+ text-align: left;
81
+ flex-grow: 1;
82
+ }
83
+
84
+ .popup-header .evzone {
85
+ color: #0a0a0a;
86
+ }
87
+
88
+ .popup-header .pay {
89
+ color: #0a0a0a;
90
+ }
91
+
92
+ .close-btn {
93
+ background: none;
94
+ border: none;
95
+ font-size: 1.5em;
96
+ color: #ff5a5f;
97
+ cursor: pointer;
98
+ }
99
+
100
+ .error-content {
101
+ display: flex;
102
+ flex-direction: column;
103
+ align-items: center;
104
+ padding: 20px;
105
+ background-color: #fff;
106
+ border-radius: 8px;
107
+ }
108
+
109
+ .message-container {
110
+ display: flex;
111
+ align-items: center;
112
+ width: 100%;
113
+ margin-bottom: 20px;
114
+ background-color: #e0f7fa;
115
+ border-radius: 10px;
116
+ padding: 10px 15px;
117
+ }
118
+
119
+ .info-icon {
120
+ display: flex;
121
+ justify-content: center;
122
+ align-items: center;
123
+ width: 40px;
124
+ height: 40px;
125
+ background-color: #b3e5fc;
126
+ color: #0288d1;
127
+ border-radius: 50%;
128
+ font-size: 24px;
129
+ font-weight: bold;
130
+ margin-right: 15px;
131
+ }
132
+
133
+ .message-text {
134
+ flex: 1;
135
+ }
136
+
137
+ .message-text h3 {
138
+ font-size: 1.2em;
139
+ margin: 0;
140
+ color: #333;
141
+ font-weight: 500;
142
+ }
143
+
144
+ .submit-button {
145
+ background-color: #0288d1;
146
+ color: #fff;
147
+ border: none;
148
+ border-radius: 5px;
149
+ padding: 10px 20px;
150
+ font-size: 1em;
151
+ font-weight: 500;
152
+ cursor: pointer;
153
+ transition: background-color 0.3s ease;
154
+ width: 100%;
155
+ max-width: 200px;
156
+ }
157
+
158
+ .submit-button:hover {
159
+ background-color: #0277bd;
160
+ }
161
+ `));
162
+ };
163
+
164
+ const TransactionSummary = ({
165
+ transactionDetails,
166
+ onConfirm
167
+ }) => {
168
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
169
+ className: "popup-content"
170
+ }, /*#__PURE__*/React.createElement("div", {
171
+ className: "popup-header"
172
+ }, /*#__PURE__*/React.createElement("div", {
173
+ className: "logo"
174
+ }, /*#__PURE__*/React.createElement("img", {
175
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
176
+ alt: "EvZone Logo",
177
+ className: "header-icon"
178
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
179
+ className: "evzone"
180
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
181
+ className: "pay"
182
+ }, " Pay"))), /*#__PURE__*/React.createElement("div", {
183
+ className: "transaction-summary"
184
+ }, /*#__PURE__*/React.createElement("div", {
185
+ className: "merchant-info"
186
+ }, /*#__PURE__*/React.createElement("strong", null, "Airbnb")), /*#__PURE__*/React.createElement("div", {
187
+ className: "total-billing"
188
+ }, "UGX ", transactionDetails.totalBilling.toFixed(2)), /*#__PURE__*/React.createElement("div", {
189
+ className: "transaction-details"
190
+ }, /*#__PURE__*/React.createElement("h4", null, "Transaction Details"), /*#__PURE__*/React.createElement("div", {
191
+ className: "detail"
192
+ }, /*#__PURE__*/React.createElement("span", null, "Type"), /*#__PURE__*/React.createElement("strong", null, transactionDetails.type)), /*#__PURE__*/React.createElement("div", {
193
+ className: "detail"
194
+ }, /*#__PURE__*/React.createElement("span", null, "ID"), /*#__PURE__*/React.createElement("strong", null, transactionDetails.id)), /*#__PURE__*/React.createElement("div", {
195
+ className: "detail"
196
+ }, /*#__PURE__*/React.createElement("span", null, "Particulars"), /*#__PURE__*/React.createElement("strong", null, transactionDetails.particulars)), /*#__PURE__*/React.createElement("div", {
197
+ className: "detail"
198
+ }, /*#__PURE__*/React.createElement("span", null, "Billed Currency"), /*#__PURE__*/React.createElement("strong", null, transactionDetails.billedCurrency)), /*#__PURE__*/React.createElement("div", {
199
+ className: "detail"
200
+ }, /*#__PURE__*/React.createElement("span", null, "Billed Amount"), /*#__PURE__*/React.createElement("strong", null, "UGX ", transactionDetails.billedAmount.toFixed(2))), /*#__PURE__*/React.createElement("div", {
201
+ className: "detail total-billing-detail"
202
+ }, /*#__PURE__*/React.createElement("span", null, "Total Billing"), /*#__PURE__*/React.createElement("strong", null, "UGX ", transactionDetails.totalBilling.toFixed(2)))), /*#__PURE__*/React.createElement("button", {
203
+ onClick: onConfirm,
204
+ className: "confirm-button"
205
+ }, "Confirm"))), /*#__PURE__*/React.createElement("style", null, `
206
+ .popup-content {
207
+ display: flex;
208
+ flex-direction: column;
209
+ align-items: center;
210
+ background: white;
211
+ border-radius: 10px;
212
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
213
+ max-width: 400px;
214
+ width: 90%;
215
+ text-align: center;
216
+ border: 1px solid #ddd;
217
+ font-family: Arial, sans-serif;
218
+ z-index: 1001; /* Ensure popup is above overlay */
219
+ }
220
+
221
+ .popup-header {
222
+ display: flex;
223
+ align-items: center;
224
+ justify-content: center;
225
+ margin-bottom: 15px;
226
+ width: 100%;
227
+ padding: 10px 15px;
228
+ border-bottom: 1px solid #ddd;
229
+ }
230
+
231
+ .logo {
232
+ width: 40px;
233
+ height: 40px;
234
+ display: flex;
235
+ align-items: center;
236
+ justify-content: center;
237
+ margin-right: 10px;
238
+ border-radius: 50%;
239
+ overflow: hidden;
240
+ }
241
+
242
+ .header-icon {
243
+ width: 100%;
244
+ height: auto;
245
+ }
246
+
247
+ .popup-header h2 {
248
+ font-size: 1.2em;
249
+ color: #080808;
250
+ margin: 0;
251
+ font-weight: bold;
252
+ }
253
+
254
+ .popup-header .evzone {
255
+ color: #0a0a0a;
256
+ }
257
+
258
+ .popup-header .pay {
259
+ color: #0a0a0a;
260
+ }
261
+
262
+ .transaction-summary {
263
+ text-align: center;
264
+ width: 100%;
265
+ padding: 0 15px;
266
+ }
267
+
268
+ .merchant-info {
269
+ font-size: 1.2em;
270
+ font-weight: bold;
271
+ color: #333;
272
+ margin-bottom: 10px;
273
+ }
274
+
275
+ .total-billing {
276
+ font-size: 1.5em;
277
+ font-weight: bold;
278
+ color: #02CD8D;
279
+ text-align: center;
280
+ padding: 10px 0;
281
+ margin-bottom: 15px;
282
+ }
283
+
284
+ .transaction-details {
285
+ background: #f9f9f9;
286
+ padding: 15px;
287
+ border-radius: 8px;
288
+ margin-bottom: 20px;
289
+ display: flex;
290
+ flex-direction: column;
291
+ text-align: left;
292
+ }
293
+
294
+ .transaction-details h4 {
295
+ font-size: 1.1em;
296
+ font-weight: bold;
297
+ color: #333;
298
+ margin-bottom: 10px;
299
+ }
300
+
301
+ .transaction-details .detail {
302
+ display: flex;
303
+ justify-content: space-between;
304
+ align-items: center;
305
+ padding: 5px 0;
306
+ width: 100%;
307
+ }
308
+
309
+ .transaction-details span {
310
+ color: #666;
311
+ font-size: 0.9em;
312
+ flex-shrink: 0;
313
+ }
314
+
315
+ .transaction-details strong {
316
+ color: #000;
317
+ font-size: 0.9em;
318
+ text-align: right;
319
+ flex-shrink: 0;
320
+ }
321
+
322
+ .transaction-details .total-billing-detail {
323
+ margin-top: 10px;
324
+ padding-top: 10px;
325
+ border-top: 1px solid #ddd;
326
+ }
327
+
328
+ .confirm-button {
329
+ width: 100%;
330
+ background: #007bff;
331
+ color: #fff;
332
+ padding: 12px;
333
+ border-radius: 5px;
334
+ font-size: 1.1em;
335
+ cursor: pointer;
336
+ border: none;
337
+ transition: background-color 0.3s ease;
338
+ }
339
+
340
+ .confirm-button:hover {
341
+ background: #0056b3;
342
+ }
343
+ `));
344
+ };
345
+
346
+ var DefaultContext = {
347
+ color: undefined,
348
+ size: undefined,
349
+ className: undefined,
350
+ style: undefined,
351
+ attr: undefined
352
+ };
353
+ var IconContext = React.createContext && /*#__PURE__*/React.createContext(DefaultContext);
354
+
355
+ var _excluded = ["attr", "size", "title"];
356
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
357
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } } return target; }
358
+ function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
359
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
360
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), true).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
361
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
362
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == typeof i ? i : i + ""; }
363
+ function _toPrimitive(t, r) { if ("object" != typeof t || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r); if ("object" != typeof i) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
364
+ function Tree2Element(tree) {
365
+ return tree && tree.map((node, i) => /*#__PURE__*/React.createElement(node.tag, _objectSpread({
366
+ key: i
367
+ }, node.attr), Tree2Element(node.child)));
368
+ }
369
+ function GenIcon(data) {
370
+ return props => /*#__PURE__*/React.createElement(IconBase, _extends({
371
+ attr: _objectSpread({}, data.attr)
372
+ }, props), Tree2Element(data.child));
373
+ }
374
+ function IconBase(props) {
375
+ var elem = conf => {
376
+ var {
377
+ attr,
378
+ size,
379
+ title
380
+ } = props,
381
+ svgProps = _objectWithoutProperties(props, _excluded);
382
+ var computedSize = size || conf.size || "1em";
383
+ var className;
384
+ if (conf.className) className = conf.className;
385
+ if (props.className) className = (className ? className + " " : "") + props.className;
386
+ return /*#__PURE__*/React.createElement("svg", _extends({
387
+ stroke: "currentColor",
388
+ fill: "currentColor",
389
+ strokeWidth: "0"
390
+ }, conf.attr, attr, svgProps, {
391
+ className: className,
392
+ style: _objectSpread(_objectSpread({
393
+ color: props.color || conf.color
394
+ }, conf.style), props.style),
395
+ height: computedSize,
396
+ width: computedSize,
397
+ xmlns: "http://www.w3.org/2000/svg"
398
+ }), title && /*#__PURE__*/React.createElement("title", null, title), props.children);
399
+ };
400
+ return IconContext !== undefined ? /*#__PURE__*/React.createElement(IconContext.Consumer, null, conf => elem(conf)) : elem(DefaultContext);
401
+ }
402
+
403
+ // THIS FILE IS AUTO GENERATED
404
+ function IoEyeOff (props) {
405
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M432 448a15.92 15.92 0 0 1-11.31-4.69l-352-352a16 16 0 0 1 22.62-22.62l352 352A16 16 0 0 1 432 448zM248 315.85l-51.79-51.79a2 2 0 0 0-3.39 1.69 64.11 64.11 0 0 0 53.49 53.49 2 2 0 0 0 1.69-3.39zm16-119.7L315.87 248a2 2 0 0 0 3.4-1.69 64.13 64.13 0 0 0-53.55-53.55 2 2 0 0 0-1.72 3.39z"},"child":[]},{"tag":"path","attr":{"d":"M491 273.36a32.2 32.2 0 0 0-.1-34.76c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.68 96a226.54 226.54 0 0 0-71.82 11.79 4 4 0 0 0-1.56 6.63l47.24 47.24a4 4 0 0 0 3.82 1.05 96 96 0 0 1 116 116 4 4 0 0 0 1.05 3.81l67.95 68a4 4 0 0 0 5.4.24 343.81 343.81 0 0 0 67.24-77.4zM256 352a96 96 0 0 1-93.3-118.63 4 4 0 0 0-1.05-3.81l-66.84-66.87a4 4 0 0 0-5.41-.23c-24.39 20.81-47 46.13-67.67 75.72a31.92 31.92 0 0 0-.64 35.54c26.41 41.33 60.39 76.14 98.28 100.65C162.06 402 207.92 416 255.68 416a238.22 238.22 0 0 0 72.64-11.55 4 4 0 0 0 1.61-6.64l-47.47-47.46a4 4 0 0 0-3.81-1.05A96 96 0 0 1 256 352z"},"child":[]}]})(props);
406
+ }function IoEye (props) {
407
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"circle","attr":{"cx":"256","cy":"256","r":"64"},"child":[]},{"tag":"path","attr":{"d":"M490.84 238.6c-26.46-40.92-60.79-75.68-99.27-100.53C349 110.55 302 96 255.66 96c-42.52 0-84.33 12.15-124.27 36.11-40.73 24.43-77.63 60.12-109.68 106.07a31.92 31.92 0 0 0-.64 35.54c26.41 41.33 60.4 76.14 98.28 100.65C162 402 207.9 416 255.66 416c46.71 0 93.81-14.43 136.2-41.72 38.46-24.77 72.72-59.66 99.08-100.92a32.2 32.2 0 0 0-.1-34.76zM256 352a96 96 0 1 1 96-96 96.11 96.11 0 0 1-96 96z"},"child":[]}]})(props);
408
+ }
409
+
410
+ const EnterPasscode = ({
411
+ passcode,
412
+ setPasscode,
413
+ showPasscode,
414
+ setShowPasscode,
415
+ transactionDetails,
416
+ onSubmit,
417
+ onBack
418
+ }) => {
419
+ const renderHeader = () => /*#__PURE__*/React.createElement("div", {
420
+ className: "popup-header"
421
+ }, /*#__PURE__*/React.createElement("div", {
422
+ className: "logo"
423
+ }, /*#__PURE__*/React.createElement("img", {
424
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
425
+ alt: "EVzone Logo",
426
+ className: "header-icon"
427
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
428
+ className: "evzone"
429
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
430
+ className: "pay"
431
+ }, " Pay")));
432
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
433
+ className: "passcode-popup"
434
+ }, renderHeader(), /*#__PURE__*/React.createElement("div", {
435
+ className: "merchant-header"
436
+ }, "Merchant Info :"), /*#__PURE__*/React.createElement("div", {
437
+ className: "merchant-details"
438
+ }, /*#__PURE__*/React.createElement("div", {
439
+ className: "merchant-left"
440
+ }, /*#__PURE__*/React.createElement("div", {
441
+ className: "merchant-info"
442
+ }, /*#__PURE__*/React.createElement("div", {
443
+ className: "merchant-name"
444
+ }, "Airbnb"), /*#__PURE__*/React.createElement("div", {
445
+ className: "merchant-id"
446
+ }, "W-123456789"))), /*#__PURE__*/React.createElement("div", {
447
+ className: "merchant-amount"
448
+ }, /*#__PURE__*/React.createElement("strong", null, "UGX ", transactionDetails.totalBilling.toFixed(2)))), /*#__PURE__*/React.createElement("div", {
449
+ className: "passcode-section"
450
+ }, /*#__PURE__*/React.createElement("label", {
451
+ htmlFor: "passcode"
452
+ }, "Enter Passcode"), /*#__PURE__*/React.createElement("div", {
453
+ className: "passcode-input"
454
+ }, /*#__PURE__*/React.createElement("input", {
455
+ type: showPasscode ? "text" : "password",
456
+ id: "passcode",
457
+ value: passcode,
458
+ onChange: e => setPasscode(e.target.value),
459
+ placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022",
460
+ maxLength: "6"
461
+ }), /*#__PURE__*/React.createElement("span", {
462
+ className: "toggle-visibility",
463
+ onClick: () => setShowPasscode(!showPasscode)
464
+ }, showPasscode ? /*#__PURE__*/React.createElement(IoEye, null) : /*#__PURE__*/React.createElement(IoEyeOff, null)))), /*#__PURE__*/React.createElement("div", {
465
+ className: "transaction-details"
466
+ }, /*#__PURE__*/React.createElement("p", null, "You are making a payment to ", /*#__PURE__*/React.createElement("strong", null, "Acorn International School"), " and an amount of", /*#__PURE__*/React.createElement("strong", null, " UGX ", transactionDetails.totalBilling.toFixed(2)), " will be deducted off your wallet, including:", /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("strong", null, "0.5% Tax:"), " UGX ", (transactionDetails.totalBilling * 0.005).toFixed(2), /*#__PURE__*/React.createElement("br", null), /*#__PURE__*/React.createElement("strong", null, "0.5% Wallet Fee:"), " UGX ", (transactionDetails.totalBilling * 0.005).toFixed(2))), /*#__PURE__*/React.createElement("div", {
467
+ className: "buttons-container"
468
+ }, /*#__PURE__*/React.createElement("button", {
469
+ onClick: onSubmit,
470
+ className: "confirm-button",
471
+ disabled: !passcode
472
+ }, "Confirm Payment"), /*#__PURE__*/React.createElement("button", {
473
+ onClick: onBack,
474
+ className: "back-button",
475
+ style: {
476
+ marginTop: '15px'
477
+ }
478
+ }, "Back"))), /*#__PURE__*/React.createElement("style", null, `
479
+ .passcode-popup {
480
+ display: flex;
481
+ flex-direction: column;
482
+ align-items: center;
483
+ background: white;
484
+ padding: 20px;
485
+ border-radius: 10px;
486
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
487
+ max-width: 400px;
488
+ width: 90%;
489
+ text-align: center;
490
+ border: 1px solid #ddd;
491
+ font-family: Arial, sans-serif;
492
+ z-index: 1001;
493
+ position: relative;
494
+ pointer-events: auto;
495
+ }
496
+
497
+ .popup-header {
498
+ display: flex;
499
+ align-items: center;
500
+ justify-content: center;
501
+ margin-bottom: 15px;
502
+ width: 100%;
503
+ padding: 10px 15px;
504
+ border-bottom: 1px solid #ddd;
505
+ }
506
+
507
+ .logo {
508
+ width: 40px;
509
+ height: 40px;
510
+ display: flex;
511
+ align-items: center;
512
+ justify-content: center;
513
+ margin-right: 10px;
514
+ border-radius: 50%;
515
+ overflow: hidden;
516
+ }
517
+
518
+ .header-icon {
519
+ width: 100%;
520
+ height: auto;
521
+ }
522
+
523
+ .popup-header h2 {
524
+ font-size: 1.2em;
525
+ color: #080808;
526
+ margin: 0;
527
+ font-weight: bold;
528
+ }
529
+
530
+ .popup-header .evzone {
531
+ color: #0a0a0a;
532
+ }
533
+
534
+ .popup-header .pay {
535
+ color: #0a0a0a;
536
+ }
537
+
538
+ .merchant-header {
539
+ font-size: 1.2em;
540
+ font-weight: bold;
541
+ color: #02CD8D;
542
+ text-align: left;
543
+ margin-bottom: 10px;
544
+ width: 100%;
545
+ }
546
+
547
+ .merchant-details {
548
+ display: flex;
549
+ justify-content: space-between;
550
+ align-items: center;
551
+ background: #f9f9f9;
552
+ padding: 12px;
553
+ border-radius: 8px;
554
+ margin-bottom: 15px;
555
+ width: 100%;
556
+ }
557
+
558
+ .merchant-left {
559
+ display: flex;
560
+ align-items: center;
561
+ }
562
+
563
+ .merchant-info {
564
+ display: flex;
565
+ flex-direction: column;
566
+ text-align: left;
567
+ }
568
+
569
+ .merchant-name {
570
+ font-size: 1em;
571
+ font-weight: bold;
572
+ }
573
+
574
+ .merchant-id {
575
+ font-size: 0.9em;
576
+ color: #666;
577
+ }
578
+
579
+ .merchant-amount {
580
+ text-align: right;
581
+ }
582
+
583
+ .merchant-amount strong {
584
+ font-size: 1.2em;
585
+ font-weight: bold;
586
+ color: #000;
587
+ }
588
+
589
+ .passcode-section {
590
+ text-align: left;
591
+ margin-bottom: 20px;
592
+ width: 100%;
593
+ }
594
+
595
+ .passcode-section label {
596
+ font-size: 1em;
597
+ font-weight: bold;
598
+ color: #000;
599
+ }
600
+
601
+ .passcode-input {
602
+ position: relative;
603
+ width: 100%;
604
+ border: 1px solid #ccc;
605
+ border-radius: 8px;
606
+ padding: 12px;
607
+ font-size: 1.1em;
608
+ text-align: center;
609
+ letter-spacing: 5px;
610
+ background: transparent;
611
+ display: flex;
612
+ align-items: center;
613
+ }
614
+
615
+ .passcode-input input {
616
+ flex: 1;
617
+ border: none;
618
+ outline: none;
619
+ text-align: center;
620
+ font-size: 1.4em;
621
+ letter-spacing: 5px;
622
+ background: transparent;
623
+ color: #000;
624
+ font-weight: bold;
625
+ }
626
+
627
+ .passcode-input .toggle-visibility {
628
+ position: absolute;
629
+ right: 12px;
630
+ top: 50%;
631
+ transform: translateY(-50%);
632
+ cursor: pointer;
633
+ font-size: 1.5em;
634
+ color: #000;
635
+ }
636
+
637
+ .transaction-details {
638
+ display: flex;
639
+ align-items: flex-start;
640
+ background: #e0f0ff;
641
+ padding: 12px;
642
+ border-radius: 8px;
643
+ text-align: left;
644
+ width: 100%;
645
+ margin-bottom: 20px;
646
+ }
647
+
648
+ .transaction-details p {
649
+ font-size: 1em;
650
+ color: #000;
651
+ line-height: 1.5;
652
+ margin: 0;
653
+ }
654
+
655
+ .buttons-container {
656
+ width: 100%;
657
+ }
658
+
659
+ .confirm-button {
660
+ width: 100%;
661
+ background: #007bff;
662
+ color: #fff;
663
+ padding: 12px;
664
+ border-radius: 5px;
665
+ font-size: 1.1em;
666
+ cursor: pointer;
667
+ border: none;
668
+ transition: background-color 0.3s ease;
669
+ }
670
+
671
+ .confirm-button:disabled {
672
+ background: #ddd;
673
+ cursor: not-allowed;
674
+ }
675
+
676
+ .confirm-button:hover:not(:disabled) {
677
+ background: #0056b3;
678
+ }
679
+
680
+ .back-button {
681
+ width: 100%;
682
+ background: white;
683
+ border: 2px solid red;
684
+ color: red;
685
+ padding: 10px 15px;
686
+ border-radius: 5px;
687
+ font-size: 1em;
688
+ cursor: pointer;
689
+ transition: all 0.3s ease;
690
+ }
691
+
692
+ .back-button:hover {
693
+ background: white;
694
+ color: red;
695
+ border-color: red;
696
+ }
697
+ `));
698
+ };
699
+
700
+ // THIS FILE IS AUTO GENERATED
701
+ function FaCheckCircle (props) {
702
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M504 256c0 136.967-111.033 248-248 248S8 392.967 8 256 119.033 8 256 8s248 111.033 248 248zM227.314 387.314l184-184c6.248-6.248 6.248-16.379 0-22.627l-22.627-22.627c-6.248-6.249-16.379-6.249-22.628 0L216 308.118l-70.059-70.059c-6.248-6.248-16.379-6.248-22.628 0l-22.627 22.627c-6.248 6.248-6.248 16.379 0 22.627l104 104c6.249 6.249 16.379 6.249 22.628.001z"},"child":[]}]})(props);
703
+ }function FaExclamationCircle (props) {
704
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M504 256c0 136.997-111.043 248-248 248S8 392.997 8 256C8 119.083 119.043 8 256 8s248 111.083 248 248zm-248 50c-25.405 0-46 20.595-46 46s20.595 46 46 46 46-20.595 46-46-20.595-46-46-46zm-43.673-165.346l7.418 136c.347 6.364 5.609 11.346 11.982 11.346h48.546c6.373 0 11.635-4.982 11.982-11.346l7.418-136c.375-6.874-5.098-12.654-11.982-12.654h-63.383c-6.884 0-12.356 5.78-11.981 12.654z"},"child":[]}]})(props);
705
+ }function FaTimesCircle (props) {
706
+ return GenIcon({"attr":{"viewBox":"0 0 512 512"},"child":[{"tag":"path","attr":{"d":"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm121.6 313.1c4.7 4.7 4.7 12.3 0 17L338 377.6c-4.7 4.7-12.3 4.7-17 0L256 312l-65.1 65.6c-4.7 4.7-12.3 4.7-17 0L134.4 338c-4.7-4.7-4.7-12.3 0-17l65.6-65-65.6-65.1c-4.7-4.7-4.7-12.3 0-17l39.6-39.6c4.7-4.7 12.3-4.7 17 0l65 65.7 65.1-65.6c4.7-4.7 12.3-4.7 17 0l39.6 39.6c4.7 4.7 4.7 12.3 0 17L312 256l65.6 65.1z"},"child":[]}]})(props);
707
+ }
708
+
709
+ const PaymentSuccess = ({
710
+ amount,
711
+ onClose
712
+ }) => {
713
+ const renderHeader = () => /*#__PURE__*/React.createElement("div", {
714
+ className: "popup-header"
715
+ }, /*#__PURE__*/React.createElement("div", {
716
+ className: "logo"
717
+ }, /*#__PURE__*/React.createElement("img", {
718
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
719
+ alt: "EvZone Logo",
720
+ className: "header-icon"
721
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
722
+ className: "evzone"
723
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
724
+ className: "pay"
725
+ }, " Pay")));
726
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
727
+ className: "popup-content"
728
+ }, renderHeader(), /*#__PURE__*/React.createElement("div", {
729
+ className: "success-content"
730
+ }, /*#__PURE__*/React.createElement(FaCheckCircle, {
731
+ className: "icon"
732
+ }), /*#__PURE__*/React.createElement("h3", null, "Payment Successful"), /*#__PURE__*/React.createElement("p", null, "Your payment of UGX ", amount.toFixed(2), " was processed successfully!"), /*#__PURE__*/React.createElement("button", {
733
+ onClick: onClose,
734
+ className: "close-button"
735
+ }, "Close"))), /*#__PURE__*/React.createElement("style", null, `
736
+ .popup-content {
737
+ display: flex;
738
+ flex-direction: column;
739
+ align-items: center;
740
+ background: white;
741
+ border-radius: 10px;
742
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
743
+ max-width: 400px;
744
+ width: 90%;
745
+ text-align: center;
746
+ border: 1px solid #ddd;
747
+ font-family: Arial, sans-serif;
748
+ }
749
+
750
+ .popup-header {
751
+ display: flex;
752
+ align-items: center;
753
+ justify-content: center;
754
+ margin-bottom: 15px;
755
+ width: 100%;
756
+ padding: 10px 15px;
757
+ border-bottom: 1px solid #ddd;
758
+ }
759
+
760
+ .logo {
761
+ width: 40px;
762
+ height: 40px;
763
+ display: flex;
764
+ align-items: center;
765
+ justify-content: center;
766
+ margin-right: 10px;
767
+ border-radius: 50%;
768
+ overflow: hidden;
769
+ }
770
+
771
+ .header-icon {
772
+ width: 100%;
773
+ height: auto;
774
+ }
775
+
776
+ .popup-header h2 {
777
+ font-size: 1.2em;
778
+ color: #080808;
779
+ margin: 0;
780
+ font-weight: bold;
781
+ }
782
+
783
+ .popup-header .evzone {
784
+ color: #0a0a0a;
785
+ }
786
+
787
+ .popup-header .pay {
788
+ color: #0a0a0a;
789
+ }
790
+
791
+ .success-content {
792
+ display: flex;
793
+ flex-direction: column;
794
+ align-items: center;
795
+ padding: 20px;
796
+ background-color: #fff;
797
+ border-radius: 8px;
798
+ }
799
+
800
+ .success-content .icon {
801
+ color: #02CD8D;
802
+ font-size: 40px;
803
+ margin-bottom: 10px;
804
+ }
805
+
806
+ .success-content h3 {
807
+ font-size: 1.2em;
808
+ margin: 0 0 15px;
809
+ color: #333;
810
+ font-weight: 500;
811
+ }
812
+
813
+ .success-content p {
814
+ font-size: 1em;
815
+ color: #666;
816
+ margin-bottom: 15px;
817
+ }
818
+
819
+ .close-button {
820
+ background-color: #0288d1;
821
+ color: #fff;
822
+ border: none;
823
+ border-radius: 5px;
824
+ padding: 10px 20px;
825
+ font-size: 1em;
826
+ font-weight: 500;
827
+ cursor: pointer;
828
+ transition: background-color 0.3s ease;
829
+ width: 100%;
830
+ max-width: 200px;
831
+ }
832
+
833
+ .close-button:hover {
834
+ background-color: #0277bd;
835
+ }
836
+ `));
837
+ };
838
+
839
+ const PaymentFailed = ({
840
+ onClose
841
+ }) => {
842
+ const renderHeader = () => /*#__PURE__*/React.createElement("div", {
843
+ className: "popup-header"
844
+ }, /*#__PURE__*/React.createElement("div", {
845
+ className: "logo"
846
+ }, /*#__PURE__*/React.createElement("img", {
847
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
848
+ alt: "EVzone Logo",
849
+ className: "header-icon"
850
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
851
+ className: "evzone"
852
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
853
+ className: "pay"
854
+ }, " Pay")));
855
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
856
+ className: "popup-content"
857
+ }, renderHeader(), /*#__PURE__*/React.createElement("div", {
858
+ className: "error-content"
859
+ }, /*#__PURE__*/React.createElement(FaTimesCircle, {
860
+ className: "icon"
861
+ }), /*#__PURE__*/React.createElement("h3", null, "Payment Failed"), /*#__PURE__*/React.createElement("p", null, "Please check your wallet for details."), /*#__PURE__*/React.createElement("button", {
862
+ onClick: onClose,
863
+ className: "close-button"
864
+ }, "Details"))), /*#__PURE__*/React.createElement("style", null, `
865
+ .popup-content {
866
+ display: flex;
867
+ flex-direction: column;
868
+ align-items: center;
869
+ background: white;
870
+ border-radius: 10px;
871
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
872
+ max-width: 400px;
873
+ width: 90%;
874
+ text-align: center;
875
+ border: 1px solid #ddd;
876
+ font-family: Arial, sans-serif;
877
+ }
878
+
879
+ .popup-header {
880
+ display: flex;
881
+ align-items: center;
882
+ justify-content: center;
883
+ margin-bottom: 15px;
884
+ width: 100%;
885
+ padding: 10px 15px;
886
+ border-bottom: 1px solid #ddd;
887
+ }
888
+
889
+ .logo {
890
+ width: 40px;
891
+ height: 40px;
892
+ display: flex;
893
+ align-items: center;
894
+ justify-content: center;
895
+ margin-right: 10px;
896
+ border-radius: 50%;
897
+ overflow: hidden;
898
+ }
899
+
900
+ .header-icon {
901
+ width: 100%;
902
+ height: auto;
903
+ }
904
+
905
+ .popup-header h2 {
906
+ font-size: 1.2em;
907
+ color: #080808;
908
+ margin: 0;
909
+ font-weight: bold;
910
+ }
911
+
912
+ .popup-header .evzone {
913
+ color: #0a0a0a;
914
+ }
915
+
916
+ .popup-header .pay {
917
+ color: #0a0a0a;
918
+ }
919
+
920
+ .error-content {
921
+ display: flex;
922
+ flex-direction: column;
923
+ align-items: center;
924
+ padding: 20px;
925
+ background-color: #fff;
926
+ border-radius: 8px;
927
+ }
928
+
929
+ .error-content .icon {
930
+ color: #ff5a5f;
931
+ font-size: 40px;
932
+ margin-bottom: 10px;
933
+ }
934
+
935
+ .error-content h3 {
936
+ font-size: 1.2em;
937
+ margin: 0 0 15px;
938
+ color: #333;
939
+ font-weight: 500;
940
+ }
941
+
942
+ .error-content p {
943
+ font-size: 1em;
944
+ color: #666;
945
+ margin-bottom: 15px;
946
+ }
947
+
948
+ .close-button {
949
+ background-color: #0288d1;
950
+ color: #fff;
951
+ border: none;
952
+ border-radius: 5px;
953
+ padding: 10px 20px;
954
+ font-size: 1em;
955
+ font-weight: 500;
956
+ cursor: pointer;
957
+ transition: background-color 0.3s ease;
958
+ width: 100%;
959
+ max-width: 200px;
960
+ }
961
+
962
+ .close-button:hover {
963
+ background-color: #0277bd;
964
+ }
965
+ `));
966
+ };
967
+
968
+ const InsufficientFunds = ({
969
+ onClose
970
+ }) => {
971
+ const renderHeader = () => /*#__PURE__*/React.createElement("div", {
972
+ className: "popup-header"
973
+ }, /*#__PURE__*/React.createElement("div", {
974
+ className: "logo"
975
+ }, /*#__PURE__*/React.createElement("img", {
976
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
977
+ alt: "EVzone Logo",
978
+ className: "header-icon"
979
+ })), /*#__PURE__*/React.createElement("h2", null, /*#__PURE__*/React.createElement("span", {
980
+ className: "evzone"
981
+ }, "EVzone"), /*#__PURE__*/React.createElement("span", {
982
+ className: "pay"
983
+ }, " Pay")));
984
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
985
+ className: "popup-content"
986
+ }, renderHeader(), /*#__PURE__*/React.createElement("div", {
987
+ className: "error-content"
988
+ }, /*#__PURE__*/React.createElement(FaExclamationCircle, {
989
+ className: "icon"
990
+ }), /*#__PURE__*/React.createElement("h3", null, "Insufficient Funds"), /*#__PURE__*/React.createElement("p", null, "Please add funds to your wallet to proceed."), /*#__PURE__*/React.createElement("button", {
991
+ onClick: onClose,
992
+ className: "close-button"
993
+ }, "Close"))), /*#__PURE__*/React.createElement("style", null, `
994
+ .popup-content {
995
+ display: flex;
996
+ flex-direction: column;
997
+ align-items: center;
998
+ background: white;
999
+ border-radius: 10px;
1000
+ box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
1001
+ max-width: 400px;
1002
+ width: 90%;
1003
+ text-align: center;
1004
+ border: 1px solid #ddd;
1005
+ font-family: Arial, sans-serif;
1006
+ }
1007
+
1008
+ .popup-header {
1009
+ display: flex;
1010
+ align-items: center;
1011
+ justify-content: center;
1012
+ margin-bottom: 15px;
1013
+ width: 100%;
1014
+ padding: 10px 15px;
1015
+ border-bottom: 1px solid #ddd;
1016
+ }
1017
+
1018
+ .logo {
1019
+ width: 40px;
1020
+ height: 40px;
1021
+ display: flex;
1022
+ align-items: center;
1023
+ justify-content: center;
1024
+ margin-right: 10px;
1025
+ border-radius: 50%;
1026
+ overflow: hidden;
1027
+ }
1028
+
1029
+ .header-icon {
1030
+ width: 100%;
1031
+ height: auto;
1032
+ }
1033
+
1034
+ .popup-header h2 {
1035
+ font-size: 1.2em;
1036
+ color: #080808;
1037
+ margin: 0;
1038
+ font-weight: bold;
1039
+ }
1040
+
1041
+ .popup-header .evzone {
1042
+ color: #0a0a0a;
1043
+ }
1044
+
1045
+ .popup-header .pay {
1046
+ color: #0a0a0a;
1047
+ }
1048
+
1049
+ .error-content {
1050
+ display: flex;
1051
+ flex-direction: column;
1052
+ align-items: center;
1053
+ padding: 20px;
1054
+ background-color: #fff;
1055
+ border-radius: 8px;
1056
+ }
1057
+
1058
+ .error-content .icon {
1059
+ color: #ff9800;
1060
+ font-size: 40px;
1061
+ margin-bottom: 10px;
1062
+ }
1063
+
1064
+ .error-content h3 {
1065
+ font-size: 1.2em;
1066
+ margin: 0 0 15px;
1067
+ color: #333;
1068
+ font-weight: 500;
1069
+ }
1070
+
1071
+ .error-content p {
1072
+ font-size: 1em;
1073
+ color: #666;
1074
+ margin-bottom: 15px;
1075
+ }
1076
+
1077
+ .close-button {
1078
+ background-color: #0288d1;
1079
+ color: #fff;
1080
+ border: none;
1081
+ border-radius: 5px;
1082
+ padding: 10px 20px;
1083
+ font-size: 1em;
1084
+ font-weight: 500;
1085
+ cursor: pointer;
1086
+ transition: background-color 0.3s ease;
1087
+ width: 100%;
1088
+ max-width: 200px;
1089
+ }
1090
+
1091
+ .close-button:hover {
1092
+ background-color: #0277bd;
1093
+ }
1094
+ `));
1095
+ };
1096
+
1097
+ const LoadingOverlay = () => {
1098
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1099
+ className: "loading-overlay"
1100
+ }, /*#__PURE__*/React.createElement("div", {
1101
+ className: "loading-content"
1102
+ }, /*#__PURE__*/React.createElement("img", {
1103
+ src: "https://res.cloudinary.com/dlfa42ans/image/upload/v1741686201/logo_n7vrsf.jpg",
1104
+ alt: "EvZone Logo",
1105
+ className: "loading-logo"
1106
+ }), /*#__PURE__*/React.createElement("p", {
1107
+ className: "loading-text"
1108
+ }, /*#__PURE__*/React.createElement("span", {
1109
+ className: "evzone"
1110
+ }, "EVzone"), ' ', /*#__PURE__*/React.createElement("span", {
1111
+ className: "pay"
1112
+ }, "Pay")))), /*#__PURE__*/React.createElement("style", null, `
1113
+ .loading-overlay {
1114
+ position: fixed;
1115
+ top: 0;
1116
+ left: 0;
1117
+ width: 100%;
1118
+ height: 100%;
1119
+ background: rgba(0, 0, 0, 0.5);
1120
+ display: flex;
1121
+ justify-content: center;
1122
+ align-items: center;
1123
+ z-index: 9999;
1124
+ }
1125
+
1126
+ .loading-content {
1127
+ text-align: center;
1128
+ display: flex;
1129
+ flex-direction: column;
1130
+ justify-content: center;
1131
+ align-items: center;
1132
+ }
1133
+
1134
+ .loading-logo {
1135
+ width: 120px;
1136
+ height: 120px;
1137
+ margin-bottom: 20px;
1138
+ border-radius: 50%;
1139
+ overflow: hidden;
1140
+ }
1141
+
1142
+ .loading-text {
1143
+ font-size: 36px;
1144
+ font-weight: bold;
1145
+ margin: 0;
1146
+ animation: blink 1.5s step-start infinite;
1147
+ }
1148
+
1149
+ .loading-text .evzone {
1150
+ color: rgb(49, 141, 89);
1151
+ }
1152
+
1153
+ .loading-text .pay {
1154
+ color: rgb(218, 124, 36);
1155
+ }
1156
+
1157
+ @keyframes blink {
1158
+ 0% {
1159
+ opacity: 1;
1160
+ }
1161
+ 50% {
1162
+ opacity: 0;
1163
+ }
1164
+ 100% {
1165
+ opacity: 1;
1166
+ }
1167
+ }
1168
+ `));
1169
+ };
1170
+
1171
+ const SAMPLE_CUSTOMERS = {
1172
+ "customer123": {
1173
+ name: "John Doe",
1174
+ balance: 1000,
1175
+ passcode: "123456"
1176
+ },
1177
+ "customer456": {
1178
+ name: "Jane Smith",
1179
+ balance: 500,
1180
+ passcode: "567856"
1181
+ },
1182
+ "customer789": {
1183
+ name: "Alice Brown",
1184
+ balance: 50,
1185
+ passcode: "901256"
1186
+ }
1187
+ };
1188
+ const generateTransactionDetails = (amount, transactionId) => ({
1189
+ type: "Booking",
1190
+ id: transactionId,
1191
+ particulars: "Hotel Booking",
1192
+ billedCurrency: "UGX",
1193
+ billedAmount: amount,
1194
+ totalBilling: amount
1195
+ });
1196
+ const checkAccountExists = customerId => Promise.resolve(!!SAMPLE_CUSTOMERS[customerId]);
1197
+ const validatePasscode = (customerId, passcode, amount) => {
1198
+ const customer = SAMPLE_CUSTOMERS[customerId];
1199
+ if (!customer) return {
1200
+ success: false,
1201
+ reason: 'no_account'
1202
+ };
1203
+ if (customer.passcode !== passcode) return {
1204
+ success: false,
1205
+ reason: 'invalid_passcode'
1206
+ };
1207
+ if (customer.balance < amount) return {
1208
+ success: false,
1209
+ reason: 'insufficient_funds'
1210
+ };
1211
+ SAMPLE_CUSTOMERS[customerId].balance -= amount;
1212
+ return {
1213
+ success: true
1214
+ };
1215
+ };
1216
+ const WalletPaymentForm = ({
1217
+ customerId,
1218
+ amount,
1219
+ onClose,
1220
+ onSuccess
1221
+ }) => {
1222
+ const [popup, setPopup] = useState('transactionSummary');
1223
+ const [passcode, setPasscode] = useState('');
1224
+ const [hasAccount, setHasAccount] = useState(null);
1225
+ const [paymentStatus, setPaymentStatus] = useState('idle');
1226
+ const [showPasscode, setShowPasscode] = useState(false);
1227
+ const [transactionId] = useState(`W-${Math.floor(Math.random() * 1000000000)}`);
1228
+ const [loading, setLoading] = useState(true);
1229
+ useEffect(() => {
1230
+ console.log('useEffect running, customerId:', customerId, 'amount:', amount);
1231
+ const timer = setTimeout(() => {
1232
+ console.log('Loading finished');
1233
+ setLoading(false);
1234
+ }, 5000);
1235
+ const checkConditions = async () => {
1236
+ if (!customerId) {
1237
+ console.log('No customerId provided, setting hasAccount to false');
1238
+ setHasAccount(false);
1239
+ return;
1240
+ }
1241
+ if (!SAMPLE_CUSTOMERS[customerId]) {
1242
+ console.log(`Invalid customerId: ${customerId}, setting hasAccount to false`);
1243
+ setHasAccount(false);
1244
+ return;
1245
+ }
1246
+ const accountExists = await checkAccountExists(customerId);
1247
+ console.log('Account exists:', accountExists);
1248
+ setHasAccount(accountExists);
1249
+ };
1250
+ checkConditions();
1251
+ return () => clearTimeout(timer);
1252
+ }, [customerId, amount]);
1253
+ const handleConfirm = () => {
1254
+ console.log('Confirm clicked, hasAccount:', hasAccount);
1255
+ if (hasAccount === null) {
1256
+ console.log('hasAccount is null, cannot proceed');
1257
+ return;
1258
+ }
1259
+ if (hasAccount) {
1260
+ setPopup('enterPasscode');
1261
+ } else {
1262
+ console.log('No account, showing HasAccountSummary');
1263
+ setPopup('transactionSummary');
1264
+ }
1265
+ };
1266
+ const handleSubmit = async e => {
1267
+ e.preventDefault();
1268
+ console.log('Submitting passcode:', passcode);
1269
+ setPaymentStatus('pending');
1270
+ const result = await validatePasscode(customerId, passcode, amount);
1271
+ console.log('Validation result:', result);
1272
+ setPaymentStatus(result.success ? 'success' : 'failed');
1273
+ if (result.success) {
1274
+ setPopup('paymentSuccess');
1275
+ if (onSuccess) onSuccess();
1276
+ } else {
1277
+ if (result.reason === 'insufficient_funds') {
1278
+ setPopup('insufficientFunds');
1279
+ } else {
1280
+ setPopup('paymentFailed');
1281
+ }
1282
+ setTimeout(() => {
1283
+ setPopup('transactionSummary');
1284
+ setPasscode('');
1285
+ setPaymentStatus('idle');
1286
+ onClose();
1287
+ }, 5000);
1288
+ }
1289
+ };
1290
+ const handleSuccessClose = () => {
1291
+ console.log('Success close clicked');
1292
+ setPopup('transactionSummary');
1293
+ setPasscode('');
1294
+ setPaymentStatus('idle');
1295
+ onClose();
1296
+ };
1297
+ const transactionDetails = generateTransactionDetails(amount, transactionId);
1298
+ const renderPopup = () => {
1299
+ console.log('Rendering popup, current popup:', popup, 'hasAccount:', hasAccount);
1300
+ switch (popup) {
1301
+ case 'transactionSummary':
1302
+ if (!hasAccount) {
1303
+ return /*#__PURE__*/React.createElement(HasAccountSummary, {
1304
+ onClose: onClose
1305
+ });
1306
+ }
1307
+ return /*#__PURE__*/React.createElement(TransactionSummary, {
1308
+ transactionDetails: transactionDetails,
1309
+ onConfirm: handleConfirm
1310
+ });
1311
+ case 'enterPasscode':
1312
+ return /*#__PURE__*/React.createElement(EnterPasscode, {
1313
+ passcode: passcode,
1314
+ setPasscode: setPasscode,
1315
+ showPasscode: showPasscode,
1316
+ setShowPasscode: setShowPasscode,
1317
+ transactionDetails: transactionDetails,
1318
+ onSubmit: handleSubmit,
1319
+ onBack: () => setPopup('transactionSummary')
1320
+ });
1321
+ case 'paymentSuccess':
1322
+ return /*#__PURE__*/React.createElement(PaymentSuccess, {
1323
+ amount: amount,
1324
+ onClose: handleSuccessClose
1325
+ });
1326
+ case 'paymentFailed':
1327
+ return /*#__PURE__*/React.createElement(PaymentFailed, {
1328
+ onClose: onClose
1329
+ });
1330
+ case 'insufficientFunds':
1331
+ return /*#__PURE__*/React.createElement(InsufficientFunds, {
1332
+ onClose: onClose
1333
+ });
1334
+ default:
1335
+ return null;
1336
+ }
1337
+ };
1338
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1339
+ className: "wallet-payment-form"
1340
+ }, loading ? /*#__PURE__*/React.createElement(LoadingOverlay, null) : /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("div", {
1341
+ className: "overlay",
1342
+ onClick: () => {
1343
+ console.log('Overlay clicked, closing');
1344
+ onClose();
1345
+ }
1346
+ }), renderPopup())), /*#__PURE__*/React.createElement("style", null, `
1347
+ .wallet-payment-form {
1348
+ position: fixed;
1349
+ top: 0;
1350
+ left: 0;
1351
+ width: 100%;
1352
+ height: 100%;
1353
+ display: flex;
1354
+ justify-content: center;
1355
+ align-items: center;
1356
+ z-index: 1000;
1357
+ }
1358
+
1359
+ .overlay {
1360
+ position: absolute;
1361
+ top: 0;
1362
+ left: 0;
1363
+ width: 100%;
1364
+ height: 100%;
1365
+ background: rgba(0, 0, 0, 0.5);
1366
+ z-index: 999;
1367
+ pointer-events: auto;
1368
+ }
1369
+ `));
1370
+ };
1371
+
1372
+ export { WalletPaymentForm as default };