我正在尝试使用带有条纹的节点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"
}
}
我不知道我在做什么错。
谢谢
答案 0 :(得分:1)
我想您使用的ID是错误的。它是产品ID,而不是计划ID。您需要使用https://stripe.com/docs/api/plans/create API创建计划。
然后使用新创建的计划的ID来创建订阅。