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 本题的答案是不是有问题
  • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
  • ¥15 C++使用Gunplot
  • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
  • ¥15 matlab数字图像处理频率域滤波
  • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
  • ¥15 ELGamal和paillier计算效率谁快?
  • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题
  • ¥15 file converter 转换格式失败 报错 Error marking filters as finished,如何解决?
  • ¥15 Arcgis相交分析无法绘制一个或多个图形