Beispiel #1
0
 public function notify($request)
 {
     unset($request['city']);
     unset($request['ctl']);
     unset($request['act']);
     unset($request['class_name']);
     unset($_POST['city']);
     unset($_POST['ctl']);
     unset($_POST['act']);
     unset($_POST['class_name']);
     $upop_evn = $this->upop_evn;
     $return_res = array('info' => '', 'status' => false);
     $payment = $GLOBALS['db']->getRow("select id,config from " . DB_PREFIX . "payment where class_name='Upop'");
     $payment['config'] = unserialize($payment['config']);
     // 商户名称
     quickpay_conf::$pay_params['merAbbr'] = $payment['config']['upop_merAbbr'];
     foreach (Upop_payment::$api_url[$upop_evn] as $key => $value) {
         quickpay_conf::${$key} = $value;
     }
     if ($upop_evn == '2') {
         quickpay_conf::$security_key = $payment['config']['upop_security_key'];
         quickpay_conf::$pay_params['merId'] = $payment['config']['upop_account'];
     } else {
         if ($upop_evn == '1') {
             quickpay_conf::$security_key = $payment['config']['upop_security_key_pm'];
             quickpay_conf::$pay_params['merId'] = $payment['config']['upop_account_pm'];
         } else {
             if ($upop_evn == '0') {
                 quickpay_conf::$security_key = $payment['upop_security_key'];
                 quickpay_conf::$pay_params['merId'] = $payment['upop_account'];
             }
         }
     }
     try {
         $response = new quickpay_service($request, quickpay_conf::RESPONSE);
         if ($response->get('respCode') != quickpay_service::RESP_SUCCESS) {
             $err = sprintf("Error: %d => %s", $response->get('respCode'), $response->get('respMsg'));
             showErr($err);
         }
         $arr_ret = $response->get_args();
         if (quickpay_conf::$pay_params['merId'] != $arr_ret['merId']) {
             echo "fail";
             die;
         }
         // 如果未支付成功。
         if ($arr_ret['respCode'] != '00') {
             echo "fail";
             die;
         }
         //告诉用户交易完成
         $payment_notice_sn = $arr_ret['orderNumber'];
         $outer_notice_sn = $arr_ret['orderNumber'];
         $payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where notice_sn = '" . $payment_notice_sn . "'");
         $order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $payment_notice['order_id']);
         require_once APP_ROOT_PATH . "system/model/cart.php";
         $rs = payment_paid($payment_notice['id']);
         if ($rs) {
             $rs = order_paid($payment_notice['order_id']);
             if ($rs) {
                 //开始更新相应的outer_notice_sn
                 $GLOBALS['db']->query("update " . DB_PREFIX . "payment_notice set outer_notice_sn = '" . $outer_notice_sn . "' where id = " . $payment_notice['id']);
                 echo "Success";
             } else {
                 echo "Success";
             }
         } else {
             app_redirect(url("index", "payment#pay", array("id" => $payment_notice['id'])));
         }
     } catch (Exception $exp) {
         $str .= var_export($exp, true);
         echo "fail";
     }
 }
Beispiel #2
0
<?php

//前台支付接口示例
ini_set('display_errors', 0);
require dirname(__FILE__) . '/../include/common.inc.php';
require_once 'api/quickpay_service.php';
//下面这行用于测试,以生成随机且唯一的订单号
mt_srand(quickpay_service::make_seed());
$orderAmount = $_POST['price'] * 100;
//总金额
$orderNumber = $_POST['ordersn'];
//订单号
quickpay_conf::$security_key = $cfg_yinlian_securitykey;
//key
quickpay_conf::$pay_params['merId'] = $cfg_yinlian_merid;
//商户号
quickpay_conf::$pay_params['merAbbr'] = $cfg_yinlian_mername;
//商户名称
$param['transType'] = quickpay_conf::CONSUME;
//交易类型,CONSUME or PRE_AUTH
$param['orderAmount'] = $orderAmount;
//交易金额
$param['orderNumber'] = $orderNumber;
//订单号,必须唯一
$param['orderTime'] = date('YmdHis');
//交易时间, YYYYmmhhddHHMMSS
$param['orderCurrency'] = quickpay_conf::CURRENCY_CNY;
//交易币种,CURRENCY_CNY=>人民币
$param['customerIp'] = $_SERVER['REMOTE_ADDR'];
//用户IP
$param['frontEndUrl'] = $GLOBALS['cfg_basehost'] . "/yinlian/front_notify.php";