-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathussdBank.php
More file actions
183 lines (160 loc) · 3.85 KB
/
ussdBank.php
File metadata and controls
183 lines (160 loc) · 3.85 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
<?php
require_once('lib/nusoap.php');
$cell_number = $_GET['MSISDN'];
$session_id = $_GET['SESSION_ID'];
$service_code = $_GET['SERVICE_CODE'];
$ussd_string = $_GET['USSD_STRING'];
//set default level to zero
$level = 0;
$ussd_string = str_replace("#","*",$ussd_string);
$ussd_string_exploded = explode("*",$ussd_string);
$ussd_string_exploded2 = array_shift($ussd_string_exploded);
//get level id from ussd_string reply
$level = count($ussd_string_exploded);
$phone = $cell_number;
if($level == 0)
{
display_menu();
}
if($level > 0)
{
switch($ussd_string_exploded[0])
{
case 1:
balanceEnquiry($ussd_string_exploded,$phone);
break;
case 2:
viewStatement($ussd_string_exploded,$phone);
break;
case 3:
Transfer($ussd_string_exploded,$phone);
break;
case 4:
Withdraw($ussd_string_exploded,$phone);
break;
case 5:
Deposit($ussd_string_exploded,$phone);
break;
}
}
function display_menu()
{
$ussd_text = "1. balanceEnquiry \n2. viewStatement \n3. Transfer \n4. Withdraw \n5. Deposit";
ussd_proceed($ussd_text);
}
function balanceEnquiry($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter your pin:";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$param = array('pin'=>$details[1],'phone'=>$phone);
$client = new nusoap_client('http://localhost/soaptest/serverBank.php');
$response = $client->call('balanceEnquiry', $param);
ussd_stop($response);
}
}
function viewStatement($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter your pin number:";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$param = array('pin'=>$details[1],'phone'=>$phone);
$client = new nusoap_client('http://localhost/soaptest/serverBank.php');
$response = $client->call('viewStatements', $param);
ussd_stop($response);
}
}
function Transfer($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter pin Number:";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$ussd_text = "Please enter the account number of he receipient";
ussd_proceed($ussd_text);
}
if(count($details) == 3)
{
$ussd_text = "Please enter the amount to transfer";
ussd_proceed($ussd_text);
}
if(count($details) == 4)
{
$param = array('pin'=>$details[1],'phone'=>$phone,'accNo'=>$details[2],'Amt'=>$details[3]);
$client = new nusoap_client('http://localhost/soaptest/serverBank.php');
$response = $client->call('Transfer', $param);
ussd_stop($response);
}
}
function Withdraw($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter your pin number:";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$ussd_text = " enter the your account Number";
ussd_proceed($ussd_text);
}
if(count($details) == 3)
{
$ussd_text = "Please enter the amount to withdraw";
ussd_proceed($ussd_text);
}
if(count($details) == 4)
{
$param = array('pin'=>$details[1],'phone'=>$phone,'accNo'=>$details[2],'Amt'=>$details[3]);
$client = new nusoap_client('http://localhost/soaptest/serverBank.php');
$response = $client->call('Withdraw', $param);
ussd_stop($response);
}
}
function Deposit($details,$phone)
{
if(count($details) == 1)
{
$ussd_text = "Please enter your pin number:";
ussd_proceed($ussd_text);
}
if(count($details) == 2)
{
$ussd_text = " enter the your account Number";
ussd_proceed($ussd_text);
}
if(count($details) == 3)
{
$ussd_text = "Please enter the amount to Deposit";
ussd_proceed($ussd_text);
}
if(count($details) == 4)
{
$param = array('pin'=>$details[1],'phone'=>$phone,'accNo'=>$details[2],'Amt'=>$details[3]);
$client = new nusoap_client('http://localhost/soaptest/serverBank.php');
$response = $client->call('Deposit', $param);
ussd_stop($response);
}
}
function ussd_proceed($ussd_text)
{
echo "CON $ussd_text";
exit(0);
}
function ussd_stop($ussd_text)
{
echo "END $ussd_text";
exit(0);
}
?>