Ejemplo n.º 1
0
 private final function ReplyNotify($needSign = true)
 {
     if ($needSign == true && $this->GetReturn_code($return_code) == "SUCCESS") {
         $this->SetSign();
     }
     WxpayApi::replyNotify($this->ToXml());
 }
Ejemplo n.º 2
0
 /**
  * 
  * 生成扫描支付URL,模式一
  * @param BizPayUrlInput $bizUrlInfo
  */
 public function GetPrePayUrl($productId)
 {
     $biz = new WxPayBizPayUrl();
     $biz->SetProduct_id($productId);
     $values = WxpayApi::bizpayurl($biz);
     $url = "weixin://wxpay/bizpayurl?" . $this->ToUrlParams($values);
     return $url;
 }
Ejemplo n.º 3
0
 /**
  * 
  * 回复通知
  * @param bool $needSign 是否需要签名输出
  */
 private final function ReplyNotify($needSign = true)
 {
     //如果需要签名
     if ($needSign == true && $this->GetReturn_code($return_code) == "SUCCESS") {
         $this->SetSign();
     }
     $xml = $this->ToXml();
     $fp = fopen("jcbjcb.log", "w");
     fputs($fp, $xml);
     fclose($fp);
     WxpayApi::replyNotify($xml);
 }
Ejemplo n.º 4
0
 /**
  * 
  * 回复通知
  * @param bool $needSign 是否需要签名输出
  */
 private final function ReplyNotify($needSign = true)
 {
     //如果需要签名
     //marked by hehb begin
     //if($needSign == true &&
     //	$this->GetReturn_code($return_code) == "SUCCESS")
     if ($needSign == true && $this->GetReturn_code() == "SUCCESS") {
         $this->SetSign();
     }
     //marked by hehb for yii2 begin
     //WxpayApi::replyNotify($this->ToXml());
     return WxpayApi::replyNotify($this->ToXml());
     //end
 }
 function check_wechatpay_response()
 {
     //generate QR Code
     if (isset($_GET['QRData'])) {
         $url = $_GET['QRData'];
         Log::DEBUG('Generate WeChat QR Code:' . print_r($url, true));
         QRcode::png($url);
         exit;
     } else {
         //handle ipn callback
         $xml = $GLOBALS['HTTP_RAW_POST_DATA'];
         Log::DEBUG(' message callback.' . print_r($xml, true));
         Log::DEBUG('weChat Async IPN message callback.');
         if ($this->isWeChatIPNValid($xml)) {
             Log::DEBUG('weChat IPN is valid message.');
             Log::DEBUG('weChat Async IPN message:' . print_r($xml, true));
             $order_id = $this->ipn['attach'];
             $order = new WC_Order($order_id);
             $order->payment_complete();
             $trade_no = $this->ipn['transaction_id'];
             update_post_meta($order_id, 'WeChatPay Trade No.', wc_clean($trade_no));
             $reply = new WxPayNotifyReply();
             $reply->SetReturn_code("SUCCESS");
             $reply->SetReturn_msg("OK");
             WxpayApi::replyNotify($reply->ToXml());
         } else {
             $reply = new WxPayNotifyReply();
             $reply->SetReturn_code("FAIL");
             $reply->SetReturn_msg("OK");
             WxpayApi::replyNotify($reply->ToXml());
         }
     }
 }
Ejemplo n.º 6
0
 public function callbackWechat()
 {
     DB::beginTransaction();
     try {
         $wechat = new WechatPay();
         $wechat->log->INFO('callback start');
         $input = file_get_contents('php://input', 'r');
         $wechat->log->INFO('POSTED DATE FRON WX SERVER:' . $input);
         $re = $wechat->verifyNotify();
         $transaction_id = $re['transaction_id'];
         $re['total_fee'] = $re['total_fee'] * 0.01;
         $orders = Order::getGroupOrdersByNo($re['out_trade_no']);
         foreach ($orders as $key => $order) {
             $u_id = $order->u_id;
             $o_id = $order->o_id;
             $order->pay(WechatPay::PAYMENT_TAG);
             $order->checkoutCarts();
         }
         $wechat->_notify->SetReturn_code('SUCCESS');
         $wechat->_notify->SetReturn_msg('OK');
         $cart = Cart::where('o_id', '=', $o_id)->where('c_status', '<>', 0)->first();
         if ($cart->c_type == Cart::$TYPE_REGULAR_PRODUCT || $cart->c_type == Cart::$TYPE_FLEA_PRODUCT) {
             $log_cate = LogTransaction::$CATE_PRODUCT;
         } elseif ($cart->c_type == Cart::$TYPE_CROWD_FUNDING) {
             $log_cate = LogTransaction::$CATE_CROWDFUNDING;
         } elseif ($cart->c_type == Cart::$TYPE_AUCTION) {
             $log_cate = LogTransaction::$CATE_AUCTION;
         } else {
             $log_cate = 0;
         }
         //add transaction log
         $log = new LogTransaction();
         $log->l_type = LogTransaction::$TYPE_TRADE;
         $log->l_cate = $log_cate;
         $log->l_amt = $re['total_fee'];
         $log->from_type = LogTransaction::$OPERATOR_USER;
         $log->from_id = $u_id;
         $log->to_type = LogTransaction::$OPERATOR_QNCK;
         $log->to_id = 1;
         $log->via_type = LogTransaction::$PAYMENT_WECHAT;
         $log->transaction_id = $transaction_id;
         $log->addLog();
         if (empty($log->l_id)) {
             throw new Exception("添加交易记录失败", 2001);
         }
         $log_order = new LogTransactionOrders();
         $log_order->l_id = $log->l_id;
         $log_order->o_group_number = $re['out_trade_no'];
         $log_order->save();
         DB::commit();
     } catch (Exception $e) {
         $wechat->log->ERROR('exeception caught:' . $e->getMessage());
         $wechat->_notify->SetReturn_code('FAIL');
         $wechat->_notify->SetReturn_msg($e->getMessage());
         DB::rollback();
     }
     $re = $wechat->_notify->ToXml();
     $wechat->log->INFO('XML:' . $re);
     WxpayApi::replyNotify($re);
     exit;
 }