Authored by 肖亚东

支付相关

... ... @@ -8,18 +8,18 @@ export default {
"yas": "https://analysis.yohobuy.com/yas_mobile",
"report": "https://app.yoho.cn/collect/v3"
},
"appid": "wx084ab813d88c594b",
"payment_code": "45",
"appid": "tt8a52fcef1578326b",
"payment_code": "68",
"private_key": "b43890b0a296ff3c7b8c260ca763980b",
"jump": {
"brand": "go.brand",
"detail": "go.detail",
"productpool": "go.poollist"
},
"mini_app_type": "0",
"mini_app_type": "64",
"client_type": "miniapp",
"business_line": "miniapp",
"os_version": "yohobuy:h5",
"app_version": "2.8.3",
"app_build": "1032"
"app_build": "3000"
}
\ No newline at end of file
... ...
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { wexinPay } from '../../utils/wxpay';
// import { wexinPay } from '../../utils/wxpay';
import { aliPay } from '../../utils/payUtil';
import { getYHStorageSync } from '../../utils/util';
import {
... ... @@ -334,7 +335,9 @@ Page({
}
}
mOrder.order_code = mCode;
wexinPay(mOrder, payParam)
// wexinPay(mOrder, payParam)
aliPay(mOrder, payParam)
},
/**
* 删除订单
... ...
import {API_HOST, SERVICE_HOST} from '../../../libs/config';
import {GET, POST} from '../../../libs/request';
import {wexinPay} from '../../../utils/wxpay';
// import {wexinPay} from '../../../utils/wxpay';
import { aliPay } from '../../../utils/payUtil';
import { getYHStorageSync, getImageUrlWithWH} from '../../../utils/util';
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode } from '../../../utils/home';
import { parseBrandListData } from '../../../utils/productList';
... ... @@ -1019,7 +1020,9 @@ Page({
let mOrder = { payment_amount};
let payParam = {};
mOrder.order_code = mCode;
wexinPay(mOrder, payParam);
// wexinPay(mOrder, payParam);
aliPay(mOrder, payParam)
// }
// }
// });
... ... @@ -1052,7 +1055,9 @@ Page({
let mOrder = json.data;
let payParam = {};
mOrder.order_code = mCode;
wexinPay(mOrder, payParam)
// wexinPay(mOrder, payParam)
aliPay(mOrder, payParam)
}
})
.catch(error => {
... ... @@ -1071,7 +1076,8 @@ Page({
}
}
mOrder.order_code = mCode;
wexinPay(mOrder, payParam)
// wexinPay(mOrder, payParam)
aliPay(mOrder, payParam)
}
},
/**
... ...
import {API_HOST, SERVICE_HOST} from '../../libs/config';
import {GET, POST} from '../../libs/request';
import {wexinPay} from '../../utils/wxpay';
// import {wexinPay} from '../../utils/wxpay';
import { aliPay } from '../../utils/payUtil';
import {
logEvent,
YB_PAGE_OPEN_L,
... ... @@ -446,7 +447,9 @@ Page({
}
}
mOrder.order_code = mCode;
wexinPay(mOrder, payParam);
// wexinPay(mOrder, payParam);
aliPay(mOrder, payParam)
// }
// }
// });
... ... @@ -465,7 +468,9 @@ Page({
}
}
mOrder.order_code = mCode;
wexinPay(mOrder, payParam)
// wexinPay(mOrder, payParam)
aliPay(mOrder, payParam)
},
/**
* 删除订单
... ...
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { wexinPay } from '../../utils/wxpay';
// import { wexinPay } from '../../utils/wxpay';
import { aliPay } from '../../utils/payUtil';
import { getYHStorageSync } from '../../utils/util';
import {
... ... @@ -52,7 +53,7 @@ Page({
payAmount: "实付金额",
finalPayment: '商品到货后需支付尾款金额',
payMentButtonTitle: "微信安全支付",
payMentButtonTitle: "支付宝安全支付",
invoiceDetailTitle: "发票信息",
invoiceDetail: "电子发票-个人",
invoiceData: null,
... ... @@ -1134,7 +1135,8 @@ Page({
// console.log(params);
if (parseInt(that.data.actualAmount) > 0) {
wexinPay(data.data)
// wexinPay(data.data)
aliPay(data.data)
} else {
tt.navigateTo({
url: "../paymentSuccessed/paymentSuccessed?orderCode=" + data.data.order_code + '&hasSuc=true' + '&price=' + parseInt(that.data.actualAmount).toFixed(2)
... ... @@ -1317,8 +1319,8 @@ Page({
}
if (parseInt(that.data.actualAmount) > 0) {
wexinPay(data.data)
} else {
// wexinPay(data.data)
aliPay } else {
tt.navigateTo({
url: "../paymentSuccessed/paymentSuccessed?orderCode=" + data.data.order_code + '&hasSuc=true' + '&price=' + parseInt(that.data.actualAmount).toFixed(2)
});
... ... @@ -1477,7 +1479,8 @@ Page({
group_no: group_no,
fromPage: that.data.from_page_name,
};
wexinPay(data.data, payParam)
// wexinPay(data.data, payParam)
aliPay(data.data, payParam)
}
} else {
tt.navigateTo({
... ...
... ... @@ -73,9 +73,9 @@ Page({
let use_red_pacakge = options.use_red_pacakge;
let open_red_package = options.open_red_package;
let value = getYHStorageSync(timestamp,'useCoupons');
let isDepositTail = options.isDepositTail;
let order_code = options.order_code;
let open_yoho_code = options.open_yoho_code;
let isDepositTail = options.isDepositTail || '';
let order_code = options.order_code || '';
let open_yoho_code = options.open_yoho_code || '';
tt.setStorageSync(timestamp, null);//清除内存
... ...
import { API_HOST, SERVICE_HOST } from '../../libs/config';
import { GET, POST } from '../../libs/request';
import { wexinPay } from '../../utils/wxpay';
// import { wexinPay } from '../../utils/wxpay';
import { aliPay } from '../../utils/payUtil';
import { getYHStorageSync } from '../../utils/util';
import {
... ... @@ -163,7 +164,8 @@ Page({
let payParam = {
isVirtual: true,
};
wexinPay(data.data,payParam);
// wexinPay(data.data,payParam);
aliPay(data.data,payParam);
} else {
tt.navigateTo({
url: "../paymentSuccessed/paymentSuccessed?orderCode=" + data.data.order_code + '&hasSuc=true' + '&price=' + that.data.shopping_cart_data.last_order_amount + '&isVirtual=true'
... ...
... ... @@ -9,7 +9,7 @@
},
"compileType": "miniprogram",
"libVersion": "2.6.5",
"appid": "wx084ab813d88c594b",
"appid": "tt8a52fcef1578326b",
"projectname": "%E6%9C%89%E8%B4%A7%E5%95%86%E5%9F%8E%E7%B2%BE%E9%80%89",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
... ...
... ... @@ -25,7 +25,7 @@ const appData = {
}
},
anotherApp: {
appId: 'wx084ab813d88c594b',
appId: 'tt8a52fcef1578326b',
page: {
home: '/pages/product/detail/detail'
}
... ...
... ... @@ -50,7 +50,7 @@ function wechatLoginAction(callbackFunc) {
//上报接口返回的结果,线上debug用
checkUnionIDExist(responseData.openid + "", responseData.unionid + "", responseData.srd_session+"", param.method)
debugger;
//保存srdSession
app.setWechatThirdSession(responseData.srd_session);
//保存openid
... ...
import { API_HOST, SERVICE_HOST, PAYMENT_CODE} from '../libs/config';
import {GET, POST} from '../libs/request';
// import tt from "./tt";
import { getYHStorageSync } from './util';
import {
logEvent,
YB_SC_PAY_RES,
} from '../libs/analytics.js'
let app = getApp();
function pay(data, payParam) {
console.log(data.payment_amount);
console.log(data.order_amount);
let wetoast = new app.WeToast();
let order_amount = data.payment_amount ? data.payment_amount : data.order_amount;
let order_code = data.order_code;
let isVirtual = payParam && payParam.isVirtual ? 'true':'false';
if(!data){
let params = {
ORDER_AMOUNT: order_amount,
PAY_TYPE: 1,
PAY_RES: 0,
ORD_NUM: order_code,
};
logEvent(YB_SC_PAY_RES, params);
tt.showModal({
content: '支付失败,请求参数不完整.',
showCancel: false,
confirmText: "确定",
})
return
}
if(!data.order_code){
let params = {
ORDER_AMOUNT: order_amount,
PAY_TYPE: 1,
PAY_RES: 0,
ORD_NUM: order_code,
};
logEvent(YB_SC_PAY_RES, params);
tt.showModal({
content: '支付失败,订单号未获取到.',
showCancel: false,
confirmText: "确定",
})
return
}
if(!app.getOpenID()){
let params = {
ORDER_AMOUNT: order_amount,
PAY_TYPE: 1,
PAY_RES: 0,
ORD_NUM: order_code,
};
logEvent(YB_SC_PAY_RES, params);
tt.showModal({
content: '支付失败,用户openID未获取到.',
showCancel: false,
confirmText: "确定",
})
return
}
tt.showToast({
title: '加载中',
icon: 'loading',
duration: 10000
})
let param = {
order_code: order_code,
payment_code: PAYMENT_CODE,
openid: app.getOpenID(),
}
GET(SERVICE_HOST+'/payment/alipay_data', param)
.then(json=>{
let jsonData = json.data;
if(jsonData){
let payParams = jsonData.payParams;
// ttPayment(payParams, data);
let paymentData = JSON.parse(payParams);
let timestampStr = paymentData.timestamp+"";
let total_amount = parseFloat(paymentData.total_amount);
//头条需要该字段为String
paymentData.timestamp = timestampStr;
//头条需要该字段为数字
paymentData.total_amount = total_amount;
tt.requestPayment({
data:paymentData,
success (res) {
let app = getApp()
//上报formID
let prepareID = paymentData.package
if (prepareID && prepareID.length > 10) {
prepareID = prepareID.slice(10)
let formIdParams = {
uid: app.getUid(),
order_code: order_code,
openId: app.globalData.openID ? app.globalData.openID : getYHStorageSync('openID','wxpay'),
miniapp_type: app.globalData.miniapp_type,
formId: prepareID,
method: 'wechat.formId.add',
formType: 'pay',
}
GET(API_HOST, formIdParams)
.then((data) => {
// console.log('responsedata', data)
})
.catch(error => {
})
}
let params = {
ORDER_AMOUNT: order_amount,
PAY_TYPE: 1,
PAY_RES: 1,
ORD_NUM: order_code,
};
logEvent(YB_SC_PAY_RES, params);
payConfirm(order_code);
//支付成功以后跳转到支付成功页
if (order_code && paymentData.fromPage == 'groupPurchaseDetail'){
tt.navigateTo({
url: "/pages/groupPurchase/groupPurchaseResult?activity_id=" + payParam.activity_id + '&group_no=' + payParam.group_no + '&page_name=' + 'statements' + '&page_param=' + ''
});
}else {
tt.navigateTo({
url: "/pages/paymentSuccessed/paymentSuccessed?orderCode=" + order_code + '&hasSuc=true' + '&price=' + parseInt(order_amount).toFixed(2) + '&isVirtual=' + 'false'
});
}
},
fail (res) {
console.log("pay fail: " + res.errMsg);
let params = {
ORDER_AMOUNT: order_amount,
PAY_TYPE: 1,
PAY_RES: 0,
ORD_NUM: order_code,
};
logEvent(YB_SC_PAY_RES, params);
if (res.errMsg=='requestPayment:fail cancel') {
tt.redirectTo({
url: '/pages/orders/orders'
})
}else{
tt.showModal({
content: res.errMsg,
showCancel: false,
confirmText: "确定",
complete: function(res) {
tt.redirectTo({
url: '/pages/orders/orders'
})
}
})
}
}
})
}
})
}
//支付确认接口
function payConfirm(orderCode){
if(!orderCode||orderCode==0){
return
}
let param = {
method:'app.SpaceOrders.payConfirm',
order_code:orderCode,
payment_id:45
}
GET(API_HOST, param)
.then(json=>{
})
}
module.exports = {
aliPay: pay,
}
... ...