const express = require('express'); const router = express.Router(); const OAuth = require('wechat-oauth'); const tenpay = require('tenpay'); const config = { appid: 'wxb558057b16b95dd5', mchid: '1391101602', partnerKey: 'WLfN6xZt60JL2Pj1HFb72VA48IPofN3n' }; const wechatApi = new tenpay(config); // const oauthClient = new OAuth('wxb558057b16b95dd5', '46237a17fbc57f5ebc5cc93c2b8cc505'); const oauthClient = new OAuth('wxae62986df7490c49', '68dfe0d7c768d650847b307700db04ef'); /* router.get('/', async function (req, res, next) { let result = await api.micropay({ out_trade_no: `testOrder${new Date().getTime()}`, body: 'Test order', total_fee: 100, auth_code: '46237a17fbc57f5ebc5cc93c2b8cc505' }); console.log(result); }); */ router.get('/', (req, res, next) => { let url = oauthClient.getAuthorizeURLForWebsite('http://www.1473.cn/wechatpay'); console.log(url); res.send(url); }) router.get('/wechatpay', (res, req, next) => { console.log(res); }) module.exports = router;