-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
1886 lines (1760 loc) · 77.8 KB
/
index.js
File metadata and controls
1886 lines (1760 loc) · 77.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
let modalStylesEle = document.createElement("style");
let modalStyles = `
.modal {
display: none;
position: fixed;
z-index: 9999;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
width: 100%;
border-radius: 8px;
position: relative;
max-width: 360px;
}
/* media queries */
@media screen and (max-width: 640px) {
.modal-content {
width: 90%;
}
.text-truncate {
width: 120px;
}
}
@media screen and (min-width: 768px) and (max-width: 1180px) {
.modal-content {
width: 50%;
}
.text-truncate {
width: 120px;
}
`;
function Pooler(merchantConfig) {
let overlay = "";
const woodcoreConfig = {
apiUrl: "https://api.swim.poolerapp.com/api/v1/",
apiRoute: "business/accounts/disposable",
dev: "checkout.swim.poolerapp.com",
live: "checkout.poolerapp.com",
local: "checkout.localhost:4000",
};
const config = {
display_name: "Idris Bankole",
email: "idris@woodcoreapp.com",
mobile_number: "08189960542",
metadata: {},
payment_link: true,
amount: 9000,
"x-key":
"skl_D+7m+90BNNcyV7SM0sb/iEdIaMfRUPUnzsKx0KiN7H9LNtT+m5NTZamT567TmYE0UzbhK7LwAN3xh47NMosZ8g==",
};
var styles = document.createElement("style");
var cssStyles = `
.spinner {
border: 16px solid #f3f3f3;
border-top: 16px solid #3498db;
border-radius: 50%;
width: 80px;
height: 80px;
animation: spin 0.5s linear infinite;
}
.spinner-small {
border: 6px solid #f3f3f3;
border-top: 6px solid #261bc1;
border-radius: 50%;
width: 40px;
height: 40px;
animation: spin 0.5s linear infinite;
}
.footer-text {
position: absolute;
top: 100%;
left: 35%;
}
@keyframes spin {
0% {
transform: rotate(0deg);
}
100% {
transform: rotate(360deg);
}
}
.spinner-centered {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.awaiting-container {
display: flex;
flex-direction: column;
border-radius: 0.5rem;
padding-top: 1.5rem;
padding-bottom: 1.5rem;
}
.transferToMerchant {
color: #000;
text-align: center;
font-weight: 500;
font-size: 1rem;
}
.modal {
display: block;
position: fixed;
z-index: 1;
padding-top: 100px;
left: 0;
top: 0;
width: 100%;
height: 100%;
overflow: auto;
background-color: rgb(0, 0, 0);
background-color: rgba(0, 0, 0, 0.4);
}
.modal-content {
background-color: #fefefe;
margin: auto;
width: 25%;
border-radius: 8px;
position: relative;
}
.modal-footer {
display: flex;
flex-direction: column;
width: 100%;
/* margin-top: 1rem; */
padding-top: 0.5rem;
padding-bottom: 1.5rem;
padding-left: 2rem;
padding-right: 2rem;
}
.modal-text-parent {
background-color: #e0e4f4;
border-top-left-radius: 8px;
border-top-right-radius: 8px;
border-bottom: 1px solid #e0e4f4;
padding: 20px;
}
.modal-header {
display: flex;
flex-direction: row;
align-items: center;
justify-content: space-between;
}
.modal-amt-email {
display: flex;
flex-direction: column;
margin-top: 0.25rem;
}
.modal-amt {
font-weight: 500;
color: #000;
text-align: end;
text-align: right;
font-size: 1.125rem;
}
.modal-em {
font-style: normal;
font-size: 1rem;
line-height: 1.25;
}
.modal-body {
display: flex;
flex-direction: column;
position: relative;
margin-left: auto;
margin-right: auto;
width: 91.6667%;
padding-left: 2rem;
padding-right: 2rem;
margin-top: 1.2rem;
}
.modal-amount-email {
display: flex;
flex-direction: column;
column-gap: 5px;
}
.modal-email {
color: #8f9bb2;
font-family: "GraphikRegular", "Source Sans Pro", sans-serif;
}
.close {
color: #000;
float: right;
margin-top: 0px;
position: absolute;
right: -5%;
top: 1%;
width: 10px;
height: 10px;
}
.close-img:hover {
background: red;
box-shadow: 0px 4px 25px rgba(0, 0, 0, 0.08),
4px 10px 25px rgba(0, 0, 0, 0.03);
border-radius: 13px;
width: 10px;
height: 10px;
transition: all 0.8s ease-in-out;
}
.close:hover,
.close:focus {
color: #000;
text-decoration: none;
cursor: pointer;
}
`;
styles.innerHTML = cssStyles;
overlay = document.createElement("div");
// COUNTDOWN SEQUENCE
// trigger overlay, and loader
function payWithPooler() {
overlay.style.position = "fixed";
overlay.style.top = "0";
overlay.style.left = "0";
overlay.style.width = "100%";
overlay.style.height = "100%";
overlay.style.backgroundColor = "rgba(0, 0, 0, 0.3)";
overlay.style.display = "flex";
overlay.style.flexDirection = "row";
overlay.style.justifyContent = "center";
overlay.style.alignItems = "center";
overlay.style.zIndex = "1";
var spinnerCssCode = `
<style>
.spinner-3 {
width: 30px;
aspect-ratio: 1;
display: grid;
border-radius: 50%;
background:
linear-gradient(0deg ,rgb(0 0 0/50%) 30%,#0000 0 70%,rgb(0 0 0/100%) 0) 50%/8% 100%,
linear-gradient(90deg,rgb(0 0 0/25%) 30%,#0000 0 70%,rgb(0 0 0/75% ) 0) 50%/100% 8%;
background-repeat: no-repeat;
animation: s3 1s infinite steps(12);
}
.spinner-3::before,
.spinner-3::after {
content: "";
grid-area: 1/1;
border-radius: 50%;
background: inherit;
opacity: 0.915;
transform: rotate(30deg);
}
.spinner-3::after {
opacity: 0.83;
transform: rotate(60deg);
}
@keyframes s3 {
100% {transform: rotate(1turn)}
}
</style>
`;
var spinnerContainer = document.createElement("div");
spinnerContainer.innerHTML = spinnerCssCode;
var spinner = document.createElement("div");
spinner.className = "spinner-3";
// Create the spinner divs
// for (var i = 0; i < 12; i++) {
// var div = document.createElement("div");
// spinner.appendChild(div);
// }
overlay.appendChild(spinnerContainer);
overlay.appendChild(spinner);
// create iframe
var iframe = document.createElement("iframe");
iframe.id = "pooler-iframe";
iframe.style.position = "fixed";
iframe.style.top = "0";
iframe.style.left = "0";
iframe.style.width = "100%";
iframe.style.height = "100%";
iframe.style.border = "none";
iframe.style.display = "flex";
iframe.style.flexDirection = "row";
iframe.style.justifyContent = "center";
iframe.style.alignItems = "center";
iframe.style.background = "transparent";
// document.body.appendChild(overlay);
// append overlay to iframe
iframe.addEventListener("load", () => {
var iframeWindow = iframe.contentWindow;
iframeWindow.document.body.appendChild(overlay);
setTimeout(function () {
overlay.style.backgroundColor = "transparent";
spinner.style.display = "none";
overlay.style.display = "none";
iframe.style.display = "none";
createDisposableAccount(merchantConfig, woodcoreConfig);
}, 3000);
});
document.body.appendChild(iframe);
// await createDisposableAccount(merchantConfig, woodcoreConfig);
// SET UP CONNECTION TO GENERATE DISPOSABLE ACCOUNT
}
// shows merchant details modal
function showMerchantModal(config) {
// const data = response?.data;
const data = config;
// create iframe for merchant details modal
var merchantIframe = document.createElement("iframe");
merchantIframe.id = "merchant-iframe";
merchantIframe.style.position = "fixed";
merchantIframe.style.top = "0";
merchantIframe.style.left = "0";
merchantIframe.style.width = "100%";
merchantIframe.style.height = "100%";
merchantIframe.style.border = "none";
merchantIframe.style.display = "flex";
var Merchantmodal = document.createElement("div");
Merchantmodal.setAttribute("id", "merchant-modal");
Merchantmodal.style.display = "block";
Merchantmodal.style.position = "fixed";
Merchantmodal.style.zIndex = "9999";
Merchantmodal.style.top = "0";
Merchantmodal.style.left = "0";
Merchantmodal.style.paddingTop = "100px";
Merchantmodal.style.width = "100%";
Merchantmodal.style.height = "100%";
Merchantmodal.style.overflow = "auto";
Merchantmodal.style.backgroundColor = "rgb(0, 0, 0, 0.3)";
var modalContent = document.createElement("div");
modalContent.setAttribute("id", "merchant-content");
modalContent.style.backgroundColor = "#fefefe";
modalContent.style.margin = "auto";
modalContent.style.width = "100%";
modalContent.style.borderRadius = "8px";
modalContent.style.position = "relative";
modalContent.style.maxWidth = "360px";
modalContent.style.boxShadow = "0 4px 15px 0 rgba(0,0,0,.2)";
var closeBtn = document.createElement("div");
closeBtn.innerHTML = `<svg width="10" height="10" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg" id="close-svg">
<path d="M11 1L1 11M1 1L11 11" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
// closeBtn.className = "close close-img";
closeBtn.style.color = "#000";
closeBtn.style.float = "right";
closeBtn.style.marginTop = "0px";
closeBtn.style.position = "absolute";
closeBtn.style.right = "-6.5%";
closeBtn.style.top = "1%";
closeBtn.style.width = "10px";
closeBtn.style.height = "10px";
closeBtn.style.cursor = "pointer";
// closeBtn.addEventListener("mouseover", function () {
// closeBtn.style.backgroundColor = "red";
// closeBtn.style.border = "1px solid red";
// closeBtn.style.borderRadius = "100%";
// });
// modal text parent
var modalTextParent = document.createElement("div");
// modalTextParent.className = "modal-text-parent";
modalTextParent.style.background = "#e0e4f4";
modalTextParent.style.borderTopLeftRadius = "8px";
modalTextParent.style.borderTopRightRadius = "8px";
modalTextParent.style.borderBottom = "1px solid #e0e4f4";
modalTextParent.style.padding = "20px";
modalContent.appendChild(modalTextParent);
// modal header
var modalText = document.createElement("div");
// modalText.className = "modal-header";
modalText.style.display = "flex";
modalText.style.flexDirection = "row";
modalText.style.alignItems = "center";
modalText.style.justifyContent = "space-between";
// pooler image icon
var poolerIcon = document.createElement("div");
// poolerIcon.src = "./Pooler DP 1.svg"
// poolerIcon.innerHTML = poolerLogo;
poolerIcon.innerHTML = `<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.383 12.1136L22.9586 10.5829C22.6293 10.4051 22.2876 10.2508 21.936 10.121C20.985 9.75941 19.9744 9.57471 18.9553 9.57618H9.65918L11.1286 26.7961H15.7526V25.9878H18.9553C20.0471 25.9878 21.1283 25.7753 22.137 25.3628C23.1457 24.9502 24.0622 24.3454 24.8341 23.5829C25.606 22.8205 26.2182 21.9154 26.6358 20.9193C27.0535 19.9232 27.2682 18.8556 27.2677 17.7776V17.742C27.251 16.0846 26.6098 14.4928 25.4684 13.2772L24.383 12.1136Z" fill="#52A1FF"/>
<path d="M25.166 15.594C25.1664 16.6723 24.9516 17.7401 24.5338 18.7364C24.116 19.7327 23.5035 20.638 22.7313 21.4004C21.9591 22.1629 21.0422 22.7676 20.0332 23.1801C19.0241 23.5926 17.9426 23.8047 16.8505 23.8043H13.6508V26.7888H7.56641V7.38673H16.8625C18.3194 7.38485 19.7511 7.76275 21.0127 8.4822L22.9649 10.5785L23.3098 10.9515C24.4908 12.2029 25.1551 13.8452 25.172 15.5555L25.166 15.594Z" fill="#1F7AFF"/>
<path d="M22.6592 13.4573C22.6599 15.633 21.7858 17.72 20.2287 19.2595C18.6717 20.7991 16.5592 21.6652 14.3556 21.6676H11.141V26.7897H5.05957V5.25H14.3556C15.6236 5.25052 16.8746 5.53795 18.0125 6.09023C19.1504 6.64248 20.145 7.44487 20.9199 8.4358C22.0484 9.87702 22.6601 11.6474 22.6592 13.4691V13.4573Z" fill="#2C1DFF"/>
</svg>
`;
poolerIcon.style.width = "32px";
poolerIcon.style.height = "32px";
modalText.appendChild(poolerIcon);
// amount and email address column
var modalAmountEmail = document.createElement("div");
// modalAmountEmail.className = "modal-amt-email";
modalAmountEmail.style.display = "flex";
modalAmountEmail.style.flexDirection = "column";
modalAmountEmail.style.marginTop = "0.25rem";
modalAmountEmail.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalAmountEmail.style.fontSize = "1rem";
modalText.appendChild(modalAmountEmail);
modalTextParent.appendChild(modalText);
// amount
var modalAmount = document.createElement("div");
// modalAmount.className = "modal-amount modal-amt";
modalAmount.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalAmount.style.fontWeight = "600";
modalAmount.style.color = "#000";
modalAmount.style.textAlign = "end";
modalAmount.style.textAlign = "right";
modalAmount.style.fontSize = "1.125rem";
modalAmount.style.paddingBottom = "8px";
modalAmount.textContent = `${data?.amount}`;
modalAmountEmail.appendChild(modalAmount);
// email
var modalEmail = document.createElement("div");
// modalEmail.className = "modal-email modal-em";
modalAmount.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalEmail.style.color = "#8f9bb2";
modalEmail.style.fontStyle = "normal";
modalEmail.style.fontSize = "1rem";
modalEmail.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalEmail.textContent = `${data?.email}`;
modalAmountEmail.appendChild(modalEmail);
// modal body
var modalBody = document.createElement("div");
modalBody.style.display = "flex";
modalBody.style.flexDirection = "column";
modalBody.style.position = "relative";
// make transfer to
var transferToHeader = document.createElement("div");
// transferToHeader.className = "transferToHeader";
transferToHeader.style.marginBottom = "1.5rem";
transferToHeader.style.marginTop = "35px";
var transferTo = document.createElement("div");
// transferTo.className = "transfer-to transferTo";
transferTo.textContent = "Make Transfer to";
transferTo.style.textAlign = "center";
transferTo.style.fontFamily = "GraphikRegular, sans-serif";
transferTo.style.color = "#8f9bb2";
transferTo.style.fontStyle = "normal";
transferTo.style.fontSize = "14px";
transferTo.style.paddingBottom = "15px";
var transferToMerchant = document.createElement("div");
// transferToMerchant.className = "transferToMerchant";
transferToMerchant.textContent = `${data.display_name}`;
transferToMerchant.style.textAlign = "center";
transferToMerchant.style.color = "#000";
transferToMerchant.style.fontStyle = "normal";
transferToMerchant.style.fontSize = "16px";
transferToMerchant.style.fontFamily = "GraphikRegular, sans-serif";
transferToHeader.appendChild(transferTo);
transferToHeader.appendChild(transferToMerchant);
modalBody.appendChild(transferToHeader);
// merchant details
var paymentDetails = document.createElement("ul");
// paymentDetails.className = "payment-details";
paymentDetails.style.listStyleType = "none";
paymentDetails.style.display = "flex";
paymentDetails.style.flexDirection = "column";
paymentDetails.style.width = "79%";
paymentDetails.style.marginBottom = "30px";
paymentDetails.style.position = "relative";
// paymentDetails.classList.add("payment-details");
// LIST 1
var li1 = document.createElement("li");
// li1.className = "payment-detail";
li1.style.display = "flex";
li1.style.flexDirection = "row";
li1.style.alignItems = "center";
li1.style.justifyContent = "space-between";
li1.style.borderBottom = "1px solid #e5e7eb";
li1.style.paddingTop = "0.9em";
li1.style.paddingBottom = "0.9em";
var merchant = document.createElement("span");
// merchant.className = "payment-detail-text modal-email";
merchant.textContent = "Merchant";
merchant.style.fontFamily = "GraphikRegular, sans-serif";
merchant.style.color = "#8f9bb2";
var merchatName = document.createElement("span");
// merchatName.className = "payment-detail-bold text-truncate";
merchatName.style.fontFamily = "GraphikMedium, sans-serif";
merchatName.style.fontWeight = "500";
merchatName.style.color = "#000";
merchatName.textContent = `${data.display_name}`;
merchatName.style.width = "200px";
merchatName.style.whiteSpace = "nowrap";
merchatName.style.overflow = "hidden";
merchatName.style.textAlign = "right";
merchatName.style.textOverflow = "ellipsis";
li1.appendChild(merchant);
li1.appendChild(merchatName);
// LIST 2
var li2 = document.createElement("li");
// li2.className = "payment-detail";
li2.style.display = "flex";
li2.style.flexDirection = "row";
li2.style.alignItems = "center";
li2.style.justifyContent = "space-between";
li2.style.borderBottom = "1px solid #e5e7eb";
li2.style.paddingTop = "0.9em";
li2.style.paddingBottom = "0.9em";
var accNum = document.createElement("span");
// accNum.className = "payment-detail-text modal-email";
accNum.textContent = "Account Number";
accNum.style.fontFamily = "GraphikRegular, sans-serif";
accNum.style.color = "#8f9bb2";
var accDetails = document.createElement("span");
// accDetails.className = "payment-detail-bold row-span";
// accDetails.textContent = `${data?.account_no} || 123456789`;
accDetails.textContent = `9977639255`;
accDetails.style.fontFamily = "GraphikMedium, sans-serif";
accDetails.style.fontWeight = "500";
accDetails.style.color = "#000";
accDetails.style.display = "flex";
accDetails.style.flexDirection = "row";
var copy = document.createElement("div");
copy.innerHTML = `<svg width="16" height="16" viewBox="0 0 22 22" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M4 14C3.06812 14 2.60218 14 2.23463 13.8478C1.74458 13.6448 1.35523 13.2554 1.15224 12.7654C1 12.3978 1 11.9319 1 11V4.2C1 3.0799 1 2.51984 1.21799 2.09202C1.40973 1.71569 1.71569 1.40973 2.09202 1.21799C2.51984 1 3.0799 1 4.2 1H11C11.9319 1 12.3978 1 12.7654 1.15224C13.2554 1.35523 13.6448 1.74458 13.8478 2.23463C14 2.60218 14 3.06812 14 4M11.2 21H17.8C18.9201 21 19.4802 21 19.908 20.782C20.2843 20.5903 20.5903 20.2843 20.782 19.908C21 19.4802 21 18.9201 21 17.8V11.2C21 10.0799 21 9.51984 20.782 9.09202C20.5903 8.7157 20.2843 8.40973 19.908 8.21799C19.4802 8 18.9201 8 17.8 8H11.2C10.0799 8 9.51984 8 9.09202 8.21799C8.7157 8.40973 8.40973 8.7157 8.21799 9.09202C8 9.51984 8 10.0799 8 11.2V17.8C8 18.9201 8 19.4802 8.21799 19.908C8.40973 20.2843 8.7157 20.5903 9.09202 20.782C9.51984 21 10.0799 21 11.2 21Z" stroke="#CBD1EC" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
copy.style.width = "20px";
copy.style.height = "20px";
copy.style.position = "absolute";
copy.style.left = "102%";
copy.style.cursor = "pointer";
copy.style.top = "8%";
copy.src = "./Icon.svg";
copy.addEventListener("click", () => {
// navigator.clipboard.writeText(`${data?.account_no}`);
navigator.clipboard.writeText(`9977639255`);
});
accDetails.appendChild(copy);
li2.appendChild(accNum);
li2.appendChild(accDetails);
// LIST 3
var li3 = document.createElement("li");
// li3.className = "payment-detail";
li3.style.display = "flex";
li3.style.flexDirection = "row";
li3.style.alignItems = "center";
li3.style.justifyContent = "space-between";
li3.style.borderBottom = "1px solid #e5e7eb";
li3.style.paddingTop = "0.9em";
li3.style.paddingBottom = "0.9em";
li3.style.borderBottom = "0px";
var bank = document.createElement("span");
// bank.className = "payment-detail-text modal-email";
bank.textContent = "Bank Name";
bank.style.fontFamily = "GraphikRegular, sans-serif";
bank.style.color = "#8f9bb2";
var bankDetails = document.createElement("span");
// bankDetails.className = "payment-detail-bold text-truncate";
bankDetails.textContent = "Kredi Money MFB";
bankDetails.style.width = "125px";
bankDetails.style.whiteSpace = "nowrap";
bankDetails.style.overflow = "hidden";
bankDetails.style.textOverflow = "ellipsis";
bankDetails.style.fontFamily = "GraphikMedium, sans-serif";
bankDetails.style.fontWeight = "500";
bankDetails.style.textAlign = "right";
bankDetails.style.color = "#000";
li3.appendChild(bank);
li3.appendChild(bankDetails);
// UL MAKE UP
// paymentDetails.appendChild(li1);
paymentDetails.appendChild(li2);
paymentDetails.appendChild(li3);
modalBody.appendChild(paymentDetails);
// button and countdwon timer
var modalFooter = document.createElement("div");
// modalFooter.className = "modal-footer";
modalFooter.style.display = "flex";
modalFooter.style.flexDirection = "column";
modalFooter.style.width = "100%";
modalFooter.style.paddingTop = "0.5rem";
modalFooter.style.paddingBottom = "1.5rem";
// modalFooter.style.paddingLeft = "2rem";
// modalFooter.style.paddingRight = "2rem";
var paybutton = document.createElement("button");
// paybutton.className = "modal-btn";
paybutton.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
paybutton.style.background = "#2C1DFF";
paybutton.style.borderRadius = "8px";
paybutton.style.textAlign = "center";
paybutton.style.color = "#fff";
paybutton.style.fontWeight = "500";
paybutton.style.width = "85%";
paybutton.style.height = "2.75rem";
paybutton.style.fontSize = "1.125rem";
paybutton.style.margin = "0 auto";
paybutton.style.border = "0px";
paybutton.style.cursor = "pointer";
paybutton.textContent = "I have sent the money";
paybutton.style.zIndex = "999";
paybutton.setAttribute("type", "button");
modalFooter.appendChild(paybutton);
// count down timer
var timerText = document.createElement("span");
// timerText.className = "title modal-email timer-text";
timerText.style.paddingTop = "20px";
timerText.style.textAlign = "center";
timerText.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
timerText.textContent = `Expires in 30:0`;
// countdown time
var duration = 1799;
var countdown = "";
var text = "";
var timer = setInterval(function () {
var minutes = Math.floor(duration / 60);
var seconds = duration % 60;
countdown = minutes + ":" + seconds;
if (duration <= 0) {
showSessionExpirationModal(data);
clearInterval(timer);
Merchantmodal.style.display = "none";
overlay.style.display = "none";
document.body.removeChild(Merchantmodal);
Merchantmodal.parentNode.removeChild(Merchantmodal);
clearInterval(timer);
var childNodes = document.body.childNodes;
var desiredChild = null;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].id === "merchant-modal") {
desiredChild = childNodes[i];
break;
}
}
if (desiredChild) {
var parent = desiredChild.parentNode;
parent.removeChild(desiredChild);
console.log("yeah");
}
}
duration--;
timerText.textContent = `Expires in ${
countdown !== undefined ? countdown : ""
}`;
}, 1000);
// timerText.textContent = text;
modalFooter.appendChild(timerText);
// secure by pooler
var secureTextContainer = document.createElement("div");
// secureTextContainer.className = "absolute footer-text";
secureTextContainer.style.position = "absolute";
secureTextContainer.style.top = "100%";
secureTextContainer.style.left = "27%";
secureTextContainer.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
var htmlContent = document.createElement("div");
htmlContent.style.display = "flex";
htmlContent.style.flexDirection = "row";
htmlContent.style.paddingTop = "8px";
htmlContent.style.color = "white";
htmlContent.style.alignItems = "center";
var htmlContent = `<div style="color: #fff; display: flex; flex: row; padding-top:8px; align-items: center;"><svg xmlns="http://www.w3.org/2000/svg" class="icon icon-tabler icon-tabler-lock" width="16" height="16" viewBox="0 0 24 24" stroke-width="1.5" stroke="#fff" fill="none" stroke-linecap="round" stroke-linejoin="round" style="width: 20px; height: 20px">
<path stroke="none" d="M0 0h24v24H0z" fill="none"/>
<path d="M5 13a2 2 0 0 1 2 -2h10a2 2 0 0 1 2 2v6a2 2 0 0 1 -2 2h-10a2 2 0 0 1 -2 -2v-6z" />
<path d="M11 16a1 1 0 1 0 2 0a1 1 0 0 0 -2 0" />
<path d="M8 11v-4a4 4 0 1 1 8 0v4" />
</svg> <span>Secured by Pooler</span></div>`;
secureTextContainer.innerHTML = htmlContent;
modalContent.appendChild(secureTextContainer);
// modalFooter.appendChild(secureTextContainer);
// MODAL BUILD UP
modalContent.appendChild(closeBtn);
modalContent.appendChild(modalBody);
modalContent.appendChild(modalFooter);
Merchantmodal.appendChild(modalContent);
// overlay.appendChild(modal);
merchantIframe.addEventListener("load", () => {
var iframeWindow = merchantIframe.contentWindow;
iframeWindow.document.body.appendChild(Merchantmodal);
});
document.body.appendChild(merchantIframe); // Append modal to the document body
closeBtn.addEventListener("click", function () {
merchantIframe.parentNode.removeChild(merchantIframe);
merchantIframe.style.display = "none";
var childNodes = document.body.childNodes;
var desiredChild = null;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].id === "merchant-iframe") {
desiredChild = childNodes[i];
break;
}
}
if (desiredChild) {
var parent = desiredChild.parentNode;
parent.removeChild(desiredChild);
}
});
paybutton.addEventListener("click", function () {
showAwaitingModal(data);
clearInterval(timer);
merchantIframe.parentNode.removeChild(merchantIframe);
merchantIframe.style.display = "none";
var childNodes = document.body.childNodes;
var desiredChild = null;
for (var i = 0; i < childNodes.length; i++) {
if (childNodes[i].id === "merchant-iframe") {
desiredChild = childNodes[i];
break;
}
}
if (desiredChild) {
var parent = desiredChild.parentNode;
parent.removeChild(desiredChild);
}
});
}
// show awaiting payment while socket is opened
function showAwaitingModal(data) {
// spin up an iframe for awaiting modal
var awaitingIframe = document.createElement("iframe");
awaitingIframe.id = "awaiting-iframe";
awaitingIframe.style.position = "fixed";
awaitingIframe.style.top = "0";
awaitingIframe.style.left = "0";
awaitingIframe.style.width = "100%";
awaitingIframe.style.height = "100%";
awaitingIframe.style.border = "none";
awaitingIframe.style.display = "flex";
var Awaitingmodal = document.createElement("div");
Awaitingmodal.setAttribute("id", "awaiting-modal");
Awaitingmodal.style.display = "block";
Awaitingmodal.style.position = "fixed";
Awaitingmodal.style.zIndex = "9999";
Awaitingmodal.style.top = "0";
Awaitingmodal.style.left = "0";
Awaitingmodal.style.paddingTop = "100px";
Awaitingmodal.style.width = "100%";
Awaitingmodal.style.height = "100%";
Awaitingmodal.style.overflow = "auto";
Awaitingmodal.style.backgroundColor = "rgb(0, 0, 0, 0.5)";
// modal.className = "modal";
var modalContent = document.createElement("div");
// modalContent.className = "modal-content";
modalContent.style.backgroundColor = "#fefefe";
modalContent.style.margin = "auto";
modalContent.style.width = "100%";
modalContent.style.borderRadius = "8px";
modalContent.style.position = "relative";
modalContent.style.maxWidth = "360px";
modalContent.style.boxShadow = "0 4px 15px 0 rgba(0,0,0,.2)";
var closeBtn = document.createElement("div");
closeBtn.innerHTML = `<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M11 1L1 11M1 1L11 11" stroke="#fff" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/>
</svg>
`;
// closeBtn.className = "close close-img";
closeBtn.style.color = "#000";
closeBtn.style.float = "right";
closeBtn.style.marginTop = "0px";
closeBtn.style.position = "absolute";
closeBtn.style.right = "-6.5%";
closeBtn.style.top = "1%";
closeBtn.style.width = "10px";
closeBtn.style.height = "10px";
closeBtn.style.cursor = "pointer";
// modal text parent
var modalTextParent = document.createElement("div");
// modalTextParent.className = "modal-text-parent";
modalTextParent.style.background = "#e0e4f4";
modalTextParent.style.borderTopLeftRadius = "8px";
modalTextParent.style.borderTopRightRadius = "8px";
modalTextParent.style.borderBottom = "1px solid #e0e4f4";
modalTextParent.style.padding = "20px";
modalContent.appendChild(modalTextParent);
// modal header
var modalText = document.createElement("div");
modalText.style.display = "flex";
modalText.style.flexDirection = "row";
modalText.style.alignItems = "center";
modalText.style.justifyContent = "space-between";
// pooler image icon
var poolerIcon = document.createElement("div");
// poolerIcon.innerHTML = poolerLogo;
poolerIcon.innerHTML = `<svg width="33" height="32" viewBox="0 0 33 32" fill="none" xmlns="http://www.w3.org/2000/svg">
<path d="M24.383 12.1136L22.9586 10.5829C22.6293 10.4051 22.2876 10.2508 21.936 10.121C20.985 9.75941 19.9744 9.57471 18.9553 9.57618H9.65918L11.1286 26.7961H15.7526V25.9878H18.9553C20.0471 25.9878 21.1283 25.7753 22.137 25.3628C23.1457 24.9502 24.0622 24.3454 24.8341 23.5829C25.606 22.8205 26.2182 21.9154 26.6358 20.9193C27.0535 19.9232 27.2682 18.8556 27.2677 17.7776V17.742C27.251 16.0846 26.6098 14.4928 25.4684 13.2772L24.383 12.1136Z" fill="#52A1FF"/>
<path d="M25.166 15.594C25.1664 16.6723 24.9516 17.7401 24.5338 18.7364C24.116 19.7327 23.5035 20.638 22.7313 21.4004C21.9591 22.1629 21.0422 22.7676 20.0332 23.1801C19.0241 23.5926 17.9426 23.8047 16.8505 23.8043H13.6508V26.7888H7.56641V7.38673H16.8625C18.3194 7.38485 19.7511 7.76275 21.0127 8.4822L22.9649 10.5785L23.3098 10.9515C24.4908 12.2029 25.1551 13.8452 25.172 15.5555L25.166 15.594Z" fill="#1F7AFF"/>
<path d="M22.6592 13.4573C22.6599 15.633 21.7858 17.72 20.2287 19.2595C18.6717 20.7991 16.5592 21.6652 14.3556 21.6676H11.141V26.7897H5.05957V5.25H14.3556C15.6236 5.25052 16.8746 5.53795 18.0125 6.09023C19.1504 6.64248 20.145 7.44487 20.9199 8.4358C22.0484 9.87702 22.6601 11.6474 22.6592 13.4691V13.4573Z" fill="#2C1DFF"/>
</svg>
`;
poolerIcon.style.width = "32px";
poolerIcon.style.height = "32px";
modalText.appendChild(poolerIcon);
// amount and email address column
var modalAmountEmail = document.createElement("div");
// modalAmountEmail.className = "modal-amt-email";
modalAmountEmail.style.display = "flex";
modalAmountEmail.style.flexDirection = "column";
modalAmountEmail.style.marginTop = "0.25rem";
modalAmountEmail.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalAmountEmail.style.fontSize = "1rem";
modalText.appendChild(modalAmountEmail);
modalTextParent.appendChild(modalText);
// amount
var modalAmount = document.createElement("div");
// modalAmount.className = "modal-amount modal-amt";
modalAmount.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalAmount.style.fontWeight = "600";
modalAmount.style.color = "#000";
modalAmount.style.textAlign = "end";
modalAmount.style.textAlign = "right";
modalAmount.style.fontSize = "1.125rem";
modalAmount.style.paddingBottom = "8px";
modalAmount.textContent = `${data?.amount}`;
modalAmountEmail.appendChild(modalAmount);
// email
var modalEmail = document.createElement("div");
// modalEmail.className = "modal-email modal-em";
modalEmail.style.fontFamily =
'"GraphikMedium", "Source Sans Pro", sans-serif';
modalEmail.style.color = "#8f9bb2";
modalEmail.style.fontStyle = "normal";
modalEmail.style.fontSize = "1rem";
modalEmail.textContent = `${data?.email}`;
modalAmountEmail.appendChild(modalEmail);
// modal body
var modalBody = document.createElement("div");
// modalBody.className = "modal-body";
modalBody.style.display = "flex";
modalBody.style.flexDirection = "column";
modalBody.style.position = "relative";
modalBody.style.justifyContent = "center";
// merchant details
var paymentDetails = document.createElement("ul");
// paymentDetails.className = "payment-details";
paymentDetails.style.listStyleType = "none";
paymentDetails.style.display = "flex";
paymentDetails.style.flexDirection = "column";
paymentDetails.style.width = "79%";
paymentDetails.style.marginBottom = "30px";
paymentDetails.style.position = "relative";
paymentDetails.style.marginTop = "30px";
// AWAITING REQUEST LOADER
var awaitingContainer = document.createElement("div");
awaitingContainer.style.background = "#F5F6FB";
awaitingContainer.style.display = "flex";
awaitingContainer.style.flexDirection = "column";
awaitingContainer.style.borderRadius = "0.5rem";
awaitingContainer.style.margin = "auto";
awaitingContainer.style.width = "85%";
awaitingContainer.style.paddingTop = "1.5rem";
awaitingContainer.style.paddingBottom = "1.5rem";
awaitingContainer.style.justifyContent = "center";
awaitingContainer.style.marginTop = "25px";
modalBody.appendChild(awaitingContainer);
// loader
var loader = document.createElement("div");
loader.className = "spinner-5 spinner-centered";
// loader.style.border = "6px solid #f3f3f3";
// loader.style.borderTop = "6px solid #261bc1";
// loader.style.borderRadius = "50%";
// loader.style.width = "40px";
// loader.style.height = "40px";
// loader.style.animation = "spin 0.5s linear infinite";
// loader.style.textAlign = "center";
// loader.style.margin = "auto";
var style = document.createElement("style");
style.innerHTML = `
.spinner-centered {
text-align: center;
margin-left: auto;
margin-right: auto;
}
.spinner-5 {
width: 50px;
aspect-ratio: 1;
display: grid;
border:4px solid #0000;
border-radius: 50%;
border-right-color: #2C1DFF;
animation: s5 0.8s infinite linear;
}
.spinner-5::before,
.spinner-5::after {
content: "";
grid-area: 1/1;
margin: 2px;
border: inherit;
border-radius: 50%;
animation: s5 1.6s infinite;
}
.spinner-5::after {
margin: 8px;
animation-duration: 3s;
}
@keyframes s5{
100%{transform: rotate(1turn)}
}
`;
document.head.appendChild(style);
// loader.classList.add("spinner-small");
// loader.classList.add("spinner-centered");
awaitingContainer.appendChild(loader);
// awaiting confirmation
var awaitingConfirmation = document.createElement("div");
awaitingConfirmation.textContent = "Awaiting confirmation";
awaitingConfirmation.style.paddingTop = "10px";
awaitingConfirmation.style.fontFamily = "GraphikRegular, sans-serif";
awaitingConfirmation.style.textAlign = "center";
awaitingConfirmation.style.fontSize = "16px";
awaitingConfirmation.style.paddingTop = "20px";
// awaitingConfirmation.className = "transferToMerchant modal-amount";
awaitingContainer.appendChild(awaitingConfirmation);
// awaiting confirmation message
var awaitingMessage = document.createElement("div");
// awaitingMessage.className = "awaiting-message modal-email";
awaitingMessage.style.fontFamily = "GraphikRegular, sans-serif";
awaitingMessage.style.margin = "auto";
awaitingMessage.style.width = "80%";
awaitingMessage.style.fontSize = "14px";
awaitingMessage.style.textAlign = "center";
awaitingMessage.style.paddingTop = "20px";
awaitingMessage.style.color = "#8f9bb2";
awaitingMessage.textContent =
"We are confirming your transaction. This will take a few minutes.";
awaitingContainer.appendChild(awaitingMessage);
// LIST 1
var li1 = document.createElement("li");
li1.className = "payment-detail";
li1.style.display = "flex";
li1.style.flexDirection = "row";
li1.style.alignItems = "center";
li1.style.justifyContent = "space-between";
li1.style.borderBottom = "1px solid #e5e7eb";
li1.style.paddingTop = "0.9em";
li1.style.paddingBottom = "0.9em";
var merchant = document.createElement("span");
merchant.className = "payment-detail-text modal-email";
merchant.textContent = "Merchant";