forked from JaniKibichi/ussdSessions
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ussd.php
57 lines (40 loc) · 1.52 KB
/
ussd.php
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
<?php
// Reads the variables sent via POST from our gateway
$sessionId = $_POST["sessionId"];
$serviceCode = $_POST["serviceCode"];
$phoneNumber = $_POST["phoneNumber"];
$text = $_POST["text"];
if ( $text == "" ) {
// This is the first request. Note how we start the response with CON
$response = "CON What would you want to check \n";
$response .= "1. My Account \n";
$response .= "2. My phone number";
}
else if ( $text == "1" ) {
// Business logic for first level response
$response = "CON Choose account information you want to view \n";
$response .= "1. Account number \n";
$response .= "2. Account balance";
}
else if($text == "2") {
// Business logic for first level response
// This is a terminal request. Note how we start the response with END
$response = "END Your phone number is $phoneNumber";
}
else if($text == "1*1") {
// This is a second level response where the user selected 1 in the first instance
$accountNumber = "ACC1001";
// This is a terminal request. Note how we start the response with END
$response = "END Your account number is $accountNumber";
}
else if ( $text == "1*2" ) {
// This is a second level response where the user selected 1 in the first instance
$balance = "KES 10,000";
// This is a terminal request. Note how we start the response with END
$response = "END Your balance is $balance";
}
// Print the response onto the page so that our gateway can read it
header('Content-type: text/plain');
echo $response;
// DONE!!!
?>