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