GithubHelp home page GithubHelp logo

调用refund接口报错 about node-tenpay HOT 15 CLOSED

befinal avatar befinal commented on May 30, 2024
调用refund接口报错

from node-tenpay.

Comments (15)

befinal avatar befinal commented on May 30, 2024

升级版本试试
npm i tenpay@latest

from node-tenpay.

PanZhangOne avatar PanZhangOne commented on May 30, 2024

@befinal 升级到最新版本后,依然出现这个问题😂

from node-tenpay.

befinal avatar befinal commented on May 30, 2024

我试了一下, API没有问题.
确认一下证书配置对了吗?

from node-tenpay.

PanZhangOne avatar PanZhangOne commented on May 30, 2024

是证书配置出错了😂,麻烦了

from node-tenpay.

lzl avatar lzl commented on May 30, 2024

本地测试和部署到测试服务器时,报了和楼主发的一模一样的错,可是我没发现证书配置有什么遗漏。

pfx: require('fs').readFileSync('./apiclient_cert.p12'), // 证书文件路径

如果我修改了路径,服务器会因为找不到文件而无法启动。

@PanZhangOne 请问当时你是如何排查的。

@befinal 我在证书配置方面是否存在遗漏。

from node-tenpay.

PanZhangOne avatar PanZhangOne commented on May 30, 2024

@lzl 我们有两个公众号证书,错误地使用了另一个

from node-tenpay.

lzl avatar lzl commented on May 30, 2024

@PanZhangOne 是微信支付的API证书,对吧。

from node-tenpay.

lzl avatar lzl commented on May 30, 2024
apiclient_cert.p12
apiclient_cert.pem
apiclient_key.pem

这三个证书,应该用哪个?

from node-tenpay.

lzl avatar lzl commented on May 30, 2024

解密 wechatpy/wechatpy#312
导入 https://www.cnblogs.com/stoneniqiu/p/5585451.html

两个法子都试过了,报错依旧。

from node-tenpay.

befinal avatar befinal commented on May 30, 2024

使用P12证书.查检证书路径是不是正确,或者使用绝对路径先尝试一下

from node-tenpay.

lzl avatar lzl commented on May 30, 2024

使用绝对路径后,依然报同样的错误。

故意改动路径,会因为找不到文件而无法运行,说明原先的相对/绝对路径是正确的。

from node-tenpay.

lzl avatar lzl commented on May 30, 2024

原因找到了。

我把源码里的 this.pfx 打出来,发现是 undefined,说明证书压根没赋上。原因是我先把证书赋给了配置参数,再把配置参数传给 tenpay,可能是在这个过程中出现问题了。改为初始化时直接传给 tenpay 就好了。

const config = {
  appid: wechatConfig.appId,
  mchid: wechatConfig.mchId,
  partnerKey: wechatConfig.mchKey,
  // pfx: wechatConfig.pfs, // 这样就报错
  pfx: require('fs').readFileSync('./apiclient_cert.p12'), // 改为直接读取
  notify_url: wechatConfig.notify_url,
  refund_url: wechatConfig.refund_url,
}

from node-tenpay.

Primary-Traxex avatar Primary-Traxex commented on May 30, 2024

遇到相同的问题, @lzl 你的方法用了也是不行。
后来我直接在源码里面配置
在node_modules=>tenpay=>lib=>index.js文件里
this.pfx = require('fs').readFileSync('./apiclient_cert.p12');
就可以正常用了

from node-tenpay.

befinal avatar befinal commented on May 30, 2024

先使用一个变量保存文件buffer
然后再实例化试试。
空值的话应该是证书还没有读取完成就实例化了

from node-tenpay.

badboy-tian avatar badboy-tian commented on May 30, 2024

我今天遇到这个问题了 打印pfx是能打印东西的 虽然是乱码 找不到头绪 突发情况的

from node-tenpay.

Related Issues (20)

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.