# 限られた在庫の管理 Checkout セッションを期限切れにすることで、顧客がカートに在庫を保有したままになるのを防ぎます。 # ホスト型ページ > This is a ホスト型ページ for when payment-ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/checkout/managing-limited-inventory?payment-ui=stripe-hosted. 在庫に限りのある一部のビジネスでは、顧客が購入を完了せずに長時間アイテムを確保したままになるのを防ぐ必要があります。たとえば、イベントのチケット販売者は、顧客が選択したチケットを購入できる有効期限を数分間のみに制限して、期限後は販売をキャンセルしてチケットを再び販売できるようにしたいと考えます。*Checkout セッション* (A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout. After a successful payment, the Checkout Session contains a reference to the Customer, and either the successful PaymentIntent or an active Subscription)を期限切れにすることで、保留中の販売をキャンセルすることができます。 Checkout は、手動と時間指定のどちらのセッション期限切れにも対応しています。Checkout セッションを期限切れにすると、その[ステータスプロパティ](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-status)は `expired` に変わります。 ## 手動の有効期限 未処理の Checkout セッションをただちに期限切れにし、保留中の購入をキャンセルするには、[expire](https://docs.stripe.com/api/checkout/sessions/expire.md) エンドポイントを使用します。 ```curl curl -X POST https://api.stripe.com/v1/checkout/sessions/{{CHECKOUTSESSION_ID}}/expire \ -u "<>:" ``` ## 有効期限を設定 Checkout セッションの作成時に、有効期限のタイムスタンプを [expires_at](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-expires_at) パラメーターで指定します。この値は、現在時刻から 30 分後以降、24 時間以内で指定する必要があります。`expires_at` を指定しなかった場合、デフォルト値は 24 時間後になります。 #### Accounts v2 #### cURL ```bash curl https://api.stripe.com/v1/checkout/sessions \ -u <>: \ -d customer_account='{{CUSTOMER_ACCOUNT_ID}}' \ -d "line_items[0][price]"='{{PRICE_ID}}' \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d success_url="https://example.com/success" \-d expires_at="{{NOW_PLUS_TWO_HOURS}}" ``` #### Customers v1 #### cURL ```bash curl https://api.stripe.com/v1/checkout/sessions \ -u <>: \ -d customer='{{CUSTOMER_ID}}' \ -d "line_items[0][price]"='{{PRICE_ID}}' \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d success_url="https://example.com/success" \-d expires_at="{{NOW_PLUS_TWO_HOURS}}" ``` ## アイテムを在庫に戻す [Checkout セッション](https://docs.stripe.com/api/checkout/sessions.md)の期限が切れると、Stripe は `checkout.session.expired` イベントを送信します。このイベントをリッスンするように Webhook エンドポイントを設定して、Webhook ハンドラが期限切れのセッションで予約されていたアイテムを在庫に戻せるようにします。詳細については、[セッションを期限切れにする](https://docs.stripe.com/api/checkout/sessions/expire.md)のページをご覧ください。 # 埋め込みページ > This is a 埋め込みページ for when payment-ui is embedded-form. View the full page at https://docs.stripe.com/payments/checkout/managing-limited-inventory?payment-ui=embedded-form. 在庫に限りのある一部のビジネスでは、顧客が購入を完了せずに長時間アイテムを確保したままになるのを防ぐ必要があります。たとえば、イベントのチケット販売者は、顧客が選択したチケットを購入できる有効期限を数分間のみに制限して、期限後は販売をキャンセルしてチケットを再び販売できるようにしたいと考えます。*Checkout セッション* (A Checkout Session represents your customer's session as they pay for one-time purchases or subscriptions through Checkout. After a successful payment, the Checkout Session contains a reference to the Customer, and either the successful PaymentIntent or an active Subscription)を期限切れにすることで、保留中の販売をキャンセルすることができます。 Checkout は、手動と時間指定のどちらのセッション期限切れにも対応しています。Checkout セッションを期限切れにすると、その[ステータスプロパティ](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-status)は `expired` に変わります。 ## 手動の有効期限 未処理の Checkout セッションをただちに期限切れにし、保留中の購入をキャンセルするには、[expire](https://docs.stripe.com/api/checkout/sessions/expire.md) エンドポイントを使用します。 ```curl curl -X POST https://api.stripe.com/v1/checkout/sessions/{{CHECKOUTSESSION_ID}}/expire \ -u "<>:" ``` ## 有効期限を設定 Checkout セッションの作成時に、有効期限のタイムスタンプを [expires_at](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-expires_at) パラメーターで指定します。この値は、現在時刻から 30 分後以降、24 時間以内で指定する必要があります。`expires_at` を指定しなかった場合、デフォルト値は 24 時間後になります。 #### cURL ```bash curl https://api.stripe.com/v1/checkout/sessions \ -u <>: \ -d customer='{{CUSTOMER_ID}}' \ -d "line_items[0][price]"='{{PRICE_ID}}' \ -d "line_items[0][quantity]"=1 \ -d mode=payment \ -d ui_mode=embedded_page \ -d return_url="https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}" \-d expires_at="{{NOW_PLUS_TWO_HOURS}}" ``` ## アイテムを在庫に戻す [Checkout セッション](https://docs.stripe.com/api/checkout/sessions.md)の期限が切れると、Stripe は `checkout.session.expired` イベントを送信します。このイベントをリッスンするように Webhook エンドポイントを設定して、Webhook ハンドラが期限切れのセッションで予約されていたアイテムを在庫に戻せるようにします。詳細については、[セッションを期限切れにする](https://docs.stripe.com/api/checkout/sessions/expire.md)のページをご覧ください。