yangfuhe / node-wxpay Goto Github PK
View Code? Open in Web Editor NEW微信支付APIv3 for nodejs
微信支付APIv3 for nodejs
请问支持小程序的支付方式吗?
JSAPI支付发起的时候
商户订单号 | out_trade_no 这个参数 不需要传吗?
微信支付接口 v3 还有海外版,url需要适配下,或者让用户传对应接口的url
海外版微信支付v3接口
https://api.mch.weixin.qq.com/hk/v3/transactions/app
境内大陆微信支付接口
https://api.mch.weixin.qq.com/v3/pay/transactions/app
或者在payment构造函数定义一个变量 oversea 布尔值变量,在构造函数中替换url;
const Payment = require("wxpay-v3");
const payment = new Payment({
appid: "xxxx",
mchid: "xxx",
private_key: require("fs")
.readFileSync("./cert/apiclient_key.pem")
.toString(), //或者直接复制证书文件内容
serial_no: "3xxxxxxxC0DFDB7CF67B901A5A5746A",
apiv3_private_key: "xxxxxx",
notify_url: "https://f.tuoyal.com/beta-api/version",
});
// const config = {
// mchid: '1633213487', // 商户号
// serial: '36DA2A3BF839A4FC0C0DFDB7CF67B901A5A5746A', // 商户API证书序列号
// privateKey: readFileSync('./cert/apiclient_key.pem'), // 商户API私钥
// publicKey: readFileSync('./cert/apiclient_cert.pem'), // 微信支付平台公钥
// appid: 'wx7331e7f65737fd9a', // 微信支付应用ID
// };
let test = async () => {
let result = await payment.app({
description: "点存云-测试支付",
out_trade_no: Date.now().toString(),
amount: {
total: 1,
},
});
console.log("result", result);
};
/Users/liuzukuan/Desktop/wechat/node_modules/wxpay-v3/lib/index.js:231
throw new Error('获取证书列表失败')
^
Error: 获取证书列表失败
at Payment.decodeCertificates (/Users/liuzukuan/Desktop/wechat/node_modules/wxpay-v3/lib/index.js:231:19)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
decodeCertificates 是异步函数
constructor({appid, mchid, private_key, serial_no,apiv3_private_key,notify_url} = {}) {
....
this.decodeCertificates(); // pending , 无法加载 certificates
}
jsapi支付只返回 prepay_id
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.