【问题标题】:error when charged { Error: No such plan: on stripe with Node JS收费时出错 { 错误:没有这样的计划:在带有 Node JS 的条带上
【发布时间】:2019-03-21 21:10:40
【问题描述】:

我正在尝试使用带条纹的节点 JS 制定每月计费计划。

我得到这个错误:

error when charged { Error: No such plan:

这是我的代码:

const keyPublishable = "pk_test_DbEg2qVxduEZaIOl03AJAKX800fGtReb3c";
const keySecret = "XXX";
app.post("/charge", async (req, res) => {
try {
    var customer = await stripe.customers.create({
        email: req.body.stripeEmail,
        source: req.body.stripeToken
    })

    await stripe.subscriptions.create({ // no point in awaiting here
        plan: 'prod_EjuGPEbcrhczeA',
        customer: customer.id
    })
    res.render("charge.pug")

在我得到的条纹日志中:

{
  "error": {
    "code": "resource_missing",
    "doc_url": "https://stripe.com/docs/error-codes/resource-missing",
    "message": "No such plan: prod_EjuGPEbcrhczeA",
    "param": "plan",
    "type": "invalid_request_error"
  }
}

我不知道自己做错了什么。

谢谢

【问题讨论】:

标签: node.js stripe-payments


【解决方案1】:

我想你使用的 id 是错误的。它是产品 ID 不是计划 ID。您需要使用 API 创建计划:https://stripe.com/docs/api/plans/create

然后使用新创建的计划的 id 来创建订阅。

【讨论】:

  • 谢谢,就像你和 Seblor 所说的,我使用了错误的计划。
猜你喜欢
  • 2019-05-20
  • 2018-11-07
  • 2019-11-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-12
相关资源
最近更新 更多