问题描述
我的目标是使用react前端使用node设置条纹签出.我使用键道具映射了apiId,以遍历列表中的所有项目.但是控制台内有一个集成警告,我不确定为什么.我已将js.stripe脚本src添加到我的html文件中,所以我不明白为什么未进行API调用.
My goal is to use react front end to setup a stripe checkout using node. I mapped the apiId using the key prop to iterate over all the items in my list. But there is an integration warning inside the console and I'm not sure why. I've added the js.stripe script src into my html file so I don't understand why an API call is not being made.
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
The items
field only accepts an array of SKU/Plans and a quantity. If you're using Prices you want to use lineItems
: https://stripe.com/docs/js/checkout/redirect_to_checkout#stripe_checkout_redirect_to_checkout-options-lineItems
这篇关于未捕获的IntegrationError:无效的stripe.redirectToCheckout参数:items.0.price不是可接受的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!