当前位置: 首页>>代码示例>>PHP>>正文


PHP WapAction::generatePayResultUrl方法代码示例

本文整理汇总了PHP中WapAction::generatePayResultUrl方法的典型用法代码示例。如果您正苦于以下问题:PHP WapAction::generatePayResultUrl方法的具体用法?PHP WapAction::generatePayResultUrl怎么用?PHP WapAction::generatePayResultUrl使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WapAction的用法示例。


在下文中一共展示了WapAction::generatePayResultUrl方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: callback

 public function callback()
 {
     Log::record('cftpay callback get:' . print_r($_GET, true));
     Log::save();
     // 由于二级域名redirect的原因,我们会自动在GET参数里添加shop=merchant_code,需要显示的去掉该参数
     unset($_GET['shop']);
     unset($_GET['_URL_']);
     $out_trade_no = $_GET['sp_billno'];
     $transaction_id = $_GET['transaction_id'];
     if (empty($out_trade_no) || empty($transaction_id)) {
         echo 'fail';
         exit;
     }
     // verify whether trade record existing in our db for <order_sn>
     $trade = M('b2c_cfttrade')->where(array('order_sn' => $out_trade_no, 'transaction_id' => $transaction_id))->find();
     if (empty($trade)) {
         Log::record('cftpay callback non existing order_sn get:' . print_r($_GET, true));
         Log::save();
         $this->error('非法订单号', U('Wap/Shop/error'));
     }
     $DECODED_GET = array();
     foreach ($_GET as $k => $v) {
         $DECODED_GET[$k] = urldecode($v);
     }
     import("@.ORG.CftWapPayHelper");
     // url signature verification
     $cftWapPayHelper = new CftWapPayHelper($trade['partnerId'], $trade['partnerkey']);
     foreach ($DECODED_GET as $k => $v) {
         $cftWapPayHelper->setParameter($k, $v);
     }
     if (!$cftWapPayHelper->isTenpaySign()) {
         // sign mismatch
         Log::record('cftpay callback url sign mismatch: .GET:' . print_r($_GET, true));
         Log::save();
         echo 'fail';
         exit;
     }
     Log::record('cftpay callback url sign verification passed!', Log::INFO);
     Log::save();
     $audit['trade_callback_timestamp'] = time();
     $audit['trade_callback_times'] = $trade['trade_callback_times'] + 1;
     M('b2c_cfttrade')->where(array('id' => $trade['id']))->save($audit);
     $host_name = C('wx_handler_server');
     // update trade table for tracking
     if ($trade['n_pay_result'] == 0) {
         $redirect = WapAction::generatePayResultUrl('Shop/my', $trade['token'], array('token' => $trade['token'], 'wecha_id' => $trade['wecha_id'], 'success' => 1));
         $this->redirect($redirect);
         //$this->success('交易成功',U('Wap/Shop/index',array('shop'=> $trade['token'],'wecha_id'=>$trade['wecha_id'])));
     } else {
         $redirect = WapAction::generatePayResultUrl('Shop/my', $trade['token'], array('token' => $trade['token'], 'wecha_id' => $trade['wecha_id'], 'success' => 0));
         $this->redirect($redirect);
         //$this->error('交易失败',U('Wap/Shop/index',array('shop'=> $trade['token'],'wecha_id'=>$trade['wecha_id'])));
     }
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:54,代码来源:ShopCftPayAction.class.php

示例2: return_url

 public function return_url()
 {
     $out_trade_no = $_GET['out_trade_no'];
     Log::record("return url:" . print_r($_GET, true), Log::INFO);
     $shop = null;
     $trade = null;
     if ($out_trade_no) {
         $Model = new Model();
         // 实例化一个model对象 没有对应任何数据表
         $shop = $Model->query("select o.token, o.wecha_id, p.pay_config  from tp_b2c_order as o JOIN tp_b2c_payment as p on p.token = o.token where p.pay_code ='alipay' and o.sn = '{$out_trade_no}'");
         if ($shop == null) {
             Log::record("Illegle order sn:" . $out_trade_no, Log::NOTICE);
             $this->error('非法订单号', U('Wap/Shop/error'));
         }
         if (is_array($shop) && is_string($shop[0]['pay_config'])) {
             $store = unserialize($shop[0]['pay_config']);
             $shop[0]['pay_account'] = $store['pay_account'];
             //合作身份者id,以2088开头的16位纯数字
             $shop[0]['partner'] = $store['alipay_pid'];
             //安全检验码,以数字和字母组成的32位字符
             //如果签名方式设置为“MD5”时,请设置该参数
             $shop[0]['key'] = $store['alipay_key'];
         }
     }
     Log::record("shop_config:" . print_r($shop, true), Log::INFO);
     import("@.ORG.AliWapPay.AlipayNotify");
     $alipayNotify = new AlipayNotify($this->setconfig($shop[0]['partner'], $shop[0]['key']));
     $verify_result = $alipayNotify->verifyReturn();
     if ($verify_result) {
         //商户订单号
         $out_trade_no = $_GET['out_trade_no'];
         //支付宝交易号
         $trade_no = $_GET['trade_no'];
         //交易状态
         $trade_status = $_GET['result'];
         //用户付款时间
         $gmt_payment_time = time();
         $trade_db = M('b2c_trade');
         $trade_where = array('order_sn' => $out_trade_no);
         $trade = $trade_db->field('trade_id', 'token', 'trade_no')->where($trade_where)->find();
         Log::record('return url: status:' . $trade_status . ' trade_no:' . $trade['trade_no'], Log::INFO);
         Log::save();
         if ($trade_status == 'success' && $trade && empty($trade['trade_no'])) {
             $data = array('status' => 2, 'trade_no' => $trade_no, 'alipay_create_time' => time(), 'payment_time' => $gmt_payment_time);
             $ret = $trade_db->where($trade_where)->save($data);
             if ($ret) {
                 //2 是订单已付款
                 $order_ret = M('b2c_order')->where(array('sn' => $out_trade_no))->save(array('status' => 2));
                 Log::save();
                 //echo "交易成功<br />";
                 $redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 1));
                 $this->redirect($redirect);
                 //$this->success('交易成功',U('Wap/Shop/index',array('shop'=> $trade['token'])));
             }
         }
         if ($trade_status == 'success') {
             $redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 1));
             $this->redirect($redirect);
         } else {
             $redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 0));
             $this->redirect($redirect);
         }
     } else {
         Log::save();
         //echo "支付失败<br />";
         $redirect = WapAction::generatePayResultUrl('Shop/my', $shop[0]['token'], array('token' => $shop[0]['token'], 'wecha_id' => $shop[0]['wecha_id'], 'success' => 0));
         $this->redirect($redirect);
         //$this->error('支付失败 ,请联系客服,为您处理',U('Wap/Shop/index'));
     }
 }
开发者ID:zhaoshengloveqingqing,项目名称:Wechat,代码行数:70,代码来源:ShopPayAction.class.php


注:本文中的WapAction::generatePayResultUrl方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。