Commit c3990f6c by lixinming

no message

parent 2e762403
...@@ -17,6 +17,7 @@ import moment = require("moment"); ...@@ -17,6 +17,7 @@ import moment = require("moment");
const AppId = 'wx96c0cf11b3babcf6'; const AppId = 'wx96c0cf11b3babcf6';
const MchId = '1614605859'; const MchId = '1614605859';
const V3Key = 'c0338804d0c6a60cced9cad83a9a0402';
const pay = new WxPay({ const pay = new WxPay({
appid: AppId, appid: AppId,
mchid: MchId, mchid: MchId,
...@@ -48,9 +49,10 @@ export async function placeAnOrder({id}) { ...@@ -48,9 +49,10 @@ export async function placeAnOrder({id}) {
description:desc, description:desc,
out_trade_no,//订单号 out_trade_no,//订单号
amount:{//金额 amount:{//金额
total:orderInfo.money // total:orderInfo.money
total:0.01
}, },
notify_url:'',//测试时先设置白名单地址 notify_url:'http://7ggz2y.natappfree.cc/pay/wechart/callback',//订单回调
}; };
const result = await pay.transactions_native(Param); const result = await pay.transactions_native(Param);
if (result.status != 200) throw new BizError(ERRORENUM.调起微信支付失败); if (result.status != 200) throw new BizError(ERRORENUM.调起微信支付失败);
...@@ -94,4 +96,10 @@ export async function orderClose({id, weChartPR}) { ...@@ -94,4 +96,10 @@ export async function orderClose({id, weChartPR}) {
} }
// export async function
\ No newline at end of file /**
* 微信回调函数【微信用】
*/
export async function payCallback(body) {
console.log(body);
}
\ No newline at end of file
...@@ -39,6 +39,7 @@ export class httpServer { ...@@ -39,6 +39,7 @@ export class httpServer {
httpServer.use(watch); httpServer.use(watch);
httpServer.use(bodyParser.json({limit:"5000kb"})); httpServer.use(bodyParser.json({limit:"5000kb"}));
routers.setRouter(httpServer); routers.setRouter(httpServer);
routers.setAdditionalRouter(httpServer);//测试
httpServer.use(httpErrorHandler); httpServer.use(httpErrorHandler);
httpServer.listen(port); httpServer.listen(port);
......
/**
* 支付
*/
import * as costBiz from "../../biz/member/cost";
export const FirstName = '支付';
export const FirstRouter = '/manage/cost';
export const Config = {
"微信支付":[
{
apiName:"发起支付",
subUrl:'/fees/wechart/pay',
param:[
{key:"id", type:"String", desc:"订单id"}
],
bindBiz:costBiz.placeAnOrder
},
{
apiName:"订单查询状态",
subUrl:'/fees/wechart/find/state',
param:[
{key:"id", type:"String", desc:"订单id"},
{key:"weChartPR", type:"String", desc:"微信订单id 创建订单是下发"}
],
bindBiz:costBiz.orderState
},
{
apiName:"关闭订单",
subUrl:'/fees/wechart/close',
param:[
{key:"id", type:"String", desc:"订单id"},
{key:"weChartPR", type:"String", desc:"微信订单id 创建订单是下发"}
],
bindBiz:costBiz.orderClose
}
]
}
\ No newline at end of file
...@@ -11,9 +11,11 @@ import { eccFormParam, eccReqParamater } from "../util/verificationParam"; ...@@ -11,9 +11,11 @@ import { eccFormParam, eccReqParamater } from "../util/verificationParam";
import * as portalRouter from "./portal/router"; import * as portalRouter from "./portal/router";
import * as publicRouter from "./public/router"; import * as publicRouter from "./public/router";
import * as memberRouter from "./member/router"; import * as memberRouter from "./member/router";
import * as costRouter from "./cost/router";
import * as officalWebsiteRouter from "./officalWebsite/router"; import * as officalWebsiteRouter from "./officalWebsite/router";
import * as orderRouter from "./order/router"; import * as orderRouter from "./order/router";
import * as asyncHandler from 'express-async-handler'; import * as asyncHandler from 'express-async-handler';
import { payCallback } from "../biz/member/cost";
const Look = false;//true更新文档 const Look = false;//true更新文档
...@@ -25,12 +27,14 @@ export async function setRouter(httpServer){ ...@@ -25,12 +27,14 @@ export async function setRouter(httpServer){
await initDoc(memberRouter.FirstName, memberRouter.Config, memberRouter.FirstRouter);//用户路由 await initDoc(memberRouter.FirstName, memberRouter.Config, memberRouter.FirstRouter);//用户路由
await initDoc(officalWebsiteRouter.FirstName, officalWebsiteRouter.Config, officalWebsiteRouter.FirstRouter);//官网路由 await initDoc(officalWebsiteRouter.FirstName, officalWebsiteRouter.Config, officalWebsiteRouter.FirstRouter);//官网路由
await initDoc(orderRouter.FirstName, orderRouter.Config, orderRouter.FirstRouter);//会费相关 await initDoc(orderRouter.FirstName, orderRouter.Config, orderRouter.FirstRouter);//会费相关
await initDoc(costRouter.FirstName, costRouter.Config, costRouter.FirstRouter);//支付
} }
await analysisRouter(httpServer, portalRouter.Config, portalRouter.FirstRouter);//网站编辑 await analysisRouter(httpServer, portalRouter.Config, portalRouter.FirstRouter);//网站编辑
await analysisRouter(httpServer, publicRouter.Config, publicRouter.FirstRouter);//公用组件 await analysisRouter(httpServer, publicRouter.Config, publicRouter.FirstRouter);//公用组件
await analysisRouter(httpServer, memberRouter.Config, memberRouter.FirstRouter);//用户路由 await analysisRouter(httpServer, memberRouter.Config, memberRouter.FirstRouter);//用户路由
await analysisRouter(httpServer, officalWebsiteRouter.Config, officalWebsiteRouter.FirstRouter);//官网路由 await analysisRouter(httpServer, officalWebsiteRouter.Config, officalWebsiteRouter.FirstRouter);//官网路由
await analysisRouter(httpServer, orderRouter.Config, orderRouter.FirstRouter);//会费相关 await analysisRouter(httpServer, orderRouter.Config, orderRouter.FirstRouter);//会费相关
await analysisRouter(httpServer, costRouter.Config, costRouter.FirstRouter);//支付
} }
async function analysisRouter(httpServer, config, firstRouter) { async function analysisRouter(httpServer, config, firstRouter) {
...@@ -79,3 +83,9 @@ async function analysisRouter(httpServer, config, firstRouter) { ...@@ -79,3 +83,9 @@ async function analysisRouter(httpServer, config, firstRouter) {
} }
export async function setAdditionalRouter(httpServer) {
httpServer.post('/pay/wechart/callback', asyncHandler(async (req, res) => {
await payCallback(req.body);
res.success({});
}));
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment