Authored by 郝肖肖

支付宝支付添加extra_common_param字段

... ... @@ -20,6 +20,10 @@ const Alibank = {
pay(user, order, param, protocol) {
let payParams = JSON.parse(param.payParams);
let extraParam = JSON.stringify({
sign_id_ext: user.uid,
defaultbank: param.bankCode || ''
});
let params = {
service: 'create_direct_pay_by_user',
... ... @@ -34,8 +38,7 @@ const Alibank = {
payment_type: '1',
defaultbank: param.bankCode,
seller_email: payParams.merchant_other_code,
sign_id_ext: user.uid,
sign_name_ext: user.username
extra_common_param: extraParam
};
// TODO 防钓鱼配置,参考php
... ... @@ -52,9 +55,9 @@ const Alibank = {
},
notify(data, param) {
let payParams = JSON.parse(param.payParams);
let outTradeNos = data.out_trade_no && data.out_trade_no.split('_');
let orderCode = parseInt(outTradeNos[0], 10);
let bankName = outTradeNos[1] && payHelpersBank.getList()[outTradeNos[1]].name || '';
let orderCode = parseInt(data.out_trade_no, 10);
let extraParam = JSON.parse(data.extra_common_param);
let bankName = payHelpersBank.getList()[extraParam.defaultbank].name || '';
logger.info(`Alibank notify, params = ${JSON.stringify(data)}`);
... ... @@ -70,7 +73,7 @@ const Alibank = {
resultMsg: data.notify_type,
payOrderCode: orderCode,
tradeNo: data.trade_no,
bankBillNo: ''
bankBillNo: data.bank_seq_no || ''
};
}
},
... ...
... ... @@ -19,7 +19,10 @@ const Alipay = {
pay(user, order, param, protocol) {
let payParams = JSON.parse(param.payParams);
let extraParam = JSON.stringify({
sign_id_ext: user.uid,
defaultbank: param.bankCode || ''
});
let params = {
service: 'create_direct_pay_by_user',
partner: payParams.merchant_id,
... ... @@ -32,8 +35,7 @@ const Alipay = {
total_fee: order.payment_amount,
payment_type: '1',
seller_email: payParams.merchant_other_code,
sign_id_ext: user.uid,
sign_name_ext: user.username
extra_common_param: extraParam
};
// TODO 防钓鱼配置,参考php
... ...
... ... @@ -7,7 +7,7 @@
'use strict';
const api = require('./pay-api');
const payApi = require('./pay-api');
const Promise = require('bluebird');
const co = Promise.coroutine;
const camelCase = global.yoho.camelCase;
... ... @@ -29,7 +29,7 @@ const payments = {
* @returns {*|Promise.<TResult>}
*/
const getOnlinePayProvider = () => {
return api.getPayProvider().then(result => {
return payApi.getPayProvider().then(result => {
let payPattern = [], nav = [];
if (!(result.code && result.code === 200)) {
... ... @@ -95,7 +95,7 @@ const getOrderInfo = (uid, code) => {
*/
const getBankByOrder = (id) => {
return co(function *() {
let data = yield api.getBankByOrder(id);
let data = yield payApi.getBankByOrder(id);
if (data && data.code === 200 && data.data) {
return camelCase(data.data);
... ... @@ -141,7 +141,7 @@ const getPayInfo = (uid, code) => {
*/
const getPaymentInfo = (id) => {
return co(function *() {
let data = yield api.getPaymentInfo(id);
let data = yield payApi.getPaymentInfo(id);
if (data && data.code === 200 && data.data) {
return camelCase(data.data);
... ... @@ -158,7 +158,7 @@ const getPaymentInfo = (id) => {
*/
const setOrderPayBank = (code, payment, bankCode) => {
return co(function *() {
let data = yield api.setOrderPayBank(code, payment, bankCode);
let data = yield payApi.setOrderPayBank(code, payment, bankCode);
return data;
})();
... ... @@ -172,7 +172,7 @@ const setOrderPayBank = (code, payment, bankCode) => {
*/
const updateOrderPayBank = (code, payment, bankCode) => {
return co(function *() {
let data = yield api.updateOrderPayBank(code, payment, bankCode);
let data = yield payApi.updateOrderPayBank(code, payment, bankCode);
return data;
})();
... ... @@ -186,7 +186,7 @@ const updateOrderPayBank = (code, payment, bankCode) => {
*/
const sendPayConfirm = (code, payment, uid) => {
return co(function *() {
let data = yield api.sendPayConfirm(code, payment, uid);
let data = yield payApi.sendPayConfirm(code, payment, uid);
return data;
})();
... ... @@ -215,7 +215,7 @@ const procOrderData = (payResult, uid) => {
if (order.is_cancel === 'Y') {
logger.warn('front pay success but order is cancel.', {payResult: payResult, order: order});
api.sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);
payApi.sendMessage(order.mobile, 'error_sms', '支付成功,但订单已取消,订单号为' + orderCode);
return {code: 417, message: '支付成功,但订单已取消,需联系客服!'};
}
... ...