-
Notifications
You must be signed in to change notification settings - Fork 1
/
plisio_callback.php
63 lines (54 loc) · 1.68 KB
/
plisio_callback.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
58
59
60
61
62
63
<?php
require('includes/application_top.php');
function verifyCallbackData($post, $apiKey)
{
if (!isset($post['verify_hash'])) {
return false;
}
$verifyHash = $post['verify_hash'];
unset($post['verify_hash']);
ksort($post);
if (isset($post['expire_utc'])){
$post['expire_utc'] = (string)$post['expire_utc'];
}
if (isset($post['tx_urls'])){
$post['tx_urls'] = html_entity_decode($post['tx_urls']);
}
$postString = serialize($post);
$checkKey = hash_hmac('sha1', $postString, $apiKey);
if ($checkKey != $verifyHash) {
return false;
}
return true;
}
global $db;
if (verifyCallbackData($_POST, MODULE_PAYMENT_PLISIO_API_KEY)) {
$order_id = $_REQUEST['order_number'];
$order = $db->Execute("select orders_id from " . TABLE_ORDERS . " where orders_id = '" . intval($order_id) . "' limit 1");
if ($order->RecordCount() <= 0) {
throw new Exception('Order #' . $order_id . ' does not exists');
}
switch ($_REQUEST['status']) {
case 'completed':
case 'mismatch':
$pl_order_status = MODULE_PAYMENT_PLISIO_PAID_STATUS_ID;
break;
case 'cancelled':
$pl_order_status = MODULE_PAYMENT_PLISIO_CANCELLED_STATUS_ID;
break;
case 'expired':
$pl_order_status = MODULE_PAYMENT_PLISIO_EXPIRED_STATUS_ID;
break;
case 'new':
$pl_order_status = MODULE_PAYMENT_PLISIO_PENDING_STATUS_ID;
break;
default:
$pl_order_status = NULL;
}
if ($pl_order_status) {
$db->Execute("update " . TABLE_ORDERS . " set orders_status = " . $pl_order_status . " where orders_id = " . intval($order_id));
}
echo 'OK';
} else {
echo 'Verify callback data failed';
}