Make line item quantities adjustable
Learn how to allow your customers to adjust the quantity of items during checkout.
The line items for each Checkout Session keep track of what your customer is purchasing. You can configure the Checkout Session so customers can adjust line item quantities during checkout.
Payment Intents API
If you use the Payment Intents API, you must manually track line item updates and modify the payment amount, or by creating a new PaymentIntent with adjusted amounts.
Enable adjustable quantitiesServer-side
注
Other line item updates, such as adding new line items, aren’t supported for this integration.
Set adjustable_quantity on your line_items when creating a Checkout Session to allow your customers to update the quantity of an item during checkout.
You can customize the default settings for the minimum and maximum quantities allowed by setting adjustable_quantity.minimum and adjustable_quantity.maximum. By default, an item’s minimum adjustable quantity is 0 and the maximum adjustable quantity is 99. You can specify a value of up to 999999 for adjustable_
.
Checkout prevents the customer from removing an item if it’s the only item remaining.
Update line item quantitiesClient-side
Use updateLineItemQuantity to change a line item’s quantity in response to customer interaction, such as a button to increment the quantity. Pass the line item ID and the new quantity:
Handle completed transactionsServer-side
支払いが完了したら、確定済みの項目とその数量に対するリクエストを作成できます。顧客が項目を削除した場合、項目のレスポンスからも削除されます。完了済みの Checkout セッションを処理するイベントハンドラの作成方法については、フルフィルメントガイドをご覧ください。
注
イベントハンドラをテストするには、Stripe CLI をインストールし、stripe listen --forward-to localhost:4242/webhook
を使用してイベントをローカルサーバーに転送します。