添加新文件
This commit is contained in:
File diff suppressed because one or more lines are too long
+96
@@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
const common_vendor = require("../common/vendor.js");
|
||||
const api_payment = require("../api/payment.js");
|
||||
function appWxpayFun(alipay, orderId, orderNum) {
|
||||
const type = alipay.type;
|
||||
const orderStr = alipay.orderStr;
|
||||
if (type === "app") {
|
||||
const orderInfo = {
|
||||
"appid": alipay.appId,
|
||||
// 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
|
||||
"noncestr": alipay.nonceStr,
|
||||
// 随机字符串
|
||||
"package": "Sign=WXPay",
|
||||
// 固定值
|
||||
"partnerid": alipay.partnerId,
|
||||
// 微信支付商户号
|
||||
"prepayid": alipay.prepayId,
|
||||
// 统一下单订单号
|
||||
"timestamp": alipay.timeStamp,
|
||||
// 时间戳(单位:秒)
|
||||
"sign": alipay.sign
|
||||
// 签名,这里用的 MD5/RSA 签名
|
||||
};
|
||||
common_vendor.index.requestPayment({
|
||||
provider: "wxpay",
|
||||
orderInfo,
|
||||
success: function(res) {
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:27", "success:" + res);
|
||||
payFeedbackFun(orderId, orderNum, 1);
|
||||
jumpWayOk();
|
||||
},
|
||||
fail: function(err) {
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:32", "fail:", err);
|
||||
jumpWayError();
|
||||
}
|
||||
});
|
||||
} else if (type === "h5") {
|
||||
common_vendor.index.navigateTo({
|
||||
url: `/pages/payment_processing/payment_processing?link=${encodeURIComponent(orderStr)}&orderNum=` + orderNum
|
||||
// 假设有一个专门的支付页面来处理支付链接
|
||||
});
|
||||
}
|
||||
}
|
||||
function zfbPayFun(alipay, orderId, orderNum) {
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:50", "alipay", alipay);
|
||||
const type = alipay.type;
|
||||
const orderStr = alipay.orderStr;
|
||||
if (type === "h5") {
|
||||
common_vendor.index.navigateTo({
|
||||
url: `/pages/payment_processing/payment_processing?link=${encodeURIComponent(orderStr)}&orderNum=` + orderNum
|
||||
// 假设有一个专门的支付页面来处理支付链接
|
||||
});
|
||||
} else if (type === "app") {
|
||||
common_vendor.index.requestPayment({
|
||||
provider: "alipay",
|
||||
orderInfo: orderStr,
|
||||
success: function(res) {
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:62", "zfbPayFun res", res);
|
||||
payFeedbackFun(orderId, orderNum, 1);
|
||||
jumpWayOk();
|
||||
},
|
||||
fail: function(err) {
|
||||
common_vendor.index.__f__("error", "at utils/payUtils.js:67", "支付宝支付error", err);
|
||||
jumpWayError();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
function jumpWayOk() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/order_submit_ok/order_submit_ok"
|
||||
});
|
||||
}
|
||||
function jumpWayError() {
|
||||
common_vendor.index.navigateTo({
|
||||
url: "/pages/order_submit_error/order_submit_error"
|
||||
});
|
||||
}
|
||||
async function payFeedbackFun(orderId, orderNum, status) {
|
||||
const params = {
|
||||
orderId,
|
||||
orderNum,
|
||||
status
|
||||
};
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:102", "params", params);
|
||||
const response = await api_payment.feedback(params);
|
||||
common_vendor.index.__f__("log", "at utils/payUtils.js:104", "payFeedbackFun response", response);
|
||||
if (response && response.bizcode !== 100) {
|
||||
common_vendor.index.__f__("error", "at utils/payUtils.js:106", "反馈结果", response);
|
||||
}
|
||||
}
|
||||
exports.appWxpayFun = appWxpayFun;
|
||||
exports.jumpWayError = jumpWayError;
|
||||
exports.jumpWayOk = jumpWayOk;
|
||||
exports.zfbPayFun = zfbPayFun;
|
||||
//# sourceMappingURL=../../.sourcemap/mp-weixin/utils/payUtils.js.map
|
||||
Reference in New Issue
Block a user