打开购物车付款插件状态更新无效

时间:2015-01-23 12:03:14

标签: php jquery html css opencart2.x

我正在更新我们的应用程序上的付款插件,以使用新版本的opencart 2.0及更高版本。 我按照Adding an admin page on OpenCart version 2处的说明进行操作,一切都很顺利。

当我的交易获得批准后,订单状态会更新,但如果未获批准,则不会更新。

请问我有什么遗失的吗?

 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);   

                }
            }
        }
    }
}

0 个答案:

没有答案