1

I am updating a payment plugin on our application to work with the new version of opencart 2.0 and above. I followed the instruction found at Adding an admin page on OpenCart version 2 and everything almost worked fine.

When my transaction is approved, the order status updates fine, but when not approved it does not update.

Please is there something i am missing?

 public function callback() {
    if ( $_REQUEST['transaction_id'] != '' ){
        $xml = file_get_contents('https://payx.com/?v_transaction_id='.$_REQUEST['transaction_id']);
        $xml_elements = new SimpleXMLElement($xml);
        $transaction = array();
        foreach($xml_elements as $key => $value) 
        {
            $transaction[$key]=$value;
        }

        $email = $transaction['email'];
        $total = $transaction['total'];
        $date = $transaction['date'];
        $order_id = $transaction['merchant_ref'];
        $status = $transaction['status'];
        $transaction_id = $transaction['transaction_id'];

        if ($order_id !== ''){
            $this->load->model('checkout/order');
            $order_info = $this->model_checkout_order->getOrder($order_id);
            if ($order_info) {
                if (trim(strtolower($status)) == 'approved'){

                    $message = 'Payment Status : - '.$status.' - Transaction Id: '.$transaction_id;
                    $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('payx_order_status_id'), $message , false);
                }else{

                    $message = 'Payment Status : - '.$status.' - Transaction Id: '.$transaction_id;
                    $this->model_checkout_order->addOrderHistory($order_id, $this->config->get('payx_order_status_id'), $message, false);   

                }
            }
        }
    }
}
Community
  • 1
  • 1
user297056
  • 23
  • 8

0 Answers0