我在 Stripe 仪表板中创建了一个具有分级定价的产品。我复制了价格 API ID 并将它们放入我的应用程序的前端。当我运行代码时,后端生成错误:No such price: 'PRICE_1HPYAGLJZYBC5S5KGBKT8UDY'。此价格 ID 与我的 Stripe 仪表板上的价格之一匹配,但我从未设置过该产品,所以我想知道这是否是问题所在。这是我的客户端js:
function createSubscription({ customerId, paymentMethodId, priceId }) {
return (
fetch('/create-subscription', {
method: 'post',
headers: {
'Content-type': 'application/json',
},
body: JSON.stringify({
customerId: customerId,
paymentMethodId: paymentMethodId,
priceId: priceId,
}),
})
.then((response) => {
return response.json();
})
// If the card is declined, display an error to the user.
.then((result) => {
if (result.error) {
// The card had an error when trying to attach it to a …Run Code Online (Sandbox Code Playgroud)