public function callbackbak() { $this->load->helper('alipay_dt_core'); $this->load->helper('alipay_dt_md'); $alipay_config['partner'] = $this->config->get('alipay_direct_partner'); $alipay_config['key'] = $this->config->get('alipay_direct_security_code'); $alipay_config['sign_type'] = strtoupper('MD5'); $alipay_config['input_charset'] = strtolower('utf-8'); $alipay_config['cacert'] = getcwd() . '\\cacert.pem'; $alipay_config['transport'] = HTTPS_SERVER; $log = $this->config->get('alipay_direct_log'); if ($log) { $this->log->write('Alipay_Direct :: One: '); } $this->load->library('alipaydtnotify'); $alipayNotify = new Alipaydtnotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($log) { $this->log->write('Alipay_Direct :: Two: ' . $verify_result); } if ($verify_result) { $out_trade_no = $this->request->post['out_trade_no']; $order_id = $out_trade_no; $trade_no = $this->request->post['trade_no']; $trade_status = $this->request->post['trade_status']; $order_status_id = $this->config->get('config_order_status_id'); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($log) { $this->log->write('Alipay_Direct :: Three: '); } if ($order_info) { if ($log) { $this->log->write('Alipay_Direct :: Four: '); } if ($_POST['trade_status'] == 'TRADE_FINISHED') { if ($log) { $this->log->write('Alipay_Direct :: Five: '); } $order_status_id = $this->config->get('alipay_direct_trade_finished_status_id'); if (!$order_info['order_status_id']) { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); } else { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); } echo "success"; } else { if ($_POST['trade_status'] == 'TRADE_SUCCESS') { if ($log) { $this->log->write('Alipay_Direct :: Six: '); } $order_status_id = $this->config->get('alipay_direct_trade_success_status_id'); if (!$order_info['order_status_id']) { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); } else { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id, '', true); } echo "success"; } } //清除sesssion,避免客户返回不到成功页面而无法清除原有的购物车等信息 $this->cart->clear(); unset($this->session->data['shipping_method']); unset($this->session->data['shipping_methods']); unset($this->session->data['payment_method']); unset($this->session->data['payment_methods']); unset($this->session->data['guest']); unset($this->session->data['comment']); unset($this->session->data['order_id']); unset($this->session->data['coupon']); unset($this->session->data['reward']); unset($this->session->data['voucher']); unset($this->session->data['vouchers']); unset($this->session->data['totals']); if (isset($this->session->data['cs_shipfrom'])) { unset($this->session->data['cs_shipfrom']); } if (isset($this->sesssion->data['personal_card'])) { unset($this->sesssion->data['personal_card']); } } else { if ($log) { $this->log->write('Alipay_Direct :: Seven: '); } echo "fail"; } } else { if ($log) { $this->log->write('Alipay_Direct :: Eight: '); } echo "fail"; } }
public function callback() { $this->load->helper('alipay_dt_core'); $this->load->helper('alipay_dt_md'); $alipay_config['partner'] = $this->config->get('alipay_direct_partner'); $alipay_config['key'] = $this->config->get('alipay_direct_security_code'); $alipay_config['sign_type'] = strtoupper('MD5'); $alipay_config['input_charset'] = strtolower('utf-8'); $alipay_config['cacert'] = getcwd() . '\\cacert.pem'; $alipay_config['transport'] = HTTPS_SERVER; $log = $this->config->get('alipay_direct_log'); if ($log) { $this->log->write('Alipay_Direct :: One: '); } $this->load->library('alipaydtnotify'); $alipayNotify = new Alipaydtnotify($alipay_config); $verify_result = $alipayNotify->verifyNotify(); if ($log) { $this->log->write('Alipay_Direct :: Two: ' . $verify_result); } if ($verify_result) { $out_trade_no = $this->request->post['out_trade_no']; $order_id = $out_trade_no; $trade_no = $this->request->post['trade_no']; $trade_status = $this->request->post['trade_status']; $order_status_id = $this->config->get('config_order_status_id'); $this->load->model('checkout/order'); $order_info = $this->model_checkout_order->getOrder($order_id); if ($log) { $this->log->write('Alipay_Direct :: Three: '); } if ($order_info) { if ($log) { $this->log->write('Alipay_Direct :: Four: '); } if ($_POST['trade_status'] == 'TRADE_FINISHED') { if ($log) { $this->log->write('Alipay_Direct :: Five: '); } $order_status_id = $this->config->get('alipay_direct_trade_finished_status_id'); if (!$order_info['order_status_id']) { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); } else { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); } echo "success"; } else { if ($_POST['trade_status'] == 'TRADE_SUCCESS') { if ($log) { $this->log->write('Alipay_Direct :: Six: '); } $order_status_id = $this->config->get('alipay_direct_trade_success_status_id'); if (!$order_info['order_status_id']) { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); } else { $this->model_checkout_order->addOrderHistory($order_id, $order_status_id); } echo "success"; } } } else { if ($log) { $this->log->write('Alipay_Direct :: Seven: '); } echo "fail"; } } else { if ($log) { $this->log->write('Alipay_Direct :: Eight: '); } echo "fail"; } }