HaniBlindBox/honey_box/common/server/pay.js
2026-01-03 17:01:19 +08:00

68 lines
1.8 KiB
JavaScript

/**
* 支付模块 - 微信支付、余额支付、充值相关接口
*/
import RequestManager from '../request';
import { platform } from '@/common/platform/PlatformFactory';
/**
* 微信支付
* @param {String} orderNum 订单号
* @returns {Promise} 支付参数
*/
export const wxPay = async (orderNum) => {
const postData = platform.getPayData('wxPay', { order_num: orderNum });
return await RequestManager.post('/wx_pay', postData);
};
/**
* 余额支付
* @param {String} orderNum 订单号
* @returns {Promise} 支付结果
*/
export const balancePay = async (orderNum) => {
return await RequestManager.post('/balance_pay', {
order_num: orderNum
});
};
/**
* 充值
* @param {Number} amount 充值金额
* @returns {Promise} 充值结果
*/
export const recharge = async (amount) => {
const postData = platform.getPayData('recharge', { amount });
return await RequestManager.post('/recharge', postData);
};
/**
* 获取充值配置
* @returns {Promise} 充值配置
*/
export const getRechargeConfig = async () => {
return await RequestManager.get('/recharge_config', {});
};
/**
* 创建充值订单
* @param {Object} params 充值参数
* @param {Number} params.amount 充值金额
* @param {String} params.pay_type 支付方式
* @returns {Promise} 订单信息
*/
export const createRechargeOrder = async (params = {}) => {
const postData = platform.getPayData('createRechargeOrder', params);
return await RequestManager.post('/create_recharge_order', postData);
};
/**
* 查询支付状态
* @param {String} orderNum 订单号
* @returns {Promise} 支付状态
*/
export const queryPayStatus = async (orderNum) => {
return await RequestManager.get('/query_pay_status', {
order_num: orderNum
});
};