支付通路

This commit is contained in:
tianmo committed 2026-09-30 15:08:16 +08:00
1 parent c7f43e30a9
commit 85b0e70907
26 files changed
+1324 -74

No files matched your search

+19 -2
View File
@@ -20,6 +20,19 @@ function staticUrl(path) {
return config.STATIC_BASE_URL.replace(/\/+$/, '') + '/' + String(path).replace(/^\/+/, '');
}
/**
* 下单设备。平台按设备路由支付渠道(iOS 走 Apple 支付,只能用户自己找 App Store 退),
* 服务端靠这个字段判断一笔单能不能主动退款,所以下单时要一起报上去。
*/
function platform() {
try {
if (typeof wx.getDeviceInfo === 'function') return wx.getDeviceInfo().platform || 'unknown';
return wx.getSystemInfoSync().platform || 'unknown';
} catch (err) {
return 'unknown';
}
}
function normalizeError(body, statusCode) {
if (body && typeof body.code === 'number') {
return { code: body.code, message: body.message || '请求失败', requestId: body.requestId };
@@ -196,7 +209,11 @@ const api = {
// ── 订单与支付 ──────────────────────────────────────────────────────
createOrder: (courseCode) =>
request({ url: '/v1/orders', method: 'POST', data: { courseCode: courseCode } }),
request({
url: '/v1/orders',
method: 'POST',
data: { courseCode: courseCode, terminal: platform() },
}),
getOrder: (outTradeNo) => request({ url: '/v1/orders/' + outTradeNo }),
};
@@ -219,4 +236,4 @@ function requestVirtualPayment(payData) {
});
}
module.exports = Object.assign(api, { requestVirtualPayment });
module.exports = Object.assign(api, { requestVirtualPayment, devicePlatform: platform });