Zen Cart Logo
Forums / Addon Payment Modules / Error with Bitpay payment module... trying to fix myself

Error with Bitpay payment module... trying to fix myself

Views: 3,102

Results 1 to 7 of 7
16 Jan 2014, 12:41 AM
#1
lolwaut avatar

lolwaut

Zen Follower

Join Date:
Dec 2010
Posts:
142
Plugin Contributions:
0

Error with Bitpay payment module... trying to fix myself

Hi,

I have installed the Bitpay ZC module which is a payment module that allows merchant's to accept bitcoins as a payment option.

I have searched for a solution to this problem online and found that many others are experience the same problem. Additionally, I couldn't find a single person that said they were actually sucessfully using the module. I emailed bitpay support about this issue, but they have been unresponsive. So, I am at the point of trying to fix this issue myself with the help of the community.

Here's the problem. It installs fine, I
can select Bitcoin as a payment option during checkout, then when I press
the confirm order button, I just get a blank screen. This is the point
where it should redirect the customer to the external bitcoin.com payment system.

I checked
the debug files and this is what it says:

[15-Jan-2014 13:20:58] PHP Fatal error: Call to undefined function
zen_remove_order() in .../includes/modules/payment/bitpay.php on line 137

Line 137 of bitpay.php is:

zen_remove_order($insert_id, $restock = true);

Any help at all with this would be greatly appreciated. Can anybody tell me what is wrong in the above code?

Below is the entire bitpay.php file, just in case it is needed:

<?php
/**
 * Bit-pay.com Payment Module
 *
 * @package paymentMethod
 */
  class bitpay {
    var $code, $title, $description, $enabled, $payment;
	
	function log($contents){
		return; // turn on to debug
		$file = 'bitpay/log.txt';
		file_put_contents($file, date('m-d H:i:s').": \n", FILE_APPEND);
		if (is_array($contents))
			foreach($contents as $k => $v)
				file_put_contents($file, $k.': '.$v."\n", FILE_APPEND);
		else
			file_put_contents($file, $contents."\n", FILE_APPEND);
	}
	
	// class constructor
	function bitpay() {
		global $order;
		$this->code = 'bitpay';
		$this->title = MODULE_PAYMENT_BITPAY_TEXT_TITLE;
		$this->description = MODULE_PAYMENT_BITPAY_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_PAYMENT_BITPAY_SORT_ORDER;
		$this->enabled = ((MODULE_PAYMENT_BITPAY_STATUS == 'True') ? true : false);

		if ((int)MODULE_PAYMENT_BITPAY_ORDER_STATUS_ID > 0) {
			$this->order_status = MODULE_PAYMENT_BITPAY_ORDER_STATUS_ID;
			$payment='bitpay';
		} else if ($payment=='bitpay') {
			$payment='';
		}

		if (is_object($order)) $this->update_status();

		$this->email_footer = MODULE_PAYMENT_BITPAY_TEXT_EMAIL_FOOTER;
	}

	// class methods
	function update_status() {
		global $db;
		global $order;

		// check zone
		if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_BITPAY_ZONE > 0) ) {
			$check_flag = false;
			$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . intval(MODULE_PAYMENT_BITPAY_ZONE) . "' and zone_country_id = '" . intval($order->billing['country']['id']) . "' order by zone_id");
			while (!$check->EOF) {
				if ($check->fields['zone_id'] < 1) {
					$check_flag = true;
					break;
				} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
					$check_flag = true;
					break;
				}
				$check->MoveNext();
			}

			if ($check_flag == false) {
				$this->enabled = false;
			}
		}
		
		// check currency
		$currencies = array_map('trim',explode(",",MODULE_PAYMENT_BITPAY_CURRENCIES));
		if (array_search($order->info['currency'], $currencies) === false)
		{
			$this->enabled = false;
		}
					
		// check that api key is not blank
		if (!MODULE_PAYMENT_BITPAY_APIKEY OR !strlen(MODULE_PAYMENT_BITPAY_APIKEY))
		{
			print 'no secret '.MODULE_PAYMENT_BITPAY_APIKEY;
			$this->enabled = false;
		}
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title);
    }

    function pre_confirmation_check() {
      return false;
    }

	// called upon requesting step 3
    function confirmation() {
 		return false;
    }
	
	// called upon requesting step 3 (after confirmation above)
	function process_button() {		
		return false;
	}

	// called upon clicking confirm
    function before_process() {
		return false; 
    }

	// called upon clicking confirm (after before_process and after the order is created)
    function after_process() {
		global $insert_id, $order, $db;
		require_once 'bitpay/bp_lib.php';    			
				
		// change order status to value selected by merchant
		$db->Execute("update ". TABLE_ORDERS. " set orders_status = " . intval(MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID) . " where orders_id = ". intval($insert_id));
				
		
		$options = array(
			'physical' => $order->content_type == 'physical' ? 'true' : 'false',
			'currency' => $order->info['currency'],
			'buyerName' => $order->customer['firstname'].' '.$order->customer['lastname'],			
			'fullNotifications' => 'true',
			'notificationURL' => zen_href_link('bitpay_callback.php', $parameters='', $connection='NONSSL', $add_session_id=true, $search_engine_safe=true, $static=true ),
			'redirectURL' => zen_href_link('account'),
			'transactionSpeed' => MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED,
			'apiKey' => MODULE_PAYMENT_BITPAY_APIKEY,
			);
		$invoice = bpCreateInvoice($insert_id, $order->info['total'], $insert_id, $options);
		
		$this->log("created invoice orderID=$insert_id with options: ".var_export($options, true));
		$this->log("invoice: ".var_export($invoice, true));			
			
		if (!is_array($invoice) or array_key_exists('error', $invoice)) 
		{
			$this->log('createInvoice error '.var_export($invoice['error'], true));
			zen_remove_order($insert_id, $restock = true);
			// unfortunately, there's not a good way of telling the customer that it's hosed.  Their cart is still full so they can try again w/ a different payment option.
		}
		else
		{
			$_SESSION['cart']->reset(true);
			zen_redirect($invoice['url']);
		}

		
		return false;
    }

    function get_error() {
      return false;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_BITPAY_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    function install() {
		global $db, $messageStack;
		if (defined('MODULE_PAYMENT_BITPAY_STATUS')) {
			$messageStack->add_session('Bit-pay module already installed.', 'error');
			zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=bitpay', 'NONSSL'));
			return 'failed';
		}
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) "
		."values ('Enable Bit-pay Module', 'MODULE_PAYMENT_BITPAY_STATUS', 'True', 'Do you want to accept bitcoin payments via bit-pay.com?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('API Key', 'MODULE_PAYMENT_BITPAY_APIKEY', '', 'Enter you API Key which you generated at bitpay.com', '6', '0', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) "
		."values ('Transaction speed', 'MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED', 'low', 'At what speed do you want the transactions to be considered confirmed?', '6', '0', 'zen_cfg_select_option(array(\'high\', \'medium\', \'low\'),', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) "
		."values ('Unpaid Order Status', 'MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID', '" . intval(DEFAULT_ORDERS_STATUS_ID) .  "', 'Automatically set the status of unpaid orders to this value.', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) "
		."values ('Paid Order Status', 'MODULE_PAYMENT_BITPAY_PAID_STATUS_ID', '2', 'Automatically set the status of paid orders to this value.', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('Currencies', 'MODULE_PAYMENT_BITPAY_CURRENCIES', 'BTC, USD, EUR, GBP, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, HKD, HRK, HUF, IDR, ILS, INR, JPY, KRW, LTL, LVL, MXN, MYR, NOK, NZD, PHP, PLN, RON, RUB, SEK, SGD, THB, TRY, ZAR', 'Only enable bit-pay payments if one of these currencies is selected (note: currency must be supported by bit-pay.com).', '6', '0', now())");
			
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) "
		."values ('Payment Zone', 'MODULE_PAYMENT_BITPAY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
		
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('Sort order of display.', 'MODULE_PAYMENT_BITPAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '2', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array(
		'MODULE_PAYMENT_BITPAY_STATUS', 
		'MODULE_PAYMENT_BITPAY_APIKEY',
		'MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED',
		'MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID',
		'MODULE_PAYMENT_BITPAY_PAID_STATUS_ID',
		'MODULE_PAYMENT_BITPAY_SORT_ORDER',
		'MODULE_PAYMENT_BITPAY_ZONE',		
		'MODULE_PAYMENT_BITPAY_CURRENCIES',
		);
    }
  }
16 Jan 2014, 10:18 AM
#2
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Error with Bitpay payment module... trying to fix myself

lolwaut:

Hi,

I have installed the Bitpay ZC module which is a payment module that allows merchant's to accept bitcoins as a payment option.

I have searched for a solution to this problem online and found that many others are experience the same problem. Additionally, I couldn't find a single person that said they were actually sucessfully using the module. I emailed bitpay support about this issue, but they have been unresponsive. So, I am at the point of trying to fix this issue myself with the help of the community.

Here's the problem. It installs fine, I
can select Bitcoin as a payment option during checkout, then when I press
the confirm order button, I just get a blank screen. This is the point
where it should redirect the customer to the external bitcoin.com payment system.

I checked
the debug files and this is what it says:

Line 137 of bitpay.php is:

zen_remove_order($insert_id, $restock = true);

> 
> Any help at all with this would be greatly appreciated. Can anybody tell me what is wrong in the above code?
> 
> Below is the entire bitpay.php file, just in case it is needed:
> 
> ```
<?php
/**
 * Bit-pay.com Payment Module
 *
 * @package paymentMethod
 */
  class bitpay {
    var $code, $title, $description, $enabled, $payment;
	
	function log($contents){
		return; // turn on to debug
		$file = 'bitpay/log.txt';
		file_put_contents($file, date('m-d H:i:s').": \n", FILE_APPEND);
		if (is_array($contents))
			foreach($contents as $k => $v)
				file_put_contents($file, $k.': '.$v."\n", FILE_APPEND);
		else
			file_put_contents($file, $contents."\n", FILE_APPEND);
	}
	
	// class constructor
	function bitpay() {
		global $order;
		$this->code = 'bitpay';
		$this->title = MODULE_PAYMENT_BITPAY_TEXT_TITLE;
		$this->description = MODULE_PAYMENT_BITPAY_TEXT_DESCRIPTION;
		$this->sort_order = MODULE_PAYMENT_BITPAY_SORT_ORDER;
		$this->enabled = ((MODULE_PAYMENT_BITPAY_STATUS == 'True') ? true : false);

		if ((int)MODULE_PAYMENT_BITPAY_ORDER_STATUS_ID > 0) {
			$this->order_status = MODULE_PAYMENT_BITPAY_ORDER_STATUS_ID;
			$payment='bitpay';
		} else if ($payment=='bitpay') {
			$payment='';
		}

		if (is_object($order)) $this->update_status();

		$this->email_footer = MODULE_PAYMENT_BITPAY_TEXT_EMAIL_FOOTER;
	}

	// class methods
	function update_status() {
		global $db;
		global $order;

		// check zone
		if ( ($this->enabled == true) && ((int)MODULE_PAYMENT_BITPAY_ZONE > 0) ) {
			$check_flag = false;
			$check = $db->Execute("select zone_id from " . TABLE_ZONES_TO_GEO_ZONES . " where geo_zone_id = '" . intval(MODULE_PAYMENT_BITPAY_ZONE) . "' and zone_country_id = '" . intval($order->billing['country']['id']) . "' order by zone_id");
			while (!$check->EOF) {
				if ($check->fields['zone_id'] < 1) {
					$check_flag = true;
					break;
				} elseif ($check->fields['zone_id'] == $order->billing['zone_id']) {
					$check_flag = true;
					break;
				}
				$check->MoveNext();
			}

			if ($check_flag == false) {
				$this->enabled = false;
			}
		}
		
		// check currency
		$currencies = array_map('trim',explode(",",MODULE_PAYMENT_BITPAY_CURRENCIES));
		if (array_search($order->info['currency'], $currencies) === false)
		{
			$this->enabled = false;
		}
					
		// check that api key is not blank
		if (!MODULE_PAYMENT_BITPAY_APIKEY OR !strlen(MODULE_PAYMENT_BITPAY_APIKEY))
		{
			print 'no secret '.MODULE_PAYMENT_BITPAY_APIKEY;
			$this->enabled = false;
		}
    }

    function javascript_validation() {
      return false;
    }

    function selection() {
      return array('id' => $this->code,
                   'module' => $this->title);
    }

    function pre_confirmation_check() {
      return false;
    }

	// called upon requesting step 3
    function confirmation() {
 		return false;
    }
	
	// called upon requesting step 3 (after confirmation above)
	function process_button() {		
		return false;
	}

	// called upon clicking confirm
    function before_process() {
		return false; 
    }

	// called upon clicking confirm (after before_process and after the order is created)
    function after_process() {
		global $insert_id, $order, $db;
		require_once 'bitpay/bp_lib.php';    			
				
		// change order status to value selected by merchant
		$db->Execute("update ". TABLE_ORDERS. " set orders_status = " . intval(MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID) . " where orders_id = ". intval($insert_id));
				
		
		$options = array(
			'physical' => $order->content_type == 'physical' ? 'true' : 'false',
			'currency' => $order->info['currency'],
			'buyerName' => $order->customer['firstname'].' '.$order->customer['lastname'],			
			'fullNotifications' => 'true',
			'notificationURL' => zen_href_link('bitpay_callback.php', $parameters='', $connection='NONSSL', $add_session_id=true, $search_engine_safe=true, $static=true ),
			'redirectURL' => zen_href_link('account'),
			'transactionSpeed' => MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED,
			'apiKey' => MODULE_PAYMENT_BITPAY_APIKEY,
			);
		$invoice = bpCreateInvoice($insert_id, $order->info['total'], $insert_id, $options);
		
		$this->log("created invoice orderID=$insert_id with options: ".var_export($options, true));
		$this->log("invoice: ".var_export($invoice, true));			
			
		if (!is_array($invoice) or array_key_exists('error', $invoice)) 
		{
			$this->log('createInvoice error '.var_export($invoice['error'], true));
			zen_remove_order($insert_id, $restock = true);
			// unfortunately, there's not a good way of telling the customer that it's hosed.  Their cart is still full so they can try again w/ a different payment option.
		}
		else
		{
			$_SESSION['cart']->reset(true);
			zen_redirect($invoice['url']);
		}

		
		return false;
    }

    function get_error() {
      return false;
    }

    function check() {
      global $db;
      if (!isset($this->_check)) {
        $check_query = $db->Execute("select configuration_value from " . TABLE_CONFIGURATION . " where configuration_key = 'MODULE_PAYMENT_BITPAY_STATUS'");
        $this->_check = $check_query->RecordCount();
      }
      return $this->_check;
    }

    function install() {
		global $db, $messageStack;
		if (defined('MODULE_PAYMENT_BITPAY_STATUS')) {
			$messageStack->add_session('Bit-pay module already installed.', 'error');
			zen_redirect(zen_href_link(FILENAME_MODULES, 'set=payment&module=bitpay', 'NONSSL'));
			return 'failed';
		}
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) "
		."values ('Enable Bit-pay Module', 'MODULE_PAYMENT_BITPAY_STATUS', 'True', 'Do you want to accept bitcoin payments via bit-pay.com?', '6', '0', 'zen_cfg_select_option(array(\'True\', \'False\'), ', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('API Key', 'MODULE_PAYMENT_BITPAY_APIKEY', '', 'Enter you API Key which you generated at bitpay.com', '6', '0', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, date_added) "
		."values ('Transaction speed', 'MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED', 'low', 'At what speed do you want the transactions to be considered confirmed?', '6', '0', 'zen_cfg_select_option(array(\'high\', \'medium\', \'low\'),', now());");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) "
		."values ('Unpaid Order Status', 'MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID', '" . intval(DEFAULT_ORDERS_STATUS_ID) .  "', 'Automatically set the status of unpaid orders to this value.', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, set_function, use_function, date_added) "
		."values ('Paid Order Status', 'MODULE_PAYMENT_BITPAY_PAID_STATUS_ID', '2', 'Automatically set the status of paid orders to this value.', '6', '0', 'zen_cfg_pull_down_order_statuses(', 'zen_get_order_status_name', now())");

		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('Currencies', 'MODULE_PAYMENT_BITPAY_CURRENCIES', 'BTC, USD, EUR, GBP, AUD, BGN, BRL, CAD, CHF, CNY, CZK, DKK, HKD, HRK, HUF, IDR, ILS, INR, JPY, KRW, LTL, LVL, MXN, MYR, NOK, NZD, PHP, PLN, RON, RUB, SEK, SGD, THB, TRY, ZAR', 'Only enable bit-pay payments if one of these currencies is selected (note: currency must be supported by bit-pay.com).', '6', '0', now())");
			
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, use_function, set_function, date_added) "
		."values ('Payment Zone', 'MODULE_PAYMENT_BITPAY_ZONE', '0', 'If a zone is selected, only enable this payment method for that zone.', '6', '2', 'zen_get_zone_class_title', 'zen_cfg_pull_down_zone_classes(', now())");
		
		$db->Execute("insert into " . TABLE_CONFIGURATION . " (configuration_title, configuration_key, configuration_value, configuration_description, configuration_group_id, sort_order, date_added) "
		."values ('Sort order of display.', 'MODULE_PAYMENT_BITPAY_SORT_ORDER', '0', 'Sort order of display. Lowest is displayed first.', '6', '2', now())");
    }

    function remove() {
      global $db;
      $db->Execute("delete from " . TABLE_CONFIGURATION . " where configuration_key in ('" . implode("', '", $this->keys()) . "')");
    }

    function keys() {
      return array(
		'MODULE_PAYMENT_BITPAY_STATUS', 
		'MODULE_PAYMENT_BITPAY_APIKEY',
		'MODULE_PAYMENT_BITPAY_TRANSACTION_SPEED',
		'MODULE_PAYMENT_BITPAY_UNPAID_STATUS_ID',
		'MODULE_PAYMENT_BITPAY_PAID_STATUS_ID',
		'MODULE_PAYMENT_BITPAY_SORT_ORDER',
		'MODULE_PAYMENT_BITPAY_ZONE',		
		'MODULE_PAYMENT_BITPAY_CURRENCIES',
		);
    }
  }

Try searching for:

    function after_process() {
global $insert_id, $order, $db;
require_once 'bitpay/bp_lib.php';

The code should be just above the problem statement. On the next line, try inserting:

require_once '';

Well, nevermind the above. Zen_remove_orders is an admin function. A customer doesn't have access to the admin side of ZC, so if the above truly is activated as part of an attempt for a customer to process a transaction then yes an error will occur. Would need to find a function that is similar on the customer's side. Otherwise that function is found in the admin folder's/includes/functions/general.php so the above require once would have that entire path...

It seems like one would instead clear the cart if again this function is to be activated on the customer taking some sort of action.

Perhaps not clear the cart, but I haven't looked at what it is specifically trying to perform nor have I looked at similar procedures to see how data is handled at that point/reset, etc...

16 Jan 2014, 10:30 AM
#3
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Error with Bitpay payment module... trying to fix myself

mc12345678:

Try searching for:

function after_process() {

global $insert_id, $order, $db;
require_once 'bitpay/bp_lib.php';

> 
> The code should be just above the problem statement. On the next line, try inserting:
> ```
require_once '';

Well, nevermind the above. Zen_remove_orders is an admin function. A customer doesn't have access to the admin side of ZC, so if the above truly is activated as part of an attempt for a customer to process a transaction then yes an error will occur. Would need to find a function that is similar on the customer's side. Otherwise that function is found in the admin folder's/includes/functions/general.php so the above require once would have that entire path...

It seems like one would instead clear the cart if again this function is to be activated on the customer taking some sort of action.

Perhaps not clear the cart, but I haven't looked at what it is specifically trying to perform nor have I looked at similar procedures to see how data is handled at that point/reset, etc...

Btw, that was just the start of the issues.
Now that I have taken a step back and looked at what is going on in this area of the code, well the only reason that function is being called is because:

if (!is_array($invoice) or array_key_exists('error', $invoice)) 

Says to) so while it would be great to properly handle an error, it would be even better not to get one in the first place. So would need to back track what is causing the above condition to be true. Realize there are two tests in that line, either being true (or both) will send you down that path.

16 Jan 2014, 11:32 AM
#4
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Error with Bitpay payment module... trying to fix myself

How many products have been in your cart when you tried this? Was it more than one? I recommend first trying with two different items. If that works, try 2 of the same product. If that doesn't work, then the code that returns the variable that is checked to be an array is not ensuring to assign the variable as an array when only a single product is in the cart. If neither works, then either the variable is not properly assigned or there is an error being created. Ideally would want to do something to localize that. Possibly separate the two checks, both doing the same actions, but at least that way "functionality" would be the same, just not ideally written.

So that would be if not an array do this, after that is done, if an error do the same thing above. Then the resulting error line number will at least identify which is first being experienced and can go tackle that situation. Once resolved can check again to ensure the other situation isn't occurring.

9 Feb 2014, 4:04 PM
#5
split63 avatar

split63

Totally Zenned

Join Date:
May 2010
Location:
Texas
Posts:
513
Plugin Contributions:
0

Re: Error with Bitpay payment module... trying to fix myself

It appears that the bitpay plugin may have been updated. The files are dated 1/29/14.
The change log is weak, so who knows what they fixed, if anything.

9 Feb 2014, 4:55 PM
#6
mc12345678 avatar

mc12345678

Totally Zenned

Join Date:
Jul 2012
Posts:
16,908
Plugin Contributions:
2

Re: Error with Bitpay payment module... trying to fix myself

split63:

It appears that the bitpay plugin may have been updated. The files are dated 1/29/14.
The change log is weak, so who knows what they fixed, if anything.

While I don't feel it necessary to say to you, but for those that might read this in the future, comparing the old to the new should identify what changed, though may not identify what got fixed. (Subtle difference) hopefully it is whatever was causing the error situation above.

Keep the thread updated as you go along!

29 May 2014, 8:23 PM
#7
coins2012 avatar

coins2012

New Zenner

Join Date:
Jan 2012
Posts:
89
Plugin Contributions:
0

Re: Error with Bitpay payment module... trying to fix myself

I installed this module also but don't like the fact that an order could be placed without paying in bitcoins, the order flow should be like the PayPal module, I tested it, Zencart creates an order after clicking 'Confirm Order', it takes me to Bitpay website for a payment but let's say the customer did not pay, now you have all these pending orders which need to be dealt with, I think the module should be rewritten or modified so that Zencart creates and order after payment is made.

Any ideas how to do this, I am willing to pay for this modification.