From 51c2a61fec61ba847690ab360c61a69a5812aad5 Mon Sep 17 00:00:00 2001 From: Joshua Lewis Date: Fri, 24 Apr 2020 13:22:14 -0400 Subject: [PATCH] fix for non-default installs --- modules/gateways/bitpaycheckout.php | 7 ++-- .../bitpaycheckout_callback.php | 2 +- .../bitpaycheckout/bitpaycheckout_ipn.php | 42 ++++++++++++++++--- 3 files changed, 41 insertions(+), 10 deletions(-) diff --git a/modules/gateways/bitpaycheckout.php b/modules/gateways/bitpaycheckout.php index 7c813cc..5d58160 100644 --- a/modules/gateways/bitpaycheckout.php +++ b/modules/gateways/bitpaycheckout.php @@ -1,6 +1,6 @@ 'BitPay_Checkout_WHCMS', - 'APIVersion' => '3.0.1.3', // Use API Version 1.1 + 'APIVersion' => '3.0.1.4', // Use API Version 1.1 'DisableLocalCreditCardInput' => false, 'TokenisedStorage' => false, ); @@ -134,7 +134,8 @@ function BPC_autoloader($class) function bitpaycheckout_link($config_params) { - $curpage = $_SERVER['SCRIPT_NAME']; + $curpage = basename($_SERVER["SCRIPT_FILENAME"]); + $curpage = str_replace("/", "", $curpage); if ($curpage != 'viewinvoice.php'): return;endif; ?> diff --git a/modules/gateways/bitpaycheckout/bitpaycheckout_callback.php b/modules/gateways/bitpaycheckout/bitpaycheckout_callback.php index 5f23ffc..2a194a1 100644 --- a/modules/gateways/bitpaycheckout/bitpaycheckout_callback.php +++ b/modules/gateways/bitpaycheckout/bitpaycheckout_callback.php @@ -1,7 +1,7 @@ $orderid,"transaction_id" => $order_invoice); + $result = select_query($table, $fields, $where); $rowdata = mysql_fetch_array($result); $btn_id = $rowdata['transaction_id']; @@ -58,14 +60,22 @@ $table = "tblinvoices"; $update = array("status" => 'Paid','datepaid' => date("Y-m-d H:i:s")); $where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout"); + try{ update_query($table, $update, $where); + } + catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } #update the bitpay_invoice table $table = "_bitpay_checkout_transactions"; $update = array("transaction_status" => $event['name']); $where = array("order_id" => $orderid, "transaction_id" => $order_invoice); + try{ update_query($table, $update, $where); - + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } break; @@ -74,13 +84,21 @@ $table = "tblinvoices"; $update = array("status" => 'Payment Pending','datepaid' => date("Y-m-d H:i:s")); $where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout"); + try{ update_query($table, $update, $where); + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } #update the bitpay_invoice table $table = "_bitpay_checkout_transactions"; $update = array("transaction_status" => $event['name']); $where = array("order_id" => $orderid, "transaction_id" => $order_invoice); + try{ update_query($table, $update, $where); + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } break; @@ -90,13 +108,21 @@ $table = "tblinvoices"; $update = array("status" => 'Unpaid'); $where = array("id" => $orderid, "paymentmethod" => "bitpaycheckout"); + try{ update_query($table, $update, $where); + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } #update the bitpay_invoice table $table = "_bitpay_checkout_transactions"; $update = array("transaction_status" => $event['name']); $where = array("order_id" => $orderid, "transaction_id" => $order_invoice); + try{ update_query($table, $update, $where); + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } break; @@ -105,7 +131,11 @@ #delete any orphans $table = "_bitpay_checkout_transactions"; $delete = 'DELETE FROM _bitpay_checkout_transactions WHERE transaction_id = "' . $order_invoice.'"'; + try{ full_query($delete); + }catch (Exception $e ){ + file_put_contents($file,$e,FILE_APPEND); + } break; #update both table to refunded