-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotification.php
More file actions
59 lines (49 loc) · 1.73 KB
/
notification.php
File metadata and controls
59 lines (49 loc) · 1.73 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
<?php
/**
* Express Pay Notification
*
* @package paygw_expresspay
* @copyright LLC TriIncom <info@express-pay.by>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
// @codingStandardsIgnoreLine
require_once('./../../../config.php');
//require_once($CFG->dirroot . '/payment/gateway/mollie/thirdparty/Mollie/vendor/autoload.php');
use paygw_expresspay\expresspay_helper;
use core_payment\helper;
$params = [
'data' => required_param('Data', PARAM_RAW),
'signature' => optional_param('Signature', null, PARAM_TEXT)
];
$context = context_system::instance();
$PAGE->set_context($context);
$PAGE->set_url('/payment/gateway/expresspay/notification.php');
$PAGE->set_pagelayout('admin');
$pagetitle = 'EXPRESSPAY NOTIFICATION';
$PAGE->set_title($pagetitle);
$PAGE->set_heading($pagetitle);
// Instant, we want this AS QUICK as we can.
try {
$notifObj = json_decode($params['data']);
if ($notifObj->CmdType == 1){
header("HTTP/1.1 200 OK");
exit(1);
}
// Callback is provided with internal record ID to match OUR record.
$transactionrecord = $DB->get_record('paygw_expresspay', [
'id' => $notifObj->AccountNo,
'invoiceid' => $notifObj->InvoiceNo
], '*', MUST_EXIST);
// And sycnhronize status.
$config = (object) helper::get_gateway_configuration($transactionrecord->component,
$transactionrecord->paymentarea,
$transactionrecord->itemid, 'expresspay');
$expresspay_helper = new expresspay_helper($config);
$expresspay_helper->notify($params['data'], $params['signature'], $transactionrecord);
header("HTTP/1.1 200 OK");
} catch (\Exception $e) {
// NON HTTP-200.
header("HTTP/1.1 403 Forbiden");
echo $e->getMessage();
}
exit;