首页 > 解决方案 > node.js - StripeConnectionError

问题描述

最近在尝试通过 Node.js 查找 Stripe 客户或帐户时收到以下错误。

我正在使用stripe.accounts.retrievestripe.subscriptions.retrieve

{
  "type": "StripeConnectionError",
  "stack": "Error: An error occurred with our connection to Stripe\n at Constructor._Error (/var/www/w3bbi/node_modules/stripe/lib/Error.js:12:17)\n at Constructor (/var/www/w3bbi/node_modules/stripe/lib/utils.js:124:13)\n at Constructor (/var/www/w3bbi/node_modules/stripe/lib/utils.js:124:13)\n at ClientRequest. (/var/www/w3bbi/node_modules/stripe/lib/StripeResource.js:206:9)\n at emitOne (events.js:96:13)\n at ClientRequest.emit (events.js:189:7)\n at TLSSocket.socketErrorListener (_http_client.js:358:9)\n at emitOne (events.js:96:13)\n at TLSSocket.emit (events.js:189:7)\n at emitErrorNT (net.js:1280:8)\n at _combinedTickCallback (internal/process/next_tick.js:74:11)\n at process._tickDomainCallback (internal/process/next_tick.js:122:9)",
  "message": "An error occurred with our connection to Stripe",
  "detail": {
    "code": "ECONNRESET"
  },
  "raw": {
    "message": "An error occurred with our connection to Stripe",
    "detail": {
      "code": "ECONNRESET"
    }
  }
}

关于可能导致这种情况的任何想法?我刚刚在我的 Ubuntu 服务器上升级了我的 OpenSSL 包,但这似乎并没有解决问题。

此错误似乎并非每次都会发生,而是每隔几次尝试都会发生。大多数情况下,我成功检索了 Stripe 订阅或帐户,但每隔一段时间,我就会收到此错误。

我的 node.js 代码也很简单——

stripe.subscriptions.retrieve(STRIPE_SUB_ID, function(err, subscription) {
 //want to do something with subscription here, but i get err instead (only ever so often)
}) 

太感谢了!!

标签: javascriptnode.jsstripe-payments

解决方案


您可以尝试curl使用条带 API 吗?

你可以

  1. 登录到您的条带帐户
  2. 转到https://stripe.com/docs/api/curl#retrieve_customer
  3. 复制粘贴示例中的请求。它会像curl https://api.stripe.com/v1/customers/cus_DbAXqdmjzVPz2I \ -u <your private api key>
  4. 在此处粘贴您的回复

让我知道它是否正常工作,如果可以的话,您还可以分享您的节点 js 代码(省略您的密钥)。


推荐阅读