-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathpayment.php
90 lines (64 loc) · 1.93 KB
/
payment.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
<?php
require_once(dirname(__FILE__) . '/modules/gateways/Blockonomics/Blockonomics.php');
require __DIR__ . '/init.php';
use WHMCS\ClientArea;
use WHMCS\Database\Capsule;
use Blockonomics\Blockonomics;
define('CLIENTAREA', true);
// Init Blockonomics class
$blockonomics = new Blockonomics();
$ca = new ClientArea();
$ca->setPageTitle('Bitcoin Payment');
$ca->addToBreadCrumb('index.php', Lang::trans('globalsystemname'));
$ca->addToBreadCrumb('payment.php', 'Bitcoin Payment');
$ca->initPage();
/*
* SET POST PARAMETERS TO VARIABLES AND CHECK IF THEY EXIST
*/
$fiat_amount = $_POST['price'];
$currency = $_POST['currency'];
$order_id = $_POST['order_id'];
$system_url = $blockonomics->getSystemUrl();
if(!$fiat_amount || !$currency || !$order_id) {
exit;
}
$ca->assign('fiat_amount', $fiat_amount);
$ca->assign('currency', $currency);
$ca->assign('order_id', $order_id);
$ca->assign('system_url', $system_url);
/*
* ADDRESS GENERATION
*/
$response_obj = $blockonomics->getNewBitcoinAddress();
$error_str = $blockonomics->checkForErrors($response_obj);
if ($error_str) {
$ca->assign('error', $error_str);
} else {
$btc_address = $response_obj->address;
$ca->assign('btc_address', $btc_address);
/*
* PRICE GENERATION
*/
$btc_amount = $blockonomics->getBitcoinAmount($fiat_amount, $currency);
$ca->assign('btc_amount', $btc_amount / 1.0e8);
/*
* ÁDD ORDER TO DB
*/
$blockonomics->insertOrderToDb($order_id, $btc_address, $fiat_amount, $btc_amount);
/*
* UPDATE ORDER STATUS
*/
$true_order_id = $blockonomics->getOrderIdByInvoiceId($order_id);
$order_status = 'Waiting for Bitcoin Confirmation';
$blockonomics->updateOrderStatus($true_order_id, $order_status);
}
/**
* Set a context for sidebars
*
* @link http://docs.whmcs.com/Editing_Client_Area_Menus#Context
*/
Menu::addContext();
# Define the template filename to be used without the .tpl extension
$ca->setTemplate('../blockonomics/payment');
$ca->output();
?>