Exemplo n.º 1
0
 public function index()
 {
     $data['button_confirm'] = $this->language->get('button_confirm');
     $data['button_back'] = $this->language->get('button_back');
     $data['return'] = HTTPS_SERVER . 'index.php?route=checkout/success';
     if ($this->request->get['route'] != 'checkout/guest_step_3') {
         $data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/payment';
     } else {
         $data['cancel_return'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2';
     }
     $this->load->library('encryption');
     $encryption = new Encryption($this->config->get('config_encryption'));
     $data['custom'] = $encryption->encrypt($this->session->data['order_id']);
     if ($this->request->get['route'] != 'checkout/guest_step_3') {
         $data['back'] = HTTPS_SERVER . 'index.php?route=checkout/payment';
     } else {
         $data['back'] = HTTPS_SERVER . 'index.php?route=checkout/guest_step_2';
     }
     $this->load->model('checkout/order');
     $order_id = $this->session->data['order_id'];
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $seller_email = $this->config->get('alipay_seller_email');
     $security_code = $this->config->get('alipay_security_code');
     $trade_type = $this->config->get('alipay_trade_type');
     $partner = $this->config->get('alipay_partner');
     $currency_code = 'CNY';
     $item_name = $this->config->get('config_name');
     $full_name = $order_info['payment_fullname'];
     $total = $order_info['total'];
     $currency_value = $this->currency->getValue($currency_code);
     $amount = $total * $currency_value;
     $amount = number_format($amount, 2, '.', '');
     $_input_charset = "utf-8";
     $sign_type = "MD5";
     $transport = "http";
     $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php';
     $return_url = HTTPS_SERVER . 'index.php?route=checkout/success';
     $show_url = "";
     $parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $order_id, "body" => 'Owner ' . $full_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email);
     $alipay = new alipay_service($parameter, $security_code, $sign_type);
     $action = $alipay->build_url();
     $data['action'] = $action;
     //$this->id = 'payment';
     // Save payment url address for pay later.
     $this->model_checkout_order->setOrderPaymentUrl($order_id, $action);
     // 		log_result("Alipay test 111111111111");
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) {
         return $this->load->view($this->config->get('config_template') . '/template/payment/alipay.tpl', $data);
     } else {
         return $this->load->view('default/template/payment/alipay.tpl', $data);
     }
 }
Exemplo n.º 2
0
 public function index()
 {
     $currency_code = 'CNY';
     $_input_charset = "utf-8";
     $sign_type = "MD5";
     $transport = "http";
     $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php';
     $return_url = HTTPS_SERVER . 'index.php?route=payment/paysuccess';
     $trade_type = $this->config->get('alipay_trade_type');
     $partner = $this->config->get('alipay_partner');
     $security_code = $this->config->get('alipay_security_code');
     $item_name = $this->config->get('config_store');
     $seller_email = $this->config->get('alipay_seller_email');
     $trade_type_international = "alipay.trade.direct.forcard.pay";
     $partner_international = "2088511796637269";
     //$partner_international       = "2088011357497434";
     $security_code_international = "lzwlxledgojm22pz0vgkjtjkm907agf2";
     //$security_code_international = "qo58xp4g1ywibtiiyns1gftw5mbv5rs3";
     $seller_email_international = "*****@*****.**";
     //$seller_email_international  = "*****@*****.**";
     $this->load->library('encryption');
     $encryption = new Encryption($this->config->get('config_encryption'));
     $this->load->model('checkout/order');
     $this->load->model('account/customer');
     if (isset($this->session->data['customer_id'])) {
         $customer_id = $this->customer->getId();
         if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "recharge" == $this->request->post['action']) {
             //$return_url = HTTPS_SERVER . 'index.php?route=account/rmbaccount';
             //人民币充值金额
             if (isset($this->request->post['amount']) && $this->request->post['amount']) {
                 $amount = $this->request->post['amount'];
             } else {
                 $amount = '';
             }
             if (isset($this->request->post['money']) && $this->request->post['money']) {
                 $money = $this->request->post['money'];
             } else {
                 $money = '';
             }
             $this->load->model('account/rechargerecord');
             $first_name = $this->customer->getFirstName();
             $accountmoney = $this->customer->getMoney();
             if (isset($this->request->post['js_return']) && $this->request->post['js_return']) {
                 $security_code = $security_code_international;
                 $extend_param = $this->request->post['js_return'];
                 //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php';
                 if (isset($this->request->post['type']) && $this->request->post['type']) {
                     $type = $this->request->post['type'];
                 }
                 $data = array("firstname" => $first_name, 'amount' => $amount, 'currency' => $currency_code, 'money' => $money, 'paytype' => '3', 'payname' => "支付宝国际信用卡", 'accountmoney' => $accountmoney + $money, 'addtime' => time(), 'state' => 0);
                 $rid = $this->model_account_rechargerecord->addRechargerecord($data);
                 $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => trim(strtolower($_input_charset)), "subject" => $item_name . ' Order:' . $rid, "out_trade_no" => 'cz-' . $rid . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "currency" => $currency_code, "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_logon_id" => $seller_email_international);
             } else {
                 if (isset($this->request->post['recharge_defaultbank']) && $this->request->post['recharge_defaultbank']) {
                     $defaultbank = $this->request->post['recharge_defaultbank'];
                     $payname = "网络银行";
                 } else {
                     $defaultbank = '';
                     $payname = "支付宝";
                 }
                 $data = array("firstname" => $first_name, 'amount' => $amount, 'currency' => $currency_code, 'money' => $money, 'paytype' => '2', 'payname' => $payname, 'accountmoney' => $accountmoney + $money, 'addtime' => time(), 'state' => 0);
                 $rid = $this->model_account_rechargerecord->addRechargerecord($data);
                 $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $rid, "body" => 'Owner ' . $first_name, "out_trade_no" => 'cz-' . $rid . '-' . $customer_id, "total_fee" => $amount, "payment_type" => "1", "seller_email" => $seller_email);
             }
             $alipay = new alipay_service($parameter, $security_code, $sign_type);
             $action = $alipay->build_url();
             $this->response->setOutput(json_encode($action));
         }
         if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "waybill" == $this->request->post['action']) {
             //$return_url = HTTPS_SERVER . 'index.php?route=order/order/order_guoji';
             if (isset($this->request->post['js_return']) && $this->request->post['js_return']) {
                 //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php';
                 if (isset($this->session->data['waybill'])) {
                     $this->load->model('order/order');
                     $waybill = $this->session->data['waybill'];
                     if (isset($this->request->post['type']) && $this->request->post['type']) {
                         $type = $this->request->post['type'];
                     }
                     if (isset($this->request->post['amount']) && $this->request->post['amount']) {
                         $amount = $this->request->post['amount'];
                     }
                     //测试专用
                     //$amount = 0.01;
                     $extend_param = $this->request->post['js_return'];
                     $security_code = $security_code_international;
                     $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $waybill, "out_trade_no" => 'yd-' . $waybill . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "payment_type" => "1", "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_email" => $seller_email_international);
                 }
             } else {
                 // log_result("Waybill".$this->session->data['waybill']);
                 if (isset($this->session->data['waybill'])) {
                     $this->load->model('order/order');
                     //$return_url = HTTPS_SERVER . 'index.php?route=order/order/order_guoji';
                     $waybill = $this->session->data['waybill'];
                     if (isset($this->request->post['amount']) && $this->request->post['amount']) {
                         $amount = $this->request->post['amount'];
                     } else {
                         $amount = 0;
                     }
                     //测试专用
                     //$amount = 0.01;
                     if (isset($this->request->post['waybill_defaultbank']) && $this->request->post['waybill_defaultbank']) {
                         $defaultbank = $this->request->post['waybill_defaultbank'];
                     } else {
                         $defaultbank = '';
                     }
                     $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $waybill, "out_trade_no" => 'yd-' . $waybill . '-' . $customer_id, "total_fee" => $amount, "payment_type" => "1", "seller_email" => $seller_email);
                 }
             }
             $alipay = new alipay_service($parameter, $security_code, $sign_type);
             $action = $alipay->build_url();
             $this->response->setOutput(json_encode($action));
         }
         if ($this->request->server['REQUEST_METHOD'] == 'POST' && isset($this->request->post['action']) && "order" == $this->request->post['action']) {
             //$return_url = HTTPS_SERVER . 'index.php?route=order/order';
             if (isset($this->request->post['js_return']) && $this->request->post['js_return']) {
                 if (isset($this->session->data['order_id'])) {
                     $return_url = HTTPS_SERVER . 'index.php?route=order/order';
                     //$notify_url = HTTP_SERVER . 'catalog/controller/payment/callback_international.php';
                     $extend_param = $this->request->post['js_return'];
                     $security_code = $security_code_international;
                     $order_id_array = explode(",", $this->session->data['order_id']);
                     $order_id = end($order_id_array);
                     $amount = round($this->session->data['order_total'] * (1 + 0.01 + 0.001), 2);
                     //测试专用
                     //$amount = 0.01;
                     if (isset($this->request->post['type']) && $this->request->post['type']) {
                         $type = $this->request->post['type'];
                     }
                     $parameter = array("service" => $trade_type_international, "partner" => $partner_international, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => trim(strtolower($_input_charset)), "subject" => $item_name . ' Order:' . $order_id, "out_trade_no" => $this->session->data['order_id'] . '-' . $customer_id, "default_bank" => "cybs-" . $type, "extend_param" => str_replace(" ", "", $extend_param), "total_fee" => $amount, "currency" => $currency_code, "paymethod" => trim("jvm-3d"), "sign_type" => "MD5", "sign" => $security_code_international, "seller_logon_id" => $seller_email_international);
                 }
             } else {
                 if (isset($this->session->data['order_id'])) {
                     $order_id_array = explode(",", $this->session->data['order_id']);
                     $order_id = end($order_id_array);
                     $amount = round($this->session->data['order_total'] * (1 + 0.01 + 0.001), 2);
                     if (isset($this->request->post['order_defaultbank']) && $this->request->post['order_defaultbank']) {
                         $defaultbank = $this->request->post['order_defaultbank'];
                     } else {
                         $defaultbank = '';
                     }
                     //测试专用
                     // $amount = 0.01;
                     $parameter = array("paymethod" => "bankPay", "defaultbank" => $defaultbank, "service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . ' Order:' . $order_id, "out_trade_no" => $this->session->data['order_id'] . '-' . $customer_id, "payment_type" => "1", "total_fee" => $amount, "seller_email" => $seller_email);
                 }
             }
             $alipay = new alipay_service($parameter, $security_code, $sign_type);
             $action = $alipay->build_url();
             $this->response->setOutput(json_encode($action));
         }
     }
 }
Exemplo n.º 3
0
 public function reorder()
 {
     $this->data['button_confirm'] = $this->language->get('button_reoder_confirm');
     $this->data['button_back'] = $this->language->get('button_back');
     $this->data['return'] = $this->url->link('checkout/success', '', 'SSL');
     $this->load->library('encryption');
     $encryption = new Encryption($this->config->get('config_encryption'));
     $order_id = $this->request->get['order_id'];
     $this->data['custom'] = $encryption->encrypt($order_id);
     $this->load->model('checkout/order');
     $order_info = $this->model_checkout_order->getOrder($order_id);
     $seller_email = $this->config->get('alipay_seller_email');
     $security_code = $this->config->get('alipay_security_code');
     $trade_type = $this->config->get('alipay_trade_type');
     $partner = $this->config->get('alipay_partner');
     $currency_code = 'CNY';
     $item_name = $this->config->get('config_name');
     $first_name = $order_info['payment_firstname'];
     $last_name = $order_info['payment_lastname'];
     $total = $order_info['total'];
     $currency_value = $this->currency->getValue($currency_code);
     $amount = $total * $currency_value;
     $amount = number_format($amount, 2, '.', '');
     $_input_charset = "utf-8";
     $sign_type = "MD5";
     $transport = "http";
     $notify_url = HTTP_SERVER . 'catalog/controller/payment/alipay_callback.php';
     $return_url = HTTPS_SERVER . 'index.php?route=account/paysuccess';
     $show_url = "";
     $parameter = array("service" => $trade_type, "partner" => $partner, "return_url" => $return_url, "notify_url" => $notify_url, "_input_charset" => $_input_charset, "subject" => $item_name . $this->language->get('text_order_no') . $order_id, "body" => $item_name, "out_trade_no" => $order_id, "price" => $amount, "payment_type" => "1", "quantity" => "1", "logistics_fee" => '0.00', "logistics_payment" => 'BUYER_PAY', "logistics_type" => 'EXPRESS', "show_url" => $show_url, "seller_email" => $seller_email);
     $alipay = new alipay_service($parameter, $security_code, $sign_type);
     $action = $alipay->build_url();
     $this->data['reorder'] = true;
     $this->data['action'] = $action;
     $this->id = 'payment';
     if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/alipay.tpl')) {
         $this->template = $this->config->get('config_template') . '/template/payment/alipay.tpl';
     } else {
         $this->template = 'default/template/payment/alipay.tpl';
     }
     $this->render();
 }