-
Notifications
You must be signed in to change notification settings - Fork 22
/
callback.php
71 lines (67 loc) · 2.91 KB
/
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
64
65
66
67
68
69
70
71
<?php
/**
* 2011-2016 Blockonomics
*
* NOTICE OF LICENSE
*
* This source file is subject to the Academic Free License (AFL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/afl-3.0.php
* If you did not receive a copy of the license and are unable to
* obtain it through the world-wide-web, please send an email
* to license@blockonomics.co so we can send you a copy immediately.
*
* @author Blockonomics Admin <admin@blockonomics.co>
* @copyright 2011-2016 Blockonomics
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
* International Registered Trademark & Property of Blockonomics
*/
require dirname(__FILE__) . '/../../config/config.inc.php';
require dirname(__FILE__) . '/../../header.php';
$secret = Tools::getValue('secret');
$txid = Tools::getValue('txid');
$value = Tools::getValue('value');
$status = Tools::getValue('status');
$addr = Tools::getValue('addr');
// Match secret for callback
if ($secret == Configuration::get('BLOCKONOMICS_CALLBACK_SECRET')) {
// Update status and txid for transaction
$query = 'UPDATE ' . _DB_PREFIX_ . "blockonomics_bitcoin_orders SET status='" . (int) $status . "',txid='" . pSQL($txid) . "',bits_payed=" . (int) $value . " WHERE addr='" . pSQL($addr) . "'";
$result = Db::getInstance()->Execute($query);
if ($status >= 0) {
$order = Db::getInstance()->ExecuteS('SELECT * FROM ' . _DB_PREFIX_ . "blockonomics_bitcoin_orders WHERE `addr` = '" . pSQL($addr) . "' LIMIT 1");
if ($order) {
if ($order[0]['id_cart']) {
// Delete backup cart
$delete_cart =
'DELETE FROM ' .
_DB_PREFIX_ .
"cart WHERE id_cart = '" .
$order[0]['id_cart'] . "'";
Db::getInstance()->Execute($delete_cart);
// Remove id_cart from order
$remove_cart =
'UPDATE ' .
_DB_PREFIX_ .
"blockonomics_bitcoin_orders SET id_cart=''" .
" WHERE addr='" .
pSQL($addr) .
"'";
Db::getInstance()->Execute($remove_cart);
}
// Update order status
$o = new Order($order[0]['id_order']);
if ($status == 0 || $status == 1) {
$o->setCurrentState(Configuration::get('BLOCKONOMICS_ORDER_STATUS_0'));
} elseif ($status == 2) {
$o->setCurrentState(Configuration::get('BLOCKONOMICS_ORDER_STATUS_2'));
if ($order[0]['bits'] > $order[0]['bits_payed']) {
$o->setCurrentState(Configuration::get('PS_OS_ERROR'));
} else {
$o->setCurrentState(Configuration::get('PS_OS_PAYMENT'));
}
}
}
}
}