Coder Social home page Coder Social logo

cn-pay's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cn-pay's Issues

微信支付的退款没有实现吗?

订单退款(未实现)
例子

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

文档标识未实现,微信支付的退款没有实现吗?

undefined TypeError: Cannot read property 'sign' of undefined

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("验签失败"));
    }
 }

再次发现个bug

微信支付total_fee传人9.8
转换成分变成980.0000000000001
支付失败
需要取整

19.90价格不支持

cn-pay/src/wechat/index.js line 96
params.total_fee *= 100;变成19.89.999999999浮点数

查询订单的时候验签失败

如果在统一下单里attach未填,在查询订单返回的数据里attach为空,导致验签失败
微信文档说明:如果参数的值为空不参与签名

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.