uniapp微信支付 报错

errMsg: "requestPayment:fail parameter error: parameter.non…r.signType should be String instead of Undefined;"

requestPayment:失败参数错误:参数。非…r.signType应为字符串,而不是未定义

解决方案:

1.看后端返回的值

在控制台打印出来:后端给的是字符串   这个不是我们想要的

2.将字符串转成对象

JSON.parse(val)

let data = JSON.parse(res.msg.pary_result.data)
                             console.log(data, "data")
                            

3.将对象取出来

微信支付代码段

//获取微信支付参数信息wxPayParamInfo(payParam) {wxPayParamInfoApi({ordersid: payParam.id, //订单idshopid: payParam.shop_id, //门店id}).then(res => {if (res.msg.success) {if (res.msg.pary_result.status === "y") {// {"appId":"wx69d163dabf9b4cf6",// "timeStamp":"1653027116",// "nonceStr":"uAz6AJcHLjQlfIE5Cibl0SX9sRpWn9NZ",// "package":"prepay_id=wx20141156328918980fc211bfcffc450000",// "signType":"MD5",// "paySign":"F0B4CF170D213278FECFD896A6E8E4F3"} let data = JSON.parse(res.msg.pary_result.data)let appId = data.appId;let timeStamp = data.timeStamp;let nonceStr = data.nonceStr;let packageX = data.package;let signType = data.signType;let paySign = data.paySign;console.log(appId, "appId")console.log(timeStamp, "timeStamp")console.log(nonceStr, "nonceStr")console.log(packageX, "package")console.log(signType, "signType")console.log(paySign, "paySign")uni.requestPayment({ //下面参数为必传provider: 'wxpay', //支付类型appId: appId, //小程序AppidtimeStamp:timeStamp , //创建订单时间戳nonceStr: nonceStr,package: packageX, // 订单包signType: signType, // 加密方式统一'MD5'paySign: paySign, // 后台支付签名返回success(res) {console.log("支付成功", res)console.log("完成")if (res.errMsg === 'requestPayment:ok') {uni.showToast({title: "支付成功",icon: 'success',duration: 2000})setTimeout(() => {uni.reLaunch({ //关闭所有页面,打开到应用内的某个页面。--直接返回首页url: '/pagesCatering/views/order/order?id=' +payParam.id})}, 2000);}},fail(err) {console.log("支付失败", err)}})}}})},

唤起微信支付

3.将字符串转成字符串

JSON.stringify(val)

let dataStringify = JSON.stringify(res.msg.pary_result.data)
                             console.log(dataStringify, " 本来后端返回的是字符串又被JSON.stringify(val)转了一次,变成\\转义字符 ")

JSON.stringify(val)转成字符串

JSON.parse(val)转成对象

如果觉得可以就点个

requestPayment:fail parameter error: parameter.non…r.signType should be String instead of Undefined相关推荐

  1. showToast:fail parameter error: parameter.title should be String instead of Null;

    在搞微信小程序是遇到的这个问题 编辑器用的是hbuiderx 模拟器用的是微信开发者工具 做的是模拟一个商场首页商品展示 "封装了后台请求,并且每次请求都打印code" 涉及一个g ...

  2. 微信小程序错误readFile:fail parameter error: parameter.filePath should be String instead of Undefined;...

    小程序项目总结: 需求:有一个文件需要转发给通讯录好友. wx.downloadFile({url: that.data.fileUrl,filePath: that.data.cachePath + ...

  3. R语言使用tryCatch函数调试R代码实战:tryCatch函数运行正常R代码、tryCatch函数运行有错误(error)的R代码示例/tryCatch函数运行有警告(warning)的R代码示例

    R语言使用tryCatch函数调试R代码实战:tryCatch函数运行正常R代码.tryCatch函数运行有错误(error)的R代码示例/tryCatch函数运行有警告(warning)的R代码示例 ...

  4. 微信小程序支付异常:requestPayment:fail no permission

    微信小程序支付异常:requestPayment:fail no permission 参考文章: (1)微信小程序支付异常:requestPayment:fail no permission (2) ...

  5. ERROR: Cannot install -r requirements.txt (line 2) and tensorflow>=1.14.0 because these package vers

    pip安装时出现问题 pip install --force-reinstall -r requirements.txt ERROR: Cannot install -r requirements.t ...

  6. crsd.bin Fail With Error CRS-1019 When ohasd Restarted (文档 ID 2291799.1)

    crsd.bin Fail With Error CRS-1019 When ohasd Restarted (文档 ID 2291799.1) In this Document Symptoms C ...

  7. IMPORT/EXPORT与SET PARAMETER/GET PARAMETER简单使用

    SAP 传递参数有两种方式 传递结构/内表/变量的区别就是接收的变量类型要和传递的变量类型一直就可以了 1.IMPORT/EXPORT *ABAP内存传递*同个会话窗口使用 EXPORT LIKP_V ...

  8. R中Error in gsub(“`“, ““, x, fixed = TRUE) : input string 11 is invalid in this locale

    报错 Error in gsub("`", "", x, fixed = TRUE) :    input string 11 is invalid in th ...

  9. Error in mounted hook: “TypeError: Cannot read property ‘init‘ of undefined“

    今天在使用ECharts的时候遇到了报错: Error in mounted hook: "TypeError: Cannot read property 'init' of undefin ...

最新文章

  1. ROS的工作模式和ESXI网卡工作模式的关系
  2. Java动态代理类使用
  3. 责任链(Chain of Responsibility Pattern)
  4. python 按从小到大的顺序组合成一个字典_Python实现字典排序、按照list中字典的某个key排序的方法示例...
  5. N85通过wifi共享笔记本电脑网络的方法
  6. 有很多种方法来解决八数码
  7. postman工具 如何传递当前时间戳和MD5加密
  8. jenkins设置构建触发器
  9. nrf52840芯片入门
  10. win7系统备份还原软件_十分不错的系统还原工具 一键还原备份系统软件 一键还原备份SGIMINI4.0通用版本...
  11. 【autojs】Auto.js Pro陌陌点赞全脚本源代码
  12. 百度网盘网页端视频倍速方法
  13. Luogu P2708 硬币翻转 题解
  14. 基于51单片机篮球计分器proteus仿真设计
  15. 为什么有人说C++是最难学的编程语言? (4个回答)
  16. ssm练习第二天_项目拆分moudle_基本增删改查_批量删除_一对一级联查询
  17. 大数据计算系统 Blink 在端侧的应用实践
  18. 运用STM32对SD卡数据读取
  19. 2022-2028全球高纯硅溶胶行业调研及趋势分析报告
  20. 2.4G 无线收发芯片 XL2400 SOP8封装 射频芯片 带规格书

热门文章

  1. ubuntu 下正确安装android手机驱动
  2. 【车牌识别】基于matlab GUI阈值分割车牌识别(带面板)【含Matlab源码 721期】
  3. 开车遇暴雨请戴墨镜!快转起,很多人会感激你的!
  4. 怎样找对还有一半---第四章认识彼此 完全接纳
  5. oracle转行交流群,oracle多列转行
  6. URP Lit Shader解析(1)
  7. 必备小工具百度翻译桌面版,瞬时翻译
  8. 金融市场一周简报(2017-08-12)
  9. 分享一个蓝月传奇3D手游辅助脚本,需要的可以看一下
  10. mysql_check_MySQL中check的用法