Post by darth_danny » Mon Aug 08, 2016 9:50 pm

Hi,

I made a custom payment method that posts data to a payment gateway and the gateway then posts data back to the entered return URL. This is the code I am using for my callback function but it doesnt seem to respond

Code: Select all

  public function callback() {
      
      require_once('money_functions/functions.php');
      
      
      $logfile = "money_.".date ("Y-m-d_His")."__".rand(100,999).".log";
      dLogOpen ($logfile);
      dLogWrite("Test:\n function seen and implemented \n");
      dLogClose();     
        if (isset($this->request->post['orderid'])) {
			$order_id = $this->request->post['orderid'];
		} else {
			$order_id = 0;
		}
       
    $this->load->model('checkout/order');
    
    $order_info = $this->model_checkout_order->getOrder($order_id);
  
    if ($order_info) {
      
      if($_GET['unique_transaction_id'])
      {
          
        $order_status_id = $this->config->get('config_order_status_id');
        

        
        $transactionArray['transaction_reference'] = trim($_GET['transaction_reference']);
        $transactionArray['unique_transaction_id'] = trim($_GET['unique_transaction_id']);
        $transactionArray['item_number']           = trim($_GET['item_number']);
        
        if($transactionArray['unique_transaction_id'] != '' && $transactionArray['transaction_reference'] != '')
        {
             $transactionArray = yo_account_tx_check_status($transactionArray); 

             if($transactionArray['api_response']['TransactionStatus'] == "SUCCEEDED")
             {
                 $order_status_id = "Complete";   
                 $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
             }
             else
             {
                 $order_status_id = "Failed";
                 $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
             }
        }
        
      }
      else{

        }
    }
  
  }
Logs arent being written and order status isnt updated and also there are no errors

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 08, 2016 10:11 pm

Followed are the simple modifications I converted for Opencart with the $_GET super global with the Opencart instantiated objects. This methodology will also you to debug the information on the original error logs of Opencart rather than using your own error logs in order to report the next issues on this topic when you test the callback. Reports will be indicated into your admin - > systems - > tools - > error logs page.

It is, however, suggested to integrate a debug option into the admin module in order to initiate these tests when your site is live or without maintenance on a public server.

Additional note: I left you notes in the code itself since I am not sure why those specific entries are being indicated in your codes.

Code: Select all

public function callback() {
	// Straightlight note: No idea what this function calls about ...
	require_once('money_functions/functions.php');
	
	$this->log->write("Test:\n function seen and implemented \n");
  
    if (isset($this->request->post['orderid'])) {
    	$order_id = $this->request->post['orderid'];
    } else {
        $order_id = 0;
    }

	$status = true;

	if (!isset($this->request->get['transaction_reference'])) {
		$this->log->write("Test:\n transaction_reference could not be found \n");
		
		$status = false;
	}
	
	if (!isset($this->request->get['unique_transaction_id'])) {
		$this->log->write("Test:\n unique_transaction_id could not be found \n");
		
		$status = false;
	}
	
	if (!isset($this->reqest->get['item_number'])) {
		$this->log->write("Test:\n item_number could not be found\n");
		
		$status = false;
	}
	
	if ($status) {
	    $this->load->model('checkout/order');
	    
	    $order_info = $this->model_checkout_order->getOrder($order_id);
	  
	    if ($order_info) {
	    	$order_status_id = $this->config->get('config_order_status_id');
	        
	        $transactionArray['transaction_reference'] = trim($this->request->get['transaction_reference']);
		    $transactionArray['unique_transaction_id'] = trim($this->request->get['unique_transaction_id']);
	        $transactionArray['item_number']           = trim($this->request->get['item_number']);
	        
	        if ($transactionArray['unique_transaction_id'] != '' && $transactionArray['transaction_reference'] != '') {
	            $transactionArray = yo_account_tx_check_status($transactionArray); 

	                        if (html_entity_decode(trim(strtoupper($transactionArray['api_response']['TransactionStatus'])), ENT_QUOTES, 'UTF-8') == "SUCCEEDED") {
	                $order_status_id = "Complete";   
	                $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
		        } else {
	                 $order_status_id = "Failed";
	                 $this->model_checkout_order->addOrderHistory($order_id, $order_status_id);
	            }
	        }
		// Straightlight note: else to do what?
	    } else {
				
	    }
	}
}

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Mon Aug 08, 2016 10:57 pm

Hi,

Thanks alot. Unfortunately there seems to be an issue with the returned values. How can I print a list of all returned values in the get[] array?

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Mon Aug 08, 2016 11:56 pm

darth_danny wrote:Hi,

Thanks alot. Unfortunately there seems to be an issue with the returned values. How can I print a list of all returned values in the get[] array?
Can you post the error logs messages that are being returned and provide the API documentation assigned by your remote provider?

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON

Post by darth_danny » Tue Aug 09, 2016 1:35 pm

The error logs are empty. There is no documentation, I am basing this off sample code I got from someone who uses the same API. There are supposed to be certain returned values but since they dont seem to match I wanted to view all the values posted back so that I can work out if its a problem with my script or the returned values I expected arent the same as what is posted back

New member

Posts

Joined
Wed Jul 27, 2016 5:41 pm

Post by straightlight » Tue Aug 09, 2016 7:06 pm

I would be harden to provide a solution which you don't have the materials in order to provide an accurate answer for the problem you're reporting about at this point.

Dedication and passion goes to those who are able to push and merge a project.

Regards,
Straightlight
Programmer / Opencart Tester


Legendary Member

Posts

Joined
Mon Nov 14, 2011 11:38 pm
Location - Canada, ON
Who is online

Users browsing this forum: Amazon [Bot] and 5 guests