From 9eeb00b51f6282c7531911271d829e5a6e3f291b Mon Sep 17 00:00:00 2001 From: Pieter Poorthuis Date: Tue, 18 Apr 2017 14:55:28 +0200 Subject: [PATCH] WHMCS v7 compatibility --- modules/gateways/bit-pay/.htaccess | 0 modules/gateways/bit-pay/bp_lib.php | 1 + modules/gateways/bit-pay/bp_options.php | 0 modules/gateways/bit-pay/createinvoice.php | 21 +++++++++++---------- modules/gateways/bit-pay/index.php | 0 modules/gateways/bitpay.php | 2 +- modules/gateways/callback/bitpay.php | 9 +++++++++ 7 files changed, 22 insertions(+), 11 deletions(-) mode change 100644 => 100755 modules/gateways/bit-pay/.htaccess mode change 100644 => 100755 modules/gateways/bit-pay/bp_lib.php mode change 100644 => 100755 modules/gateways/bit-pay/bp_options.php mode change 100644 => 100755 modules/gateways/bit-pay/index.php mode change 100644 => 100755 modules/gateways/callback/bitpay.php diff --git a/modules/gateways/bit-pay/.htaccess b/modules/gateways/bit-pay/.htaccess old mode 100644 new mode 100755 diff --git a/modules/gateways/bit-pay/bp_lib.php b/modules/gateways/bit-pay/bp_lib.php old mode 100644 new mode 100755 index 0aa7763..d65c675 --- a/modules/gateways/bit-pay/bp_lib.php +++ b/modules/gateways/bit-pay/bp_lib.php @@ -147,6 +147,7 @@ function bpCreateInvoice($orderId, $price, $posData, $options = array()) } $post = json_encode($post); + $response = bpCurl($network, $options['apiKey'], $post); return $response; diff --git a/modules/gateways/bit-pay/bp_options.php b/modules/gateways/bit-pay/bp_options.php old mode 100644 new mode 100755 diff --git a/modules/gateways/bit-pay/createinvoice.php b/modules/gateways/bit-pay/createinvoice.php index 5491886..793d19c 100755 --- a/modules/gateways/bit-pay/createinvoice.php +++ b/modules/gateways/bit-pay/createinvoice.php @@ -23,6 +23,8 @@ * THE SOFTWARE. */ +use WHMCS\Database\Capsule; + include '../../../includes/functions.php'; include '../../../includes/gatewayfunctions.php'; include '../../../includes/invoicefunctions.php'; @@ -45,8 +47,8 @@ // get invoice $invoiceId = (int) $_POST['invoiceId']; $price = $currency = false; -$result = mysql_query("SELECT tblinvoices.total, tblinvoices.status, tblcurrencies.code FROM tblinvoices, tblclients, tblcurrencies where tblinvoices.userid = tblclients.id and tblclients.currency = tblcurrencies.id and tblinvoices.id=$invoiceId"); -$data = mysql_fetch_assoc($result); +$result = Capsule::connection()->select("SELECT tblinvoices.total, tblinvoices.status, tblcurrencies.code FROM tblinvoices, tblclients, tblcurrencies where tblinvoices.userid = tblclients.id and tblclients.currency = tblcurrencies.id and tblinvoices.id=$invoiceId"); +$data = (array)$result[0]; if (!$data) { bpLog('[ERROR] In modules/gateways/bitpay/createinvoice.php: No invoice found for invoice id #' . $invoiceId); @@ -65,8 +67,8 @@ // if convert-to option is set (gateway setting), then convert to requested currency $convertTo = false; $query = "SELECT value from tblpaymentgateways where `gateway` = '$gatewaymodule' and `setting` = 'convertto'"; -$result = mysql_query($query); -$data = mysql_fetch_assoc($result); +$result = Capsule::connection()->select($query); +$data = (array)$result[0]; if ($data) { $convertTo = $data['value']; @@ -75,16 +77,16 @@ if ($convertTo) { // fetch $currency and $convertTo currencies $query = "SELECT rate FROM tblcurrencies where `code` = '$currency'"; - $result = mysql_query($query); - $currentCurrency = mysql_fetch_assoc($result); + $result = Capsule::connection()->select($query); + $currentCurrency = (array)$result[0]; if (!$currentCurrency) { bpLog('[ERROR] In modules/gateways/bitpay/createinvoice.php: Invalid invoice currency of ' . $currency); die('[ERROR] In modules/gateways/bitpay/createinvoice.php: Invalid invoice currency of ' . $currency); } - $result = mysql_query("SELECT code, rate FROM tblcurrencies where `id` = $convertTo"); - $convertToCurrency = mysql_fetch_assoc($result); + $result = Capsule::connection()->select("SELECT code, rate FROM tblcurrencies where `id` = $convertTo"); + $convertToCurrency = (array)$result[0]; if (!$convertToCurrency) { bpLog('[ERROR] In modules/gateways/bitpay/createinvoice.php: Invalid convertTo currency of ' . $convertTo); @@ -100,10 +102,9 @@ unset($options['invoiceId']); unset($options['systemURL']); -unset($options['redirectURL']); $options['notificationURL'] = $_POST['systemURL'].'/modules/gateways/callback/bitpay.php'; -$options['redirectURL'] = isset($_POST['redirectURL']) ? $_POST['redirectURL'] : $_POST['systemURL']; +$options['redirectURL'] = $_POST['systemURL']; $options['apiKey'] = $GATEWAY['apiKey']; $options['transactionSpeed'] = $GATEWAY['transactionSpeed']; $options['currency'] = $currency; diff --git a/modules/gateways/bit-pay/index.php b/modules/gateways/bit-pay/index.php old mode 100644 new mode 100755 diff --git a/modules/gateways/bitpay.php b/modules/gateways/bitpay.php index 6cad7b0..131817b 100755 --- a/modules/gateways/bitpay.php +++ b/modules/gateways/bitpay.php @@ -96,7 +96,7 @@ function bitpay_link($params) 'buyerEmail' => $email, 'buyerPhone' => $phone, ); - + $form = '
'; foreach ($post as $key => $value) { diff --git a/modules/gateways/callback/bitpay.php b/modules/gateways/callback/bitpay.php old mode 100644 new mode 100755 index bb93b3c..5488c08 --- a/modules/gateways/callback/bitpay.php +++ b/modules/gateways/callback/bitpay.php @@ -23,6 +23,8 @@ * THE SOFTWARE. */ +use WHMCS\Database\Capsule; + // Required File Includes include '../../../includes/functions.php'; include '../../../includes/gatewayfunctions.php'; @@ -60,6 +62,11 @@ $invoiceid = checkCbInvoiceID($invoiceid, $GATEWAY['name']); $transid = $response['id']; + + + $invoice = Capsule::table('tblinvoices')->where('id', $invoiceid)->first(); + + $userid = $invoice->userid; // Checks transaction number isn't already in the database and ends processing if it does checkCbTransID($transid); @@ -77,11 +84,13 @@ break; case 'confirmed': // Apply Payment to Invoice + Capsule::table('tblclients')->where('id', $userid)->update(array('defaultgateway' => $gatewaymodule)); addInvoicePayment($invoiceid, $transid, $amount, $fee, $gatewaymodule); logTransaction($GATEWAY['name'], $response, 'The payment has been received, and the transaction has been confirmed on the bitcoin network. This will be updated when the transaction has been completed.'); break; case 'complete': // Apply Payment to Invoice + Capsule::table('tblclients')->where('id', $userid)->update(array('defaultgateway' => $gatewaymodule)); addInvoicePayment($invoiceid, $transid, $amount, $fee, $gatewaymodule); logTransaction($GATEWAY['name'], $response, 'The transaction is now complete.'); break;