-
Notifications
You must be signed in to change notification settings - Fork 0
/
ussd.js
148 lines (122 loc) · 3.5 KB
/
ussd.js
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
// Bank USSD
let nameOne = "Clement Peterson";
let nameTwo = "Damilola Adejoke";
let nameThree = "Tobechukwu Okafor";
let option = prompt(`
1. Buy Airtime
2. Credit Third Party
3. Buy Data
4. Transfer`);
option = Number(option);
// Buy airtime
if (option == 1) {
var amount = prompt("Enter amount");
// let var const
amount = Number(amount);
var confirming = confirm("Are you sure?");
if (confirming == true) {
alert(`Your N${amount} has been confirmed!`);
}
else {
alert(`Reload Page`);
}
}
// Credit 3rd party
else if (option == 2) {
var number = prompt("Enter phone number");
number = Number(number);
var amount = prompt("Enter amount");
amount = Number(amount);
var confirming = confirm("Are you sure?");
if (confirming == true) {
alert(`Your N${amount} to ${number} has been confirmed!`);
}
else {
alert(`Reload Page`);
}
}
// Buy data
else if (option == 3) {
var amount = prompt("Enter amount of data in MB");
amount = Number(amount);
var confirming = confirm("Are you sure?");
if (confirming == true) {
alert(`Your ${amount}mb has been confirmed!`);
}
else {
alert(`Reload Page`);
}
}
// Transfer
else if (option == 4) {
let bankName = prompt(`Select receiver's bank:
1. GTBank
2. Access Bank
3. Fidelity Bank
4. Ecobank
5. Standard Chatered Bank
6. First Bank
0. More`);
bankName = Number(bankName);
if (bankName != 0 && bankName <= 6) {
let numb = prompt("Enter account number");
numb = Number(number);
let bankConf = prompt(`
Transfering to ${nameTwo}?
1. Confirm
2. Back
`);
bankConf = Number(bankConf);
if (bankConf == 1) {
let amount = prompt("Enter amount");
amount = Number(amount);
var confirming = confirm("Are you sure?");
if (confirming == true) {
alert(`Your N${amount} transfer to ${nameTwo} accont no. ${numb} has been confirmed!`);
}
else if (confirming == false) {
alert(`Reload Page`);
}
}
else if (bankConf === 2){
alert(`Reload Page`);
}
}
else if (bankName == 0) {
let bankNameTwo = prompt(`
7. Zenith Bank
8. UBA
0. Back
`);
bankNameTwo = Number(bankNameTwo);
if (bankNameTwo == 7 || bankNameTwo == 8) {
let numb = prompt("Enter account number:");
numb = Number(number);
var bankConf = prompt(`
Transfering to ${nameThree}?
1. Confirm
2. Back
`);
if (bankConf == 1) {
var amount = prompt("Enter amount:");
amount = Number(amount);
var confirming = confirm(`Are you sure you want to send N${numb} to ${nameThree}?`);
if (confirming == true) {
alert(`Your N${amount} tarnsfer to ${nameThree} account no. ${numb} has been confirmed!`);
}
else {
alert(`Reload Page`);
}
}
else if (bankConf == 2) {
alert(`Reload Page`);
}
}
else if (bankNameTwo == 0) {
alert(`Reload Page`)
}
}
else {
alert(`Invalid Input, reload page!`)
}
}