-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcass.php
51 lines (38 loc) · 1.37 KB
/
cass.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
<?php
//Shehan Bhavan - hSenid Mobile Solutions
//shehanb@hsenidmobile.com
//Dialog Ideamart
require 'alllibs.php';
$APP_ID = "APP_000001";
$PASSWORD = "password";
$EXTERNAL_TRX_ID="123";
$production = false;
if ($production == false) {
$CASS_SERVER_URL = "http://localhost:7000/caas/direct/debit";
$SMS_SERVER_URL = "http://localhost:7000/sms/send";
} else {
$CASS_SERVER_URL = 'https://api.dialog.lk/caas/direct/debit';
$SMS_SERVER_URL = "https://api.dialog.lk/sms/send";
}
$logger = new Logger();
try {
$receiver = new SMSReceiver();
$message = $receiver->getMessage(); // Get the message sent to the app
$address = $receiver->getAddress(); // Get the phone no from which the message was sent
list($keyword, $amount) = explode(" ", $message);
// Setting up CAAS
$cass = new DirectDebitSender($CASS_SERVER_URL, $APP_ID, $PASSWORD);
$sender = new SmsSender($SMS_SERVER_URL, $APP_ID, $PASSWORD);
try {
if (isset($amount)) {
$cass->cass($EXTERNAL_TRX_ID, $address, $amount);
$sender->sms("Thank you for your generosity, You Have made a donation for ".$amount." Rupees", $address);
}
} catch (CassException $ex) {
$logger->WriteLog($ex);
$sender->sms("You do not have sufficient credit to make this donation", $address);
}
} catch (Exception $e) {
$logger->WriteLog($e);
}
?>