微信退款 v2版本 invalid detail参数格式错误

本文解决了一个因参数格式错误导致的退款失败问题。具体而言,在微信支付的退款请求中,goods_detail字段内的refund_quantity值被错误地设置为字符串类型。正确的做法应当将其设为整型,并确保total_fee和refund_fee参数传递的是未减优惠券的原始金额。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

##invalid detail参数格式错误
<return_code><![CDATA[FAIL]]></return_code> <return_msg><![CDATA[invalid detail参数格式错误]]></return_msg> 错误
####

wx2421b1c4370ec43b
<mch_id>10000100</mch_id>
<nonce_str>6cefdb308e1e2e8aabd48cf79e546a02</nonce_str>
<notify_url>https://weixin.qq.com/</notify_url>
<out_refund_no>1415701182</out_refund_no>
<out_trade_no>1415757673</out_trade_no>
<refund_fee>1</refund_fee>
<total_fee>1</total_fee>
<transaction_id></transaction_id>
{“goods_detail”:[{“goods_id”:“商品编码”,“wxpay_goods_id”:“1001”,“goods_name”:“iPhone6s
16G”,“refund_amount”:528800,“refund_quantity”:1,“price”:528800},{“goods_id”:“商品编码”,“wxpay_goods_id”:“1001”,“goods_name”:“iPhone6s
16G”,“refund_amount” ":528800,“refund_quantity”:1,“price”:608800}]}</ detail>
FE56DD4AA85C0EECA82C35595A69E153

借用腾讯的数据包,数据以完全上述格式请求

    解决方案:
    需要将"refund_quantity": “2” ,把原来是字符串改成整形 "refund_quantity": 2,检测数据是否ok
    备注 :total_fee 和 refund_fee 参数需要传未减优惠券的金额
根据历史记录中的代码,我将你给我的代码进行替换,保存编译后,模拟器还出现下列错误信息,请你告诉我具体修复步骤和完整代码;报错信息如下:1、模拟器长时间没有响应,请确认你的业务逻辑中是否有复杂运算,或者死循环。2invalid app.json ["setting"] [Deprecation] SharedArrayBuffer will require cross-origin isolation as of M92, around July 2021. See https://developer.chrome.com/blog/enabling-shared-array-buffer/ for more details. [system] WeChatLib: 3.8.11 (2025.7.17 17:36:09) [system] No. of subpackages: 4 [system] LazyCodeLoading: true Lazy code loading is enabled. Only injecting required components. [wxobs] auto recording mode is not enabled in devtools. [体验分析] 为避免影响调试,开发者工具在非自定义启动模式下会启动采集。详见 https://dev.weixin.qq.com/docs/analysis/sdk/debugging.html invalid app.json ["setting"] app.js:21 应用启动失败: TypeError: this.initCloud is not a function at Rt.onLaunch (app.js:7) at Rt.<anonymous> (VM674 WASubContext.js:1) at new Rt (VM674 WASubContext.js:1) at t.<anonymous> (VM674 WASubContext.js:1) at VM674 WASubContext.js:1 at app.js:1 at VM674 WASubContext.js:1 at _.runWith (VM674 WASubContext.js:1) at q (VM674 WASubContext.js:1) at appservice.js:7(env: Windows,mp,1.06.2504010; lib: 3.8.11) onLaunch @ app.js:21 (anonymous) @ app.js:1 async function (async) (anonymous) @ appservice.app.js:5 interfacebuilder disabled invoke showToast {id: 0, duration: 2000, title: "应用启动失败", icon: "error", mask: false, …} [skyline] skyline 版本号: 1.4.0, 版本记录: 8f190450e6301587ce41e08afcaa983db4dc712e。3、我提供app.json和app.js原代码给你,请你帮我分析并进行修复,然后给我修复之后的完整的代码;app.js原代码:App({ onLaunch(options) { try { this.cloudEnvId = 'cloud1-8gtlpqtpc174de7f'; // 初始化云环境 this.initCloud(this.cloudEnvId); // 安全区域适配(使用最新API) this.initSafeArea(); // 授权获取用户信息(使用最新API) this.checkAuthStatus(); // 添加Worker安全初始化(兼容性检查) this.initWorker(); // 5秒后验证WeUI路径(避免干扰初始化) setTimeout(() => this.verifyWeuiPath(), 5000); } catch (e) { console.error('应用启动失败:', e); wx.showToast({ title: '应用启动失败', icon: 'error', duration: 2000 }); } }, // Worker安全初始化(完全兼容处理) initWorker() { console.log('-----------------------------'); console.log('Worker初始化开始...'); // 基础库版本检查 const SDKVersion = wx.getSystemInfoSync().SDKVersion; const minVersion = '2.20.1'; if (this.compareVersion(SDKVersion, minVersion) < 0) { console.warn(`基础库版本过低(${SDKVersion} < ${minVersion}),支持Worker`); this.globalData.workerAvailable = false; return; } if (typeof Worker === 'undefined' || !wx.createWorker) { console.warn('当前环境支持Worker'); this.globalData.workerAvailable = false; return; } try { this.worker = wx.createWorker('workers/index'); console.log('Worker创建成功'); this.worker.postMessage({ type: 'test', message: 'Worker通信测试' }); this.worker.onMessage((res) => { if (res.type === 'test') { console.log('收到Worker测试回复:', res); this.globalData.workerAvailable = true; } }); } catch (e) { console.error('Worker创建失败:', e); this.globalData.workerAvailable = false; } console.log('-----------------------------'); }, // 版本比较工具 compareVersion(v1, v2) { v1 = v1.split('.'); v2 = v2.split('.'); for (let i = 0; i < Math.max(v1.length, v2.length); i++) { const num1 = parseInt(v1[i] || 0, 10); const num2 = parseInt(v2[i] || 0, 10); if (num1 !== num2) return num1 - num2; } return 0; }, // 安全区域适配(使用最新API) initSafeArea() { let safeAreaInsets = { bottom: 0, top: 0, left: 0, right: 0 }; try { // 使用推荐的wx.getWindowInfo方法 if (typeof wx.getWindowInfo === 'function') { const windowInfo = wx.getWindowInfo(); safeAreaInsets = windowInfo.safeArea; } // 兼容老版本API else if (typeof wx.getSystemInfoSync === 'function') { const systemInfo = wx.getSystemInfoSync(); safeAreaInsets = systemInfo.safeArea || systemInfo.safeAreaInsets || safeAreaInsets; } // 设置全局CSS变量 this.setGlobalCssVariables(safeAreaInsets); } catch (e) { console.warn('安全区域获取失败', e); } this.globalData.safeAreaInsets = safeAreaInsets; console.log('安全区域设置完成:', safeAreaInsets); }, // 设置全局CSS变量 setGlobalCssVariables(safeAreaInsets) { try { wx.setCssVariables({ '--safe-area-inset-top': `${safeAreaInsets.top || 0}px`, '--safe-area-inset-bottom': `${safeAreaInsets.bottom || 0}px`, '--safe-area-inset-left': `${safeAreaInsets.left || 0}px`, '--safe-area-inset-right': `${safeAreaInsets.right || 0}px` }); } catch (e) { console.warn('CSS变量设置失败', e); } }, // 授权获取用户信息(兼容新老API) checkAuthStatus() { try { let authSetting = {}; // 最新推荐API if (typeof wx.getAppAuthorizeSetting === 'function') { authSetting = wx.getAppAuthorizeSetting() || {}; } // 兼容老版本API else if (typeof wx.getSetting === 'function') { const res = wx.getSetting({ sync: true }); authSetting = res.authSetting || {}; } // 最后的兼容方案 else if (typeof wx.getSettingSync === 'function') { const res = wx.getSettingSync(); authSetting = res.authSetting || {}; } if (!authSetting['scope.userInfo']) { wx.reLaunch({ url: '/pages/login/login' }); } } catch (e) { console.warn('授权状态检查失败', e); // 即使在授权失败情况下也阻止应用启动 } }, // WeUI路径验证 verifyWeuiPath() { console.log('-----------------------------'); console.log('开始验证WeUI路径...'); // 使用安全的文件系统操作 try { const fs = wx.getFileSystemManager(); const pathsToCheck = [ 'miniprogram_npm/weui-miniprogram/package.json', 'miniprogram_npm/weui-miniprogram/actionsheet/actionsheet.wxml' ]; let existsCount = 0; pathsToCheck.forEach(path => { try { fs.accessSync(path); console.log(`✅ 路径存在: ${path}`); existsCount++; } catch (accessErr) { console.warn(`❌ 路径存在: ${path}`); } }); if (existsCount === 0) { console.error('关键WeUI文件缺失!'); this.showWeuiInstallGuide(); } else if (existsCount > 1) { console.log('WeUI验证通过'); } } catch (e) { console.error('文件系统操作出错:', e); } console.log('-----------------------------'); }, // 显示WeUI安装指南(替代自动安装) showWeuiInstallGuide() { const guideMessage = ` WeUI组件未正确安装,请按以下步骤操作: 1. 打开项目目录(E:/LIANGYE99999) 2. 运行命令:npm install weui-miniprogram --save 3. 在微信开发者工具中:工具 -> 构建 npm 4. 清除缓存并重新编译 `; wx.showModal({ title: 'WeUI组件缺失', content: guideMessage, showCancel: false, confirmText: '知道了' }); console.warn(guideMessage); }, // 全局数据 globalData: { userInfo: null, unreadCount: 0, safeAreaInsets: { bottom: 0, top: 0, left: 0, right: 0 }, cloudEnvId: '', workerAvailable: false, projectPath: 'E:/LIANGYE99999' } }); app.json原代码:{ "pages": [ "pages/welcome/welcome", "pages/login/login", "pages/home/home", "pages/autoService/autoService", "pages/products/products", "pages/financeCircle/financeCircle", "pages/profile/profile", "pages/doc/upload/upload", "pages/contract/list/list", "pages/setting/setting", "pages/setting/constant/constant" ], "subPackages": [ { "root": "subpackages", "pages": [ "financeCircle/pages/publish/index", "auth/pages/realname/realname", "oa/pages/home/home", "oa/pages/todo/todo", "oa/pages/meetings/meetings", "oa/pages/approvals/approvals", "financeCircle/pages/messages/system", "financeCircle/pages/messages/finance", "financeCircle/pages/messages/interaction", "financeCircle/pages/index/index", "financeCircle/pages/publish/publish", "financeCircle/pages/detail/detail", "carWarranty/infoInput/carInfo", "carWarranty/eSign/eSign", "carWarranty/contract/templateLibrary/templateLibrary" ] }, { "root": "pages/charts", "pages": ["charts"] }, { "root": "subpages/finance", "pages": ["circle", "detail"] }, { "root": "subpages/products", "pages": ["category", "list"] } ], "window": { "backgroundColor": "#F7F9FC", "backgroundTextStyle": "light", "navigationStyle": "custom", "navigationBarBackgroundColor": "#1A3A84", "navigationBarTextStyle": "white" }, "tabBar": { "color": "#999999", "selectedColor": "#1A3A84", "backgroundColor": "#FFFFFF", "borderStyle": "white", "position": "bottom", "list": [ { "pagePath": "pages/home/home", "text": "首页", "iconPath": "images/icon/home.png", "selectedIconPath": "images/icon/home_active.png" }, { "pagePath": "pages/autoService/autoService", "text": "汽车企服", "iconPath": "images/icon/car.png", "selectedIconPath": "images/icon/car_active.png" }, { "pagePath": "pages/products/products", "text": "产品大全", "iconPath": "images/icon/product.png", "selectedIconPath": "images/icon/product_active.png" }, { "pagePath": "pages/financeCircle/financeCircle", "text": "易融圈", "iconPath": "images/icon/finance.png", "selectedIconPath": "images/icon/finance_active.png" }, { "pagePath": "pages/profile/profile", "text": "我的", "iconPath": "images/icon/user.png", "selectedIconPath": "images/icon/user_active.png" } ] }, "permission": { "scope.userLocation": { "desc": "用于展示本地服务机构" } }, "requiredPrivateInfos": ["getLocation"], "style": "v2", "sitemapLocation": "sitemap.json", "preloadRule": { "pages/home/home": { "network": "wifi", "packages": ["subpackages"] } }, "renderer": "skyline", "componentFramework": "glass-easel", "lazyCodeLoading": "requiredComponents", "rendererOptions": { "skyline": { "defaultDisplayBlock": true, "disableABTest": true, "defaultContentBox": true } }, "workers": "workers", "setting": { "minSdkVersion": "2.29.2", "urlCheck": true, "es6": true, "postcss": true, "babelSetting": { "ignore": [], "disablePlugins": [], "outputPath": "" }, "useWorker": true }, "useExtendedLib": { "weui": true } }
最新发布
07-26
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值