如何解决未捕获的IntegrationError:无效的stripe.redirectToCheckout参数:items.0.price不是可接受的参数
我的目标是使用react前端使用node设置条纹签出。我使用键道具映射了apiId,以遍历列表中的所有项目。但是控制台内部有集成警告,我不确定为什么。我已经将js.stripe脚本src添加到了我的html文件中,所以我不明白为什么没有进行API调用。
function checkout() {
stripe.redirectToCheckout({
items: items.map(item => ({
quantity: item.quantity,price: item.apiId
})),successUrl: "https://www.website.com/success",cancelUrl: "https://www.website.com/canceled",})
}
return (
<div>
<table>
<thead>
<tr>
<th>Name</th>
<th>Image</th>
<th>Quanity</th>
<th>Price</th>
</tr>
</thead>
<tbody>
{items.map((item) => (
<tr key={item.apiId}>
<td>{item.name}</td>
<td>
<img
src={`/images/${item.apiId}.jpg`}
alt={item.name}
width={180}
/>
</td>
<td>{item.quantity}</td>
<td>{formatPrice(item.price)}</td>
</tr>
))}
<tr>
<td style={{ textAlign: "right" }} colSpan={3}>
Total:
</td>
<td>{formatPrice(totalPrice(items))}</td>
</tr>
<tr>
<td style={{ textAlign: "right" }} colSpan={4}>
<button onClick={checkout}>Complete checkout</button>
</td>
</tr>
</tbody>
</table>
</div>
)
}
解决方法
items
字段仅接受SKU /计划的数组和数量。如果您使用的是价格,则要使用lineItems
:https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-lineItems
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。