【发布时间】: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"
}
}
我不知道自己做错了什么。
谢谢
【问题讨论】:
-
来自this question's comments :“[
prod_EjuGPEbcrhczeA] 是产品 ID。您需要该产品的定价计划的plan_xxxID (stripe.com/docs/billing/subscriptions/products-and-plans)” -
非常感谢它成功了。就像你说的那样使用了错误的 ID。