Skip to content

Commit

Permalink
Merge pull request #63 from thejoshualewis/master
Browse files Browse the repository at this point in the history
fix for non-default installs
  • Loading branch information
thejoshualewis authored Apr 24, 2020
2 parents 4972220 + 51c2a61 commit c2752e4
Show file tree
Hide file tree
Showing 3 changed files with 41 additions and 10 deletions.
7 changes: 4 additions & 3 deletions modules/gateways/bitpaycheckout.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* BitPay Checkout 3.0.1.3
* BitPay Checkout 3.0.1.4
*
* Within the module itself, all functions must be prefixed with the module
* filename, followed by an underscore, and then the function name. For this
Expand Down Expand Up @@ -54,7 +54,7 @@ function bitpaycheckout_MetaData()
{
return array(
'DisplayName' => '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,
);
Expand Down Expand Up @@ -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;
?>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* BitPay Checkout Callback 3.0.1.3
* BitPay Checkout Callback 3.0.1.4
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand Down
42 changes: 36 additions & 6 deletions modules/gateways/bitpaycheckout/bitpaycheckout_ipn.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php

/**
* BitPay Checkout IPN 3.0.1.3
* BitPay Checkout IPN 3.0.1.4
*
* This file demonstrates how a payment gateway callback should be
* handled within WHMCS.
Expand All @@ -23,11 +23,12 @@
require_once '../../../includes/invoicefunctions.php';

$all_data = json_decode(file_get_contents("php://input"), true);
$file = 'bitpay.txt';

error_log("===========INCOMING IPN=========================");
error_log(date('d.m.Y H:i:s'));
error_log(print_r($all_data, true));
error_log("===========END OF IPN===========================");
file_put_contents($file,"===========INCOMING IPN=========================",FILE_APPEND);
file_put_contents($file,date('d.m.Y H:i:s'),FILE_APPEND);
file_put_contents($file,print_r($all_data, true),FILE_APPEND);
file_put_contents($file,"===========END OF IPN===========================",FILE_APPEND);

$data = $all_data['data'];
$event = $all_data['event'];
Expand All @@ -45,6 +46,7 @@
$table = "_bitpay_checkout_transactions";
$fields = "order_id,transaction_id";
$where = array("order_id" => $orderid,"transaction_id" => $order_invoice);

$result = select_query($table, $fields, $where);
$rowdata = mysql_fetch_array($result);
$btn_id = $rowdata['transaction_id'];
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;

Expand All @@ -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
Expand Down

0 comments on commit c2752e4

Please sign in to comment.