qq_40433312 2017-10-09 15:40 采纳率: 0%
浏览 1675
已结题

c#.net jsapi微信支付提示缺少参数total_fee

页面

wx.config({ debug: true, // 开启调试模式,调用的所有api的返回值会在客户端alert出来,若要查看传入的参数,可以在pc端打开,参数信息会通过log打出,仅在pc端时才会打印。 appId: '<%=AppId %>', // 必填,公众号的唯一标识 timestamp: "<%=Timer %>", // 必填,生成签名的时间戳 nonceStr: "<%=RdCode %>", // 必填,生成签名的随机串 signature: "<%=GetSignature() %>", // 必填,签名,见附录1 jsApiList: ['chooseWXPay'] // 必填,需要使用的JS接口列表,所有JS接口列表见附录2 }); wx.ready(function () { wx.chooseWXPay({ appId: '<%=AppId %>', timestamp: '<%=Timer %>', nonceStr: '<%=RdCode %>', package: 'prepay_id=<%=prepay_id%>', signType: 'MD5', paySign: '<%=paySign %>', success: function (res) { }, cancel: function () { }, error: function (e) { } }); });
    后台
        public void GetprepayIdAndpaySign()
{
    //公众账号ID
    string appid = AppId;
    //商品描述
    string OrderCode = DateTime.Now.ToString("yyyyMMddHHmmss");
    string body = "订单号:" + OrderCode;
    //商户号
    string mch_id = "1262625001";
    //随机字符串
    string nonce_str = RdCode;
    //通知地址-接收微信支付成功通知
    string notify_url = "http://a.k-bean.com/notify_url.aspx";
    //用户标识 -用户在商户appid下的唯一标识
    string openid = OpenId;
    //商户订单号
    string out_trade_no = OrderCode;
    //下单IP
    string spbill_create_ip = GetIP(this.Context);
    //总金额 分为单位
    int total_fee = 1;
    //交易类型 -JSAPI、NATIVE、APP 如果是生成二维码请填写NATIVE
    string trade_type = "JSAPI";

    //微信签名





    string tmpStr = "appid=" + appid + "&body=" + body + "&mch_id=" + mch_id + "&nonce_str=" + nonce_str + "&notify_url=" + notify_url + "&openid=" + openid + "&out_trade_no=" + out_trade_no + "&spbill_create_ip=" + spbill_create_ip + "&total_fee=" + total_fee + "&trade_type=" + trade_type + "&key=" + key + "";
    string Getprepay_idSign = FormsAuthentication.HashPasswordForStoringInConfigFile(tmpStr, "MD5").ToUpper();

    string url = "https://api.mch.weixin.qq.com/pay/unifiedorder";
    string xml = "<xml>";
    xml += "<appid>" + appid + "</appid>";
    xml += "<body>" + body + "</body>";
    xml += "<mch_id>" + mch_id + "</mch_id>";
    xml += "<nonce_str>" + nonce_str + "</nonce_str>";
    xml += "<notify_url>" + notify_url + "</notify_url>";
    xml += "<openid>" + openid + "</openid>";
    xml += "<out_trade_no>" + out_trade_no + "</out_trade_no>";
    xml += "<spbill_create_ip>" + spbill_create_ip + "</spbill_create_ip>";
    xml += "<total_fee>" + total_fee + "</total_fee>";
    xml += "<trade_type>" + trade_type + "</trade_type>";
    xml += "<sign>" + Getprepay_idSign + "</sign>";
    xml += "</xml>";
    string v = PostWebRequests(url, xml);
    //获取的prepay_id
    prepay_id = v;

    //获取paySign,请对照前后台的大小写
    string v_tmpStr = "appId=" + appid + "&nonceStr=" + RdCode + "&package=prepay_id=" + v + "&signType=MD5&timeStamp=" + Timer + "&key=" + key + "";
    paySign = FormsAuthentication.HashPasswordForStoringInConfigFile(v_tmpStr, "MD5").ToUpper();
}
  • 写回答

1条回答 默认 最新

  • 专家-郭老师 Java领域新星创作者 2017-10-10 05:19
    关注

    我给你提点建议吧,提问的时候尽量代码格式化,你这个前面太乱,别人都不想看,2.提问的时候把你的报错信息发出来,配点图片更好。

    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题