shmy / cn-pay Goto Github PK
View Code? Open in Web Editor NEW比较好用的支付宝,微信支付node版SDK
License: MIT License
比较好用的支付宝,微信支付node版SDK
License: MIT License
订单退款(未实现)
例子
const order = {
out_trade_no: '1514027114',
out_refund_no: '1516000270202',
total_fee: 1, // 单位元
refund_fee: 1, // 单位元
refund_desc: '退款测试'
}
const result = await wechat.refund(order) // 此方法返回Promise
// APP/小程序退款
// 如果您需要退款 APP/小程序 的订单,请传入第二个字符串参数APP 或 MINIAPP
const result = await wechat.refund(order, 'APP') // APP订单 此方法返回Promise
const result = await wechat.refund(order, 'MINIAPP') // 小程序订单 此方法返回Promise
文档标识未实现,微信支付的退款没有实现吗?
TypeError: Cannot read property 'sign' of undefined
at Wechat.verify (C:\Users\Administrator\Desktop\test\node_modules\cn-pay\src\wechat\index.js:48:25)
at app.post (C:\Users\Administrator\Desktop\test\index.js:36:16)
at Layer.handle [as handle_request] (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\layer.js:95:5)
at next (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\route.js:137:13)
at Route.dispatch (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\route.js:112:3)
at Layer.handle [as handle_request] (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\layer.js:95:5)
at C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\index.js:281:22
at Function.process_params (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\index.js:335:12)
at next (C:\Users\Administrator\Desktop\test\node_modules\express\lib\router\index.js:275:10)
at expressInit (C:\Users\Administrator\Desktop\test\node_modules\express\lib\middleware\init.js:40:5)
该错误原因有express不原生支持xml parser,因此需要插件。
对于该错误可如下方式解决:
const xmlparser = require('express-xml-bodyparser');
app.post('/official_pay/tenpay_callback', xmlparser({trim: false, explicitArray: false}), function(req, res, next) {
if (wechat.verify(req.body.xml)) { // 一句话验签,就这么简单
console.log("微信支付异步验签成功:");
// 业务逻辑
res.send(wechat.success()); // 可以调用success或fail方法 返回结果
} else {
console.log("微信支付异步验签失败:");
res.send(wechat.fail("验签失败"));
}
}
您好。支付宝支付返回exception
微信支付total_fee传人9.8
转换成分变成980.0000000000001
支付失败
需要取整
Nice package!
Could you please add a type definition index.d.ts
in this package?
See:
https://www.typescriptlang.org/docs/handbook/declaration-files/dts-from-js.html
cn-pay/src/wechat/index.js line 96
params.total_fee *= 100;变成19.89.999999999浮点数
真香~~~~
如果在统一下单里attach未填,在查询订单返回的数据里attach为空,导致验签失败
微信文档说明:如果参数的值为空不参与签名
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.