hookehuyr

fix: 补全微信支付请求缺失的client_id参数

导出配置中的CLIENT_ID常量,补充微信支付API的参数说明,并在支付调用时传入该参数
......@@ -23,6 +23,7 @@ export const getHomeContentAPI = () => fn(fetch.get(Api.HOME_CONTENT))
* @description 获取微信支付参数(order_id 主支付链路)
* @param {Object} params 请求参数
* @param {string} params.order_id 支付订单 ID
* @param {string} params.client_id 客户端 ID(当前显式透传给 pay 接口)
* @returns {Promise<{code:number,data:any,msg:string}>}
*/
export const getWechatPayParamsAPI = (params) => fn(fetch.post(Api.PAY_TEST, params))
......
......@@ -3,6 +3,7 @@ import Taro from '@tarojs/taro'
import { getWechatPayParamsAPI } from '@/api'
import { clearSessionId } from '@/utils/request'
import { hasAuth, silentAuth } from '@/utils/authRedirect'
import { CLIENT_ID } from '@/utils/config'
/**
* @description 微信小程序支付能力封装
......@@ -104,7 +105,10 @@ export const useWechatMiniPay = () => {
update_result_text('正在请求支付参数...', options)
try {
const pay_res = await getWechatPayParamsAPI({ order_id: normalized_order_id })
const pay_res = await getWechatPayParamsAPI({
order_id: normalized_order_id,
client_id: CLIENT_ID,
})
if (!pay_res?.code || !pay_res?.data) {
const message = pay_res?.msg || '获取支付参数失败'
update_result_text(message, options)
......
......@@ -4,7 +4,7 @@
*/
const F = 'futian_wxamp'
const CLIENT_ID = '358209'
export const CLIENT_ID = '358209'
export const API_ENVIRONMENTS = {
production: {
......