收藏
回答

微信支付回调函数

h5支付回调函数url是能直接访问的,但是接收不到数据,php_ini配置也开了,postman测试,是没问题的,但是就是接收不到数据,这是怎么回事呀

回答关注问题邀请回答
收藏

2 个回答

  • 炮武
    炮武
    2020-03-20
    public function wxpay(){
    		$money2 = I('money2')*100;
    		if(!empty($money2)){
    			$money = $money2;
    		}
    		// $money= $money;                     //充值金额 微信支付单位为分
    		$userip = get_client_ip(); //获得用户设备IP
    		$appid  = "...";                  //应用APPID
    		$mch_id = "...";                  //微信支付商户号
    		$key    = "...";                 //微信商户API密钥
    		$out_trade_no = date('YmdHis').rand(1000,9999);//平台内部订单号
    		$nonce_str = createNoncestr();//随机字符串
    		$body = "H5充值";//内容
    		$total_fee = $money; //金额
    		$spbill_create_ip = $userip; //IP
    		$notify_url = "http://tt.demo88.top/Login/wxpayresult"; //回调地址
    		$trade_type = 'MWEB';//交易类型 具体看API 里面有详细介绍
    		$scene_info ='{"h5_info":{"type":"Wap","wap_url":"http://tt.demo88.top","wap_name":"支付"}}';//场景信息 必要参数
    		$signA ="appid=$appid&attach=$out_trade_no&body=$body&mch_id=$mch_id&nonce_str=$nonce_str&notify_url=$notify_url&out_trade_no=$out_trade_no&scene_info=$scene_info&spbill_create_ip=$spbill_create_ip&total_fee=$total_fee&trade_type=$trade_type";
    		$strSignTmp = $signA."&key=$key"; //拼接字符串  注意顺序微信有个测试网址 顺序按照他的来 直接点下面的校正测试 包括下面XML  是否正确
    		$sign = strtoupper(MD5($strSignTmp)); // MD5 后转换成大写
    		$post_data = "<xml>
    		                    <appid>$appid</appid>
    		                    <mch_id>$mch_id</mch_id>
    		                    <body>$body</body>
    		                    <out_trade_no>$out_trade_no</out_trade_no>
    		                    <total_fee>$total_fee</total_fee>
    		                    <spbill_create_ip>$spbill_create_ip</spbill_create_ip>
    		                    <notify_url>$notify_url</notify_url>
    		                    <trade_type>$trade_type</trade_type>
    		                    <scene_info>$scene_info</scene_info>
    		                    <attach>$out_trade_no</attach>
    		                    <nonce_str>$nonce_str</nonce_str>
    		                    <sign>$sign</sign>
    		            </xml>";//拼接成XML 格式
    		$url = "https://api.mch.weixin.qq.com/pay/unifiedorder";//微信传参地址
    		$dataxml = postXmlCurl($post_data,$url); //后台POST微信传参地址  同时取得微信返回的参数 
    		$objectxml = (array)simplexml_load_string($dataxml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
    		$objectxml['mweb_url'] = $objectxml['mweb_url'] . '&redirect_url=' . $notify_url;
    		// dump($objectxml);die;
    		if($objectxml['result_code']=='SUCCESS'){
    			$this->assign('money',$money);
    			$this->assign('objectxml',$objectxml);
    			$this->display();
    		}else{
    			$this->error('充值错误');
    		}
    
    
    	}
    
    public function wxpayresult(){
            $testxml  = file_get_contents("php://input");
            // $testxml = $GLOBALS[‘HTTP_RAW_POST_DATA’];
            dump($testxml);
            $jsonxml = json_encode(simplexml_load_string($testxml, 'SimpleXMLElement', LIBXML_NOCDATA));
            dump($jsonxml);
            $result = json_decode($jsonxml, true);//转成数组,
            dump($result);
            if($result){
                //如果成功返回了
                $out_trade_no = $result['out_trade_no'];
                        if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
          //执行业务逻辑
                            dump(123);
                        }
            }
            
    
    
        }
    

    手机网页唤醒后微信支付,成功支付点击完成后,跳转到回调函数的页面,也是回调函数中还是没有接收到数据,这是咋回事呀?

    2020-03-20
    有用
    回复
  • 微信支付技术助手8
    微信支付技术助手8
    2020-03-18

    建议你更详细描述一下你的问。提供一下你的参数以及具体截图。

    2020-03-18
    有用
    回复 1
    • 炮武
      炮武
      2020-03-20
      public function wxpay(){
        $money2 = I('money2')*100;
        if(!empty($money2)){
         $money = $money2;
        }
        // $money= $money; //充值金额 微信支付单位为分
        $userip = get_client_ip(); //获得用户设备IP
        $appid = "..."; //应用APPID
        $mch_id = "..."; //微信支付商户号
        $key = "..."; //微信商户API密钥
        $out_trade_no = date('YmdHis').rand(1000,9999);//平台内部订单号
        $nonce_str = createNoncestr();//随机字符串
        $body = "H5充值";//内容
        $total_fee = $money; //金额
        $spbill_create_ip = $userip; //IP
        $notify_url = "http://tt.demo88.top/Login/wxpayresult";; //回调地址
        $trade_type = 'MWEB';//交易类型 具体看API 里面有详细介绍
        $scene_info ='{"h5_info":{"type":"Wap","wap_url":"http://tt.demo88.top";,"wap_name":"支付"}}';//场景信息 必要参数
        $signA ="appid=$appid&attach=$out_trade_no&body=$body&mch_id=$mch_id&nonce_str=$nonce_str&notify_url=$notify_url&out_trade_no=$out_trade_no&scene_info=$scene_info&spbill_create_ip=$spbill_create_ip&total_fee=$total_fee&trade_type=$trade_type";
        $strSignTmp = $signA."&key=$key"; //拼接字符串 注意顺序微信有个测试网址 顺序按照他的来 直接点下面的校正测试 包括下面XML 是否正确
        $sign = strtoupper(MD5($strSignTmp)); // MD5 后转换成大写
        $post_data = "<xml>
                            <appid>$appid</appid>
                            <mch_id>$mch_id</mch_id>
                            <body>$body</body>
                            <out_trade_no>$out_trade_no</out_trade_no>
                            <total_fee>$total_fee</total_fee>
                            <spbill_create_ip>$spbill_create_ip</spbill_create_ip>
                            <notify_url>$notify_url</notify_url>
                            <trade_type>$trade_type</trade_type>
                            <scene_info>$scene_info</scene_info>
                            <attach>$out_trade_no</attach>
                            <nonce_str>$nonce_str</nonce_str>
                            <sign>$sign</sign>
                    </xml>";//拼接成XML 格式
        $url = "https://api.mch.weixin.qq.com/pay/unifiedorder";;//微信传参地址
        $dataxml = postXmlCurl($post_data,$url); //后台POST微信传参地址 同时取得微信返回的参数
        $objectxml = (array)simplexml_load_string($dataxml, 'SimpleXMLElement', LIBXML_NOCDATA); //将微信返回的XML 转换成数组
        $objectxml['mweb_url'] = $objectxml['mweb_url'] . '&redirect_url=' . $notify_url;
        // dump($objectxml);die;
        if($objectxml['result_code']=='SUCCESS'){
         $this->assign('money',$money);
         $this->assign('objectxml',$objectxml);
         $this->display();
        }else{
         $this->error('充值错误');
        }
       }
      public function wxpayresult(){
              $testxml = file_get_contents("php://input");
              // $testxml = $GLOBALS[‘HTTP_RAW_POST_DATA’];
              dump($testxml);
              $jsonxml = json_encode(simplexml_load_string($testxml, 'SimpleXMLElement', LIBXML_NOCDATA));
              dump($jsonxml);
              $result = json_decode($jsonxml, true);//转成数组,
              dump($result);
              if($result){
                  //如果成功返回了
                  $out_trade_no = $result['out_trade_no'];
                          if($result['return_code'] == 'SUCCESS' && $result['result_code'] == 'SUCCESS'){
            //执行业务逻辑
                              dump(123);
                          }
              }
          }
      手机网页唤醒后微信支付,成功支付点击完成后,跳转到回调函数的页面,也是回调函数中还是没有接收到数据,这是咋回事呀?
      2020-03-20
      回复
登录 后发表内容
问题标签