zoukankan      html  css  js  c++  java
  • 微信回调问题

    <?php
    $xml_weixin = file_get_contents('php://input');
    $app=str_replace("<![CDATA[", "", $xml_weixin);
    $app=str_replace("]]>", "", $app);
    $xml_array=simplexml_load_string($app);
    $json=json_encode($xml_array);
    $me=json_decode($json,true);
    file_put_contents('11.txt', $me);
    //file_put_contents('11.txt', $me);
    $appid = $me['appid'];//应用ID
    $bank_type = $me['bank_type'];//付款银行
    $cash_fee = $me['cash_fee'];//现金支付金额
    $fee_type = $me['fee_type'];//货币种类
    $is_subscribe = $me['is_subscribe'];//是否关注公众账号
    $mch_id = $me['mch_id'];//商户号
    $nonce_str = $me['nonce_str'];//随机字符串
    $openid = $me['openid'];//用户标识
    $out_trade_no = $me['out_trade_no'];//商户订单号
    $result_code = $me['result_code'];//业务结果
    $return_code = $me['return_code'];//返回状态码
    $sign = $me['sign'];//签名
    $time_end = $me['time_end'];//支付完成时间
    $total_fee = $me['total_fee'];//总金额
    $trade_type = $me['trade_type'];//交易类型
    $transaction_id = $me['transaction_id'];//微信支付订单号

    //post传递的数据值
    $post_data['appid'] = $appid;
    $post_data['bank_type'] = $bank_type;
    $post_data['cash_fee'] = $cash_fee;
    $post_data['fee_type'] = $fee_type;
    $post_data['is_subscribe'] = $is_subscribe;
    $post_data['mch_id'] = $mch_id;
    $post_data['nonce_str'] = $nonce_str;
    $post_data['openid'] = $openid;
    $post_data['out_trade_no'] = $out_trade_no;
    $post_data['result_code'] = $result_code;
    $post_data['return_code'] = $return_code;
    $post_data['sign'] = $sign;
    $post_data['time_end'] = $time_end;
    $post_data['total_fee'] = $total_fee;
    $post_data['trade_type'] = $trade_type;
    $post_data['transaction_id'] = $transaction_id;

    $url = '';//调取接口匹对数据
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_POST, 1);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);//用post方法传送参数
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $response = curl_exec($ch);
    curl_close($ch);

    ?>

    调取的接口中可以做二次签名

    public function wxmessage(Request $request){
    $appid = $request->input('appid');//应用ID
    $bank_type = $request->input('bank_type');//付款银行
    $cash_fee = $request->input('cash_fee');//现金支付金额
    $fee_type = $request->input('fee_type');//货币种类
    $is_subscribe = $request->input('is_subscribe');//是否关注公众账号
    $mch_id = $request->input('mch_id');//商户号
    $nonce_str = $request->input('nonce_str');//随机字符串
    $openid = $request->input('openid');//用户标识
    $out_trade_no = $request->input('out_trade_no');//商户订单号
    $result_code = $request->input('result_code');//业务结果
    $return_code = $request->input('return_code');//返回状态码
    $sign = $request->input('sign');//签名
    $time_end = $request->input('time_end');//支付完成时间
    $total_fee = $request->input('total_fee');//总金额
    $trade_type = $request->input('trade_type');//交易类型
    $transaction_id = $request->input('transaction_id');//微信支付订单号

    //进行二次签名认证
    if($result_code == 'SUCCESS' && $return_code == 'SUCCESS'){
    $params = array(); //参加验签签名的参数数组
    $params['appid'] = $appid;
    $params['bank_type'] = $bank_type;
    $params['cash_fee'] = $cash_fee;
    $params['fee_type'] = $fee_type;
    $params['is_subscribe'] = $is_subscribe;
    $params['mch_id'] = $mch_id;
    $params['nonce_str'] = $nonce_str;
    $params['openid'] = $openid;
    $params['out_trade_no'] = $out_trade_no;
    $params['result_code'] = $result_code;
    $params['return_code'] = $return_code;
    $params['time_end'] = $time_end;
    $params['total_fee'] = $total_fee;
    $params['trade_type'] = $trade_type;
    $params['transaction_id'] = $transaction_id;

    $verify_sign = $wechatAppPay->MakeSign($params);//生成验签签名
    if($verify_sign == $sign){
    $wechatAppPay->replyNotify();//商户处理后同步返回给微信参数
    }else{
    return false;
    }
    // $wechatAppPay->replyNotify();//商户处理后同步返回给微信参数
    }else{
    return false;
    }

    }

     注意:也可以在一个php里面写,最好是一级域名和开放平台设置的一致,不然会很多坑的

  • 相关阅读:
    WindowXP 下Android 开发环境搭建
    机房收费系统个人版——DataGridView控件怎么用?
    IOS开发(64)之GCD任务最多只执行一次
    第八学 linux内核——内存寻址——段机制(2)
    Git clone远程仓库
    vi中如何跳转到指定行数
    _STORAGE_WRITE_ERROR_:./Application/Runtime/Cache/Home/f8995a0e1afcdadc637612fae5a3b585.php
    git 报错:没有权限 remote: error: unable to unlink old 'README.md' (Permission denied)
    mytop安装,使用mytop监控MySQL性能 (总结)
    一起谈.NET技术,如何解决“呈现控件时出错”的问题 狼人:
  • 原文地址:https://www.cnblogs.com/zhangmeilin/p/7326673.html
Copyright © 2011-2022 走看看