# 支払いを複数回キャプチャーする オーソリされた金額に達するまで、PaymentIntent を複数回キャプチャーします。 # Stripe がオンラインで提供するページ > This is a Stripe がオンラインで提供するページ for when platform is web and ui is stripe-hosted. View the full page at https://docs.stripe.com/payments/multicapture?platform=web&ui=stripe-hosted. マルチキャプチャーを実行すると、1 回の取引に対し、[CheckoutSession](https://docs.stripe.com/api/checkout_sessions.md) の確定ステップで作成された [PaymentIntent を複数回キャプチャー](https://docs.stripe.com/api/payment_intents/capture.md)できるようになります ([PaymentIntent の総額](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-amount)に達するまで)。配送が数回に分かれる注文があり、注文のフルフィルメントを部分的に実行するたびにその売上をキャプチャーしたい場合は、このマルチキャプチャーが有効です。 > #### IC+ の特長 > > マルチキャプチャーは、*IC+ 料金体系* (A pricing plan where businesses pay the variable network cost for each transaction plus the Stripe fee rather than a flat rate for all transactions. This pricing model provides more visibility into payments costs)のユーザーに提供される機能の一部です。Stripe の料金体系をご利用で、この機能へのアクセスを希望の方は、[Stripe サポート](https://support.stripe.com)のフォームからお問い合わせください。 ## サポート状況 マルチキャプチャーを行う際は、次の制限事項に注意してください。 - オンラインカード決済のみサポートしています - [capture_method](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-capture_method) を `manual` に設定します。PaymentIntent に対して複数回の部分キャプチャを実行するには、マルチキャプチャで手動キャプチャが必要です。 - アメリカン・エキスプレス、Visa、Discover、Mastercard、Cartes Bancaires、ダイナースクラブ、銀聯カード (CUP)、JCB で利用可能です。 - [source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) を使用する[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)の売上フローには対応していない - Stripe では 1 つの [PaymentIntent](https://docs.stripe.com/api/payment_intents.md) に対して最大 50 回キャプチャーできます - [CheckoutSession](https://docs.stripe.com/api/checkout/sessions/.md) で [mode](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-mode) は `payment` に設定され、[capture_method](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-payment_intent_data-capture_method) は `manual` に設定されます > #### CUP と JCB のサポート > > CUP によるマルチキャプチャーは、アメリカでのみご利用いただけます。JCB によるマルチキャプチャーは、アメリカ、カナダ、オーストラリア、ニュージーランドでのみご利用いただけます。 > #### 自動キャプチャ方式 > > 現在の API では、`request_multicapture="if_available"` は、`capture_method` が `automatic` または `automatic_async` に設定されている場合でも、エラーを返さずに受け付けられます。この場合、支払いの `multicapture.status` に `available` と表示されることがありますが、PaymentIntent は自動的に全額キャプチャされるため、複数回のキャプチャは実行できません。マルチキャプチャを使用する場合は、`capture_method` を必ず `manual` に設定してください。将来の API バージョンでは、この組み合わせに対して検証エラーが返される可能性があります。 ## ベストプラクティス 1 つの注文を複数回に分けて配送する場合は、各配送の詳細を最終顧客に事前通知するようにしてください。そうすることで、銀行取引明細書に複数の取引が表示されていることに混乱した顧客からの問い合わせやチャージバックを防止できます。顧客への通知については、以下のベストプラクティスを参考にしてください。 - 購入前の段階で、配送予定日と取引金額を顧客に通知する。 - 配送の都度、取引金額を通知する。 - 全額返金とキャンセルに関するポリシーを開示する。 新しい [CheckoutSession](https://docs.stripe.com/api/checkout_sessions.md) を作成する際、[custom_text](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-custom_text) フィールドを使用して決済ページに追加のテキストを表示することで、法令遵守要件を満たせます。 > #### 法令遵守 > > マルチキャプチャーを行うにあたり、お客様は適用されるすべての法律、規制、ネットワーク規則を遵守する責任を負うものとします。この機能を使用するカードネットワークの規則に照らし、取引の内容が適用されるすべての規則に準拠していることを確認してください。規則はネットワークごとに異なります。たとえば、ほとんどのカードネットワークでは、マルチキャプチャーの用途を個別配送される商品の販売に対するカード非提示取引に制限しています。一部のカードネットワークでは、業種 (旅行業など) によって企業のマルチキャプチャーを認めていますが、分割払いや入金のワークフローでマルチキャプチャーを行うことは認められない場合があります。 > > このページに記載されている情報のうち、これらの要件の遵守に関する情報は一般的なガイダンスであり、法律、税務、会計、その他の専門的なアドバイスではありません。自らの義務について不明な点がある場合は、専門家に相談することをお勧めします。 ## Checkout セッションを作成する サーバー側のエンドポイントを呼び出す決済ボタンをウェブサイトに追加して [Checkout セッション](https://docs.stripe.com/api/checkout/sessions/create.md)を作成します。 ```html Buy cool new product
r ``` Checkout セッションには、顧客が支払いフォームにリダイレクトされたときに表示される内容がプログラム的に表されます。セッションは、以下のオプションを使用して設定することが可能です。 - 請求[項目](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-line_items) - 利用通貨 `success_url`。お客様のウェブサイト上にあり、決済完了後に顧客が戻されるページの URL 値です。 > デフォルトでは、Checkout セッションは作成後 24 時間で期限切れとなります。 Checkout セッションを作成したら、レスポンスで返された [URL](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-url) に顧客をリダイレクトします。 最後に、[request_multicapture](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-payment_method_options-card-request_multicapture) を `if_available` に設定して、マルチキャプチャー機能を有効にします。 #### Ruby ```ruby # This example sets up an endpoint using the Sinatra framework. require 'json' require 'sinatra' require 'stripe' # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = Stripe::StripeClient.new('<>') post '/create-checkout-session' do session = client.v1.checkout.sessions.create({ line_items: [{ price_data: { currency: 'usd', product_data: { name: 'T-shirt' }, unit_amount: 2000 }, quantity: 1 }],payment_intent_data: { capture_method: 'manual' }, payment_method_options: { card: { request_multicapture: 'if_available' } }, mode: 'payment', # These placeholder URLs will be replaced in a following step. success_url: 'https://example.com/success' }) redirect session.url, 303 end ``` ### 決済手段 デフォルトでは、カードとその他の一般的な決済手段が有効になっています。[Stripe ダッシュボード](https://dashboard.stripe.com/settings/payment_methods)で個々の決済手段をオンまたはオフにできます。Checkout では、Stripe は通貨と制限事項を評価して、対応している決済手段を顧客に動的に提示します。 決済手段が顧客にどのように表示されるか確認するには、ダッシュボードで取引 ID を入力するか、または注文金額と通貨を設定します。 [決済手段の設定](https://dashboard.stripe.com/settings/payment_methods)では Apple Pay と Google Pay を有効にすることができます。デフォルトでは、Apple Pay は有効で、Google Pay は無効になっています。ただし、有効になっていても Stripe が除外する場合があります。配送先住所を収集せずに[税金の自動計算を有効にした](https://docs.stripe.com/tax/checkout.md)場合、Google Pay は除外されます。 Checkout の Stripe 上のオンラインページでは、Apple Pay や Google Pay を有効にするために実装内容を変更する必要はありません。Stripe は、これらの決済を他のカード決済と同じように処理します。 ## PaymentIntent をキャプチャーする PaymentIntent が [requires_capture 状態](https://docs.stripe.com/payments/paymentintents/lifecycle.md)で、かつマルチキャプチャーが `available` の場合、オプションの `final_capture` パラメーターを `false` に設定すると、キャプチャー用の API を呼び出す際に未キャプチャーの残額をリリースしないよう Stripe に指示が送られます。たとえば、10 USD の PaymentInent を確定した場合に、7 USD を `final_capture=false` にしてキャプチャーすると、残りの 3 USD はオーソリ状態が維持されることになります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=700 \ -d final_capture=false \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 300, // 1000 - 700 = 300 "amount_received": 700, // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 700, "amount_refunded": 0, ... } ... } ``` ## 最終キャプチャー 以下のいずれかが実行されるまで、PaymentIntent のステータスは `requires_capture` のままです。 - `final_capture` を `true` に設定する。 - `final_capture` パラメーターを使わずにキャプチャーする (`final_capture` はデフォルトで `true` に設定されているため)。 - オーソリの有効期間が切れる。 この時点で Stripe は残りの売上をリリースし、PaymentIntent のステータスが `succeeded` に変わります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=200 \ -d final_capture=true \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 0, // not 100 due to final_capture=true "amount_received": 900, // 700 + 200 = 900 // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 900, "amount_refunded": 0, ... } ... } ``` 未キャプチャーの PaymentIntent は `canceled` になりますが、一部キャプチャーされた PaymentIntent は `succeeded` になります。 ## Optional: キャプチャーされていない売上をリリースする 未キャプチャーの売上をリリースして支払いを一部キャプチャーする場合は、金額を 0 に設定し、`final_capture` を `true` にします。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=0 \ -d final_capture=true ``` これにより PaymentIntent は `succeeded` に移行し、未キャプチャーの売上はカード保有者にリリースされます。 ## 構築したシステムをテストする Stripe テストカードと任意のセキュリティコード、郵便番号、将来の日付の有効期限を使用して、マルチキャプチャーによる決済をテストします。 | 番号 | 決済手段 | 説明 | | ---------------- | ---------------------------------------------- | --------------------------------------------------- | | 4242424242424242 | `pm_card_visa` | マルチキャプチャーに対応する Visa のテストカード。 | | 4000002500001001 | `pm_card_visa_cartesBancaires` | マルチキャプチャーをサポートする Cartes Bancaires または Visa のテストカード。 | | 4000008400000076 | `pm_card_credit_disableEnterpriseCardFeatures` | マルチキャプチャーに対応していない Visa のテストカード。 | ## 返金 PaymentIntent のステータスが `requires_capture` の場合、キャプチャー合計額から返金合計額を引いた金額 ([amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) — [amount_refunded](https://docs.stripe.com/api/charges/object.md#charge_object-amount_refunded) に達するまで、何度でも[返金](https://docs.stripe.com/api/refunds.md)できます。[charge.refunded](https://docs.stripe.com/api/charges/object.md#charge_object-refunded) フィールドは、最後のキャプチャーが実行され、[amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) の全額が返金された場合にのみ `true` に移行します。 Stripe は、[refund_application_fee=true](https://docs.stripe.com/api/refunds/create.md#create_refund-refund_application_fee) または [reverse_transfer=true](https://docs.stripe.com/api/refunds/create.md#create_refund-reverse_transfer) を指定した*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。代わりに、[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用して、手数料の一部返金と送金の差戻しを手動で実行できます。application fee refund エンドポイントまたは transfer reversal エンドポイントを使用すると、Stripe は `refund_application_fee=true` または `reverse_transfer=true` の返金に対応できなくなります。 ## Connect Multicapture は、[source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) パラメーターを伴う[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)を除き、Connect のすべてのユースケースに対応します。[application_fee_amount](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-application_fee_amount) と [transfer_data[amount]](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-transfer_data-amount) パラメーターにはいくつかの追加検証があります。Multicapture を Connect に実装する際は以下の検証を考慮してください。 - 最初のキャプチャー時に `application_fee_amount` または `transfer_data[amount]` を設定した場合、後続のすべてのキャプチャーで同じ値が要求されます。キャプチャー時に渡される `application_fee_amount` または `transfer_data[amount]` は、PaymentIntent の作成、確定、更新時に渡される値を上書きします。 - Stripe は、refund_application_fee=true または reverse_transfer=true を指定したマルチキャプチャーに対する*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用すると、手数料の一部返金や送金の差戻しを実行できます。 ## Webhook ### 支払いの更新 Webhook Stripe は、支払いのキャプチャーが行われるたびに、[charge.updated](https://docs.stripe.com/api/events/types.md#event_types-charge.updated) Webhook を送信します。 たとえば、`application_fee_amount` が指定されたデスティネーション支払いをマルチキャプチャーする場合、最初のキャプチャーが行われると、Stripe はこれらの空のフィールドに値を入力します。 ```json // charge.updated { "data": { "id": "ch_xxx", "object": "charge", "amount": 1000,"balance_transaction": "txn_xxx", // applicable to all charges "transfer": "tr_xxx", // applicable to destination charges only "application_fee": "fee_xxx", // applicable to Connect only ... }, "previous_attributes": {"balance_transaction": null, // applicable to all charges "transfer": null, // applicable to destination charges only "application_fee": null, // applicable to Connect only } } ``` ### payment_intent.amount_capturable_updated Stripe は、`amount_to_capture` と `final_capture` の値に関係なく、キャプチャーのたびに [payment_intent.amount_capturable_updated](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.amount_capturable_updated) を送信します。 たとえば、10 USD の金額の PaymentIntent から 1 USD をキャプチャーすると、PaymentIntent の amount_capturable フィールドが 9 USD に更新されます。 ```json // payment_intent.amount_capturable_updated { "data": { "id": "pi_xxx", "object": "payment_intent", "amount": 1000,"amount_capturable": 900 // 1000 - 100 = 900 ... }, "previous_attributes": {"amount_capturable": 1000 } } ``` ### 支払いのキャプチャーイベント Stripe は 最後のキャプチャー、またはオーソリ期間の終了時に、未キャプチャーの金額のオーソリを差戻すために [charge.captured](https://docs.stripe.com/api/events/types.md#event_types-charge.captured) イベントを送信します。支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) フィールドは、最後のキャプチャーまたはオーソリの差戻しが終わった時にのみ `true` になります。 たとえば、`amount=0` と `final_capture=true` を指定してキャプチャーを行うと、支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) 属性は false から true に変わります。 ```json // charge.captured { "data": { "id": "ch_xxx", "object": "charge","captured": true ... }, "previous_attributes": {"captured": false } } ``` ### 返金 Webhook マルチキャプチャーの返金 Webhook は、マルチキャプチャー以外の返金 Webhook と同じです。 部分返金が行われるたびに、[refund.created](https://docs.stripe.com/api/events/types.md#event_types-refund.created) イベントが送信されます。連結アカウントの場合、これに加えてプラットフォーム手数料を返金する際には [application_fee.refunded](https://docs.stripe.com/api/events/types.md#event_types-application_fee.refunded) イベント、また送金を差戻す際には [transfer.reversed](https://docs.stripe.com/api/events/types.md#event_types-transfer.reversed) イベントも送信されます。 # 完全埋め込みページ > This is a 完全埋め込みページ for when platform is web and ui is embedded-page. View the full page at https://docs.stripe.com/payments/multicapture?platform=web&ui=embedded-page. マルチキャプチャーを実行すると、1 回の取引に対し、[CheckoutSession](https://docs.stripe.com/api/checkout_sessions.md) の確定ステップで作成された [PaymentIntent を複数回キャプチャー](https://docs.stripe.com/api/payment_intents/capture.md)できるようになります ([PaymentIntent の総額](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-amount)に達するまで)。配送が数回に分かれる注文があり、注文のフルフィルメントを部分的に実行するたびにその売上をキャプチャーしたい場合は、このマルチキャプチャーが有効です。 > #### IC+ の特長 > > マルチキャプチャーは、*IC+ 料金体系* (A pricing plan where businesses pay the variable network cost for each transaction plus the Stripe fee rather than a flat rate for all transactions. This pricing model provides more visibility into payments costs)のユーザーに提供される機能の一部です。Stripe の料金体系をご利用で、この機能へのアクセスを希望の方は、[Stripe サポート](https://support.stripe.com)のフォームからお問い合わせください。 ## サポート状況 マルチキャプチャーを行う際は、次の制限事項に注意してください。 - オンラインカード決済のみサポートしています - [capture_method](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-capture_method) を `manual` に設定します。PaymentIntent に対して複数回の部分キャプチャを実行するには、マルチキャプチャで手動キャプチャが必要です。 - アメリカン・エキスプレス、Visa、Discover、Mastercard、Cartes Bancaires、ダイナースクラブ、銀聯カード (CUP)、JCB で利用可能です。 - [source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) を使用する[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)の売上フローには対応していない - Stripe では 1 つの [PaymentIntent](https://docs.stripe.com/api/payment_intents.md) に対して最大 50 回キャプチャーできます - [CheckoutSession](https://docs.stripe.com/api/checkout/sessions/.md) で [mode](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-mode) は `payment` に設定され、[capture_method](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-payment_intent_data-capture_method) は `manual` に設定されます > #### CUP と JCB のサポート > > CUP によるマルチキャプチャーは、アメリカでのみご利用いただけます。JCB によるマルチキャプチャーは、アメリカ、カナダ、オーストラリア、ニュージーランドでのみご利用いただけます。 > #### 自動キャプチャ方式 > > 現在の API では、`request_multicapture="if_available"` は、`capture_method` が `automatic` または `automatic_async` に設定されている場合でも、エラーを返さずに受け付けられます。この場合、支払いの `multicapture.status` に `available` と表示されることがありますが、PaymentIntent は自動的に全額キャプチャされるため、複数回のキャプチャは実行できません。マルチキャプチャを使用する場合は、`capture_method` を必ず `manual` に設定してください。将来の API バージョンでは、この組み合わせに対して検証エラーが返される可能性があります。 ## ベストプラクティス 1 つの注文を複数回に分けて配送する場合は、各配送の詳細を最終顧客に事前通知するようにしてください。そうすることで、銀行取引明細書に複数の取引が表示されていることに混乱した顧客からの問い合わせやチャージバックを防止できます。顧客への通知については、以下のベストプラクティスを参考にしてください。 - 購入前の段階で、配送予定日と取引金額を顧客に通知する。 - 配送の都度、取引金額を通知する。 - 全額返金とキャンセルに関するポリシーを開示する。 新しい [CheckoutSession](https://docs.stripe.com/api/checkout_sessions.md) を作成する際、[custom_text](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-custom_text) フィールドを使用して決済ページに追加のテキストを表示することで、法令遵守要件を満たせます。 > #### 法令遵守 > > マルチキャプチャーを行うにあたり、お客様は適用されるすべての法律、規制、ネットワーク規則を遵守する責任を負うものとします。この機能を使用するカードネットワークの規則に照らし、取引の内容が適用されるすべての規則に準拠していることを確認してください。規則はネットワークごとに異なります。たとえば、ほとんどのカードネットワークでは、マルチキャプチャーの用途を個別配送される商品の販売に対するカード非提示取引に制限しています。一部のカードネットワークでは、業種 (旅行業など) によって企業のマルチキャプチャーを認めていますが、分割払いや入金のワークフローでマルチキャプチャーを行うことは認められない場合があります。 > > このページに記載されている情報のうち、これらの要件の遵守に関する情報は一般的なガイダンスであり、法律、税務、会計、その他の専門的なアドバイスではありません。自らの義務について不明な点がある場合は、専門家に相談することをお勧めします。 ## Checkout セッションを作成する サーバーから、*Checkout Session* (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) を作成し、[ui_mode](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-ui_mode) を `embedded_page` に設定します。[Checkout Session](https://docs.stripe.com/api/checkout/sessions/create.md) には、含める [line items](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-line_items) (項目) や、[currency](https://docs.stripe.com/api/checkout/sessions/object.md#checkout_session_object-currency) (通貨) などのオプションを設定できます。 自社サイトでホストされているカスタムページに顧客を戻すには、そのページの URL を [return_url](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-return_url) パラメーターに指定します。URL にテンプレート変数 `{CHECKOUT_SESSION_ID}` を含めて、戻り先ページでセッションのステータスを取得します。Checkout では、リダイレクト前にこの変数が Checkout セッション ID に自動的に置き換えられます。 [戻り先ページの設定](https://docs.stripe.com/payments/accept-a-payment.md?payment-ui=checkout&ui=embedded-page#return-page)と、[リダイレクト動作をカスタマイズ](https://docs.stripe.com/payments/checkout/custom-success-page.md?payment-ui=embedded-page)するためのその他のオプションについて、詳細をご覧ください。 Checkout セッションの作成後、レスポンスで返される `client_secret` を使用して、[Checkout をマウント](https://docs.stripe.com/payments/multicapture.md#mount-checkout)します。 マルチキャプチャー機能を有効にするには、[request_multicapture](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-payment_method_options-card-request_multicapture) を `if_available` に設定します。 #### Ruby ```ruby # This example sets up an endpoint using the Sinatra framework. require 'json' require 'sinatra' require 'stripe' # Don't put any keys in code. See https://docs.stripe.com/keys-best-practices. # Find your keys at https://dashboard.stripe.com/apikeys. client = Stripe::StripeClient.new('<>') post '/create-checkout-session' do session = client.v1.checkout.sessions.create({ line_items: [{ price_data: { currency: 'usd', product_data: { name: 'T-shirt', }, unit_amount: 2000, }, quantity: 1, }], mode: 'payment', ui_mode: 'embedded_page',payment_method_options: { card: { request_multicapture: 'if_available', }, }, return_url: 'https://example.com/checkout/return?session_id={CHECKOUT_SESSION_ID}' }) {clientSecret: session.client_secret}.to_json end ``` ### 決済手段 デフォルトでは、カードとその他の一般的な決済手段が有効になっています。[Stripe ダッシュボード](https://dashboard.stripe.com/settings/payment_methods)で個々の決済手段をオンまたはオフにできます。Checkout では、Stripe は通貨と制限事項を評価して、対応している決済手段を顧客に動的に提示します。 決済手段が顧客にどのように表示されるか確認するには、ダッシュボードで取引 ID を入力するか、または注文金額と通貨を設定します。 [決済手段の設定](https://dashboard.stripe.com/settings/payment_methods)では Apple Pay と Google Pay を有効にすることができます。デフォルトでは、Apple Pay は有効で、Google Pay は無効になっています。ただし、有効になっていても Stripe が除外する場合があります。配送先住所を収集せずに[税金の自動計算を有効にした](https://docs.stripe.com/tax/checkout.md)場合、Google Pay は除外されます。 Checkout の Stripe 上のオンラインページでは、Apple Pay や Google Pay を有効にするために実装内容を変更する必要はありません。Stripe は、これらの決済を他のカード決済と同じように処理します。 ## Checkout をマウントする #### HTML + JS Checkout は [Stripe.js](https://docs.stripe.com/js.md) の一部として利用できます。HTML ファイルのヘッダーに Stripe.js スクリプトを追加してページに含めます。次に、マウンティングに使用する空の DOM ノード (コンテナー) を作成します。 ```html
``` 公開可能な API キーで Stripe.js を初期化します。 Checkout セッションの作成、および client secret の取得をサーバーにリクエストする、非同期の `fetchClientSecret` 関数を作成します。 Checkout インスタンスを作成する際に、この関数を `options` に渡します。 ```javascript // Initialize Stripe.js const stripe = Stripe('<>'); initialize(); // Fetch Checkout Session and retrieve the client secret async function initialize() { const fetchClientSecret = async () => { const response = await fetch("/create-checkout-session", { method: "POST", }); const { clientSecret } = await response.json(); return clientSecret; }; // Initialize Checkout const checkout = await stripe.createEmbeddedCheckoutPage({ fetchClientSecret, }); // Mount Checkout checkout.mount('#checkout'); } ``` #### React npm から [react-stripe-js](https://docs.stripe.com/sdks/stripejs-react.md) と Stripe.js ローダーをインストールします。 ```bash npm install --save @stripe/react-stripe-js @stripe/stripe-js ``` 埋め込みの Checkout コンポーネントを使用するには、`EmbeddedCheckoutProvider` を作成します。公開可能 API キーを使用して `loadStripe` を呼び出し、返された `Promise` をプロバイダーに渡します。 Checkout セッションの作成、および client secret の取得をサーバーにリクエストする、非同期の `fetchClientSecret` 関数を作成します。この関数をプロバイダーで受け入れられる `options` プロパティに渡します。 ```jsx import * as React from 'react'; import {loadStripe} from '@stripe/stripe-js'; import { EmbeddedCheckoutProvider, EmbeddedCheckout } from '@stripe/react-stripe-js'; // Make sure to call `loadStripe` outside of a component’s render to avoid // recreating the `Stripe` object on every render. const stripePromise = loadStripe('pk_test_123'); const App = () => { const fetchClientSecret = React.useCallback(() => { // Create a Checkout Session return fetch("/create-checkout-session", { method: "POST", }) .then((res) => res.json()) .then((data) => data.clientSecret); }, []); const options = {fetchClientSecret}; return (
) } ``` Checkout は、HTTPS 接続を介して支払い情報をStripeに安全に送信する iframe でレンダリングされます。 > 一部の支払い方法では、別のページにリダイレクトして支払いを確定する必要があるため、Checkout は別の iframe 内に配置しないでください。 ### デザインをカスタマイズする アカウントの[ブランディング設定](https://dashboard.stripe.com/settings/branding)で、背景色、ボタンの色、枠線の角丸半径、フォントを設定して、サイトのデザインに合わせて Checkout をカスタマイズします。 デフォルトでは、Checkout は外側に余白やマージンが追加されずに表示されます。必要なマージンを適用するには (四方すべてに 16px など)、目的の余白を適用するコンテナー要素 (div など) を使用することをお勧めします。 ## 戻り先ページを表示する 顧客が決済を試みた後、Stripe はお客様のサイトでホストしているリターンページに顧客をリダイレクトします。Checkout Session の作成時に、[return_url](https://docs.stripe.com/api/checkout/sessions/create.md#create_checkout_session-return_url) パラメーターでリターンページの URL を指定します。[リダイレクト動作のカスタマイズ](https://docs.stripe.com/payments/checkout/custom-success-page.md?payment-ui=embedded-page)に関するその他のオプションについて詳しくは、こちらを参照してください。 戻り先ページを表示する際は、URL に含まれる Checkout セッション ID を使用して、Checkout セッションのステータスを取得します。セッションのステータスに応じて、結果を次のように処理します。 - `complete`:支払いが成功しました。Checkout セッションの情報を成功ページに表示します。 - `open`:支払いが失敗したか、またはキャンセルされました。顧客が再試行できるように Checkout を再マウントしてください。 #### Ruby ```ruby get '/session-status' do session = client.v1.checkout.sessions.retrieve(params[:session_id]) {status: session.status, customer_email: session.customer_details.email}.to_json end ``` ```javascript const session = await fetch(`/session_status?session_id=${session_id}`) if (session.status == 'open') { // Remount embedded Checkout } else if (session.status == 'complete') { // Show success page // Optionally use session.payment_status or session.customer_email // to customize the success page } ``` #### リダイレクトベースの決済手段 決済手段によっては、決済中に顧客が銀行のオーソリページなどの中間ページにリダイレクトされることがあります。顧客はそのページでアクションを完了すると、戻り先ページにリダイレクトされます。 [リダイレクトベースの決済手段とリダイレクト動作](https://docs.stripe.com/payments/checkout/custom-success-page.md?payment-ui=embedded-page#redirect-based-payment-methods)について詳しくはこちら。 ## PaymentIntent をキャプチャーする PaymentIntent が [requires_capture 状態](https://docs.stripe.com/payments/paymentintents/lifecycle.md)で、かつマルチキャプチャーが `available` の場合、オプションの `final_capture` パラメーターを `false` に設定すると、キャプチャー用の API を呼び出す際に未キャプチャーの残額をリリースしないよう Stripe に指示が送られます。たとえば、10 USD の PaymentInent を確定した場合に、7 USD を `final_capture=false` にしてキャプチャーすると、残りの 3 USD はオーソリ状態が維持されることになります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=700 \ -d final_capture=false \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 300, // 1000 - 700 = 300 "amount_received": 700, // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 700, "amount_refunded": 0, ... } ... } ``` ## 最終キャプチャー 以下のいずれかが実行されるまで、PaymentIntent のステータスは `requires_capture` のままです。 - `final_capture` を `true` に設定する。 - `final_capture` パラメーターを使わずにキャプチャーする (`final_capture` はデフォルトで `true` に設定されているため)。 - オーソリの有効期間が切れる。 この時点で Stripe は残りの売上をリリースし、PaymentIntent のステータスが `succeeded` に変わります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=200 \ -d final_capture=true \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 0, // not 100 due to final_capture=true "amount_received": 900, // 700 + 200 = 900 // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 900, "amount_refunded": 0, ... } ... } ``` 未キャプチャーの PaymentIntent は `canceled` になりますが、一部キャプチャーされた PaymentIntent は `succeeded` になります。 ## Optional: キャプチャーされていない売上をリリースする 未キャプチャーの売上をリリースして支払いを一部キャプチャーする場合は、金額を 0 に設定し、`final_capture` を `true` にします。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=0 \ -d final_capture=true ``` これにより PaymentIntent は `succeeded` に移行し、未キャプチャーの売上はカード保有者にリリースされます。 ## 構築したシステムをテストする Stripe テストカードと任意のセキュリティコード、郵便番号、将来の日付の有効期限を使用して、マルチキャプチャーによる決済をテストします。 | 番号 | 決済手段 | 説明 | | ---------------- | ---------------------------------------------- | --------------------------------------------------- | | 4242424242424242 | `pm_card_visa` | マルチキャプチャーに対応する Visa のテストカード。 | | 4000002500001001 | `pm_card_visa_cartesBancaires` | マルチキャプチャーをサポートする Cartes Bancaires または Visa のテストカード。 | | 4000008400000076 | `pm_card_credit_disableEnterpriseCardFeatures` | マルチキャプチャーに対応していない Visa のテストカード。 | ## 返金 PaymentIntent のステータスが `requires_capture` の場合、キャプチャー合計額から返金合計額を引いた金額 ([amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) — [amount_refunded](https://docs.stripe.com/api/charges/object.md#charge_object-amount_refunded) に達するまで、何度でも[返金](https://docs.stripe.com/api/refunds.md)できます。[charge.refunded](https://docs.stripe.com/api/charges/object.md#charge_object-refunded) フィールドは、最後のキャプチャーが実行され、[amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) の全額が返金された場合にのみ `true` に移行します。 Stripe は、[refund_application_fee=true](https://docs.stripe.com/api/refunds/create.md#create_refund-refund_application_fee) または [reverse_transfer=true](https://docs.stripe.com/api/refunds/create.md#create_refund-reverse_transfer) を指定した*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。代わりに、[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用して、手数料の一部返金と送金の差戻しを手動で実行できます。application fee refund エンドポイントまたは transfer reversal エンドポイントを使用すると、Stripe は `refund_application_fee=true` または `reverse_transfer=true` の返金に対応できなくなります。 ## Connect Multicapture は、[source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) パラメーターを伴う[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)を除き、Connect のすべてのユースケースに対応します。[application_fee_amount](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-application_fee_amount) と [transfer_data[amount]](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-transfer_data-amount) パラメーターにはいくつかの追加検証があります。Multicapture を Connect に実装する際は以下の検証を考慮してください。 - 最初のキャプチャー時に `application_fee_amount` または `transfer_data[amount]` を設定した場合、後続のすべてのキャプチャーで同じ値が要求されます。キャプチャー時に渡される `application_fee_amount` または `transfer_data[amount]` は、PaymentIntent の作成、確定、更新時に渡される値を上書きします。 - Stripe は、refund_application_fee=true または reverse_transfer=true を指定したマルチキャプチャーに対する*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用すると、手数料の一部返金や送金の差戻しを実行できます。 ## Webhook ### 支払いの更新 Webhook Stripe は、支払いのキャプチャーが行われるたびに、[charge.updated](https://docs.stripe.com/api/events/types.md#event_types-charge.updated) Webhook を送信します。 たとえば、`application_fee_amount` が指定されたデスティネーション支払いをマルチキャプチャーする場合、最初のキャプチャーが行われると、Stripe はこれらの空のフィールドに値を入力します。 ```json // charge.updated { "data": { "id": "ch_xxx", "object": "charge", "amount": 1000,"balance_transaction": "txn_xxx", // applicable to all charges "transfer": "tr_xxx", // applicable to destination charges only "application_fee": "fee_xxx", // applicable to Connect only ... }, "previous_attributes": {"balance_transaction": null, // applicable to all charges "transfer": null, // applicable to destination charges only "application_fee": null, // applicable to Connect only } } ``` ### payment_intent.amount_capturable_updated Stripe は、`amount_to_capture` と `final_capture` の値に関係なく、キャプチャーのたびに [payment_intent.amount_capturable_updated](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.amount_capturable_updated) を送信します。 たとえば、10 USD の金額の PaymentIntent から 1 USD をキャプチャーすると、PaymentIntent の amount_capturable フィールドが 9 USD に更新されます。 ```json // payment_intent.amount_capturable_updated { "data": { "id": "pi_xxx", "object": "payment_intent", "amount": 1000,"amount_capturable": 900 // 1000 - 100 = 900 ... }, "previous_attributes": {"amount_capturable": 1000 } } ``` ### 支払いのキャプチャーイベント Stripe は 最後のキャプチャー、またはオーソリ期間の終了時に、未キャプチャーの金額のオーソリを差戻すために [charge.captured](https://docs.stripe.com/api/events/types.md#event_types-charge.captured) イベントを送信します。支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) フィールドは、最後のキャプチャーまたはオーソリの差戻しが終わった時にのみ `true` になります。 たとえば、`amount=0` と `final_capture=true` を指定してキャプチャーを行うと、支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) 属性は false から true に変わります。 ```json // charge.captured { "data": { "id": "ch_xxx", "object": "charge","captured": true ... }, "previous_attributes": {"captured": false } } ``` ### 返金 Webhook マルチキャプチャーの返金 Webhook は、マルチキャプチャー以外の返金 Webhook と同じです。 部分返金が行われるたびに、[refund.created](https://docs.stripe.com/api/events/types.md#event_types-refund.created) イベントが送信されます。連結アカウントの場合、これに加えてプラットフォーム手数料を返金する際には [application_fee.refunded](https://docs.stripe.com/api/events/types.md#event_types-application_fee.refunded) イベント、また送金を差戻す際には [transfer.reversed](https://docs.stripe.com/api/events/types.md#event_types-transfer.reversed) イベントも送信されます。 # 高度な連携機能 > This is a 高度な連携機能 for when platform is web and ui is elements. View the full page at https://docs.stripe.com/payments/multicapture?platform=web&ui=elements. マルチキャプチャーを実行すると、1 件のオーソリに対して複数回 [PaymentIntent のキャプチャー](https://docs.stripe.com/api/payment_intents/capture.md)を行えるようになります ([PaymentIntent の総額](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-amount)に達するまで)。配送が数回に分かれる注文があり、注文のフルフィルメントを部分的に実行するたびにその売上をキャプチャーしたい場合は、このマルチキャプチャーが有効です。 > #### IC+ の特長 > > マルチキャプチャーは、*IC+ 料金体系* (A pricing plan where businesses pay the variable network cost for each transaction plus the Stripe fee rather than a flat rate for all transactions. This pricing model provides more visibility into payments costs)のユーザーに提供される機能の一部です。Stripe の料金体系をご利用で、この機能へのアクセスを希望の方は、[Stripe サポート](https://support.stripe.com)のフォームからお問い合わせください。 ## サポート状況 マルチキャプチャーを行う際は、次の制限事項に注意してください。 - オンラインカード決済のみサポートしています - [capture_method](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-capture_method) を `manual` に設定します。PaymentIntent に対して複数回の部分キャプチャを実行するには、マルチキャプチャで手動キャプチャが必要です。 - アメリカン・エキスプレス、Visa、Discover、Mastercard、Cartes Bancaires、ダイナースクラブ、銀聯カード (CUP)、JCB で利用可能です。 - [source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) を使用する[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)の売上フローには対応していない - Stripe では 1 つの [PaymentIntent](https://docs.stripe.com/api/payment_intents.md) に対して最大 50 回キャプチャーできます > #### CUP と JCB のサポート > > CUP によるマルチキャプチャーは、アメリカでのみご利用いただけます。JCB によるマルチキャプチャーは、アメリカ、カナダ、オーストラリア、ニュージーランドでのみご利用いただけます。 > #### 自動キャプチャ方式 > > 現在の API では、`request_multicapture="if_available"` は、`capture_method` が `automatic` または `automatic_async` に設定されている場合でも、エラーを返さずに受け付けられます。この場合、支払いの `multicapture.status` に `available` と表示されることがありますが、PaymentIntent は自動的に全額キャプチャされるため、複数回のキャプチャは実行できません。マルチキャプチャを使用する場合は、`capture_method` を必ず `manual` に設定してください。将来の API バージョンでは、この組み合わせに対して検証エラーが返される可能性があります。 ## ベストプラクティス 1 つの注文を複数回に分けて配送する場合は、各配送の詳細を最終顧客に事前通知するようにしてください。そうすることで、銀行取引明細書に複数の取引が表示されていることに混乱した顧客からの問い合わせやチャージバックを防止できます。顧客への通知については、以下のベストプラクティスを参考にしてください。 - 購入前の段階で、配送予定日と取引金額を顧客に通知する。 - 配送の都度、取引金額を通知する。 - 全額返金とキャンセルに関するポリシーを開示する。 > #### 法令遵守 > > マルチキャプチャーを行うにあたり、お客様は適用されるすべての法律、規制、ネットワーク規則を遵守する責任を負うものとします。この機能を使用するカードネットワークの規則に照らし、取引の内容が適用されるすべての規則に準拠していることを確認してください。規則はネットワークごとに異なります。たとえば、ほとんどのカードネットワークでは、マルチキャプチャーの用途を個別配送される商品の販売に対するカード非提示取引に制限しています。一部のカードネットワークでは、業種 (旅行業など) によって企業のマルチキャプチャーを認めていますが、分割払いや入金のワークフローでマルチキャプチャーを行うことは認められない場合があります。 > > このページに記載されている情報のうち、これらの要件の遵守に関する情報は一般的なガイダンスであり、法律、税務、会計、その他の専門的なアドバイスではありません。自らの義務について不明な点がある場合は、専門家に相談することをお勧めします。 ## 未キャプチャー分の PaymentIntent を作成して確定する オーソリとキャプチャーを個別に行うことを示すには、PaymentIntent の作成時に [capture_method](https://docs.stripe.com/api/payment_intents/create.md#create_payment_intent-capture_method) を `manual` として指定します。オーソリとキャプチャーの分離について、詳細は[支払い方法を保留する方法](https://docs.stripe.com/payments/place-a-hold-on-a-payment-method.md)をご覧ください。 `if_available` または `never` パラメーターを使用し、この支払いに対して Multicapture をリクエストします。 - `if_available`: 作成される PaymentIntent では、支払い方法が対応している場合に、複数回のキャプチャーが許可されます。 - `never`: 作成される PaymentIntent では、複数回のキャプチャーが許可されません ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1000 \ -d currency=usd \ -d "payment_method_types[]=card" \ -d payment_method=pm_card_visa \ -d confirm=true \ -d capture_method=manual \ -d "expand[]=latest_charge" \ -d "payment_method_options[card][request_multicapture]=if_available" ``` レスポンスでは、[latest_charge](https://docs.stripe.com/api/charges/object.md) の `payment_method_details.card.multicapture.status` フィールドには、顧客の支払い方法に基づき `available` または `unavailable` が含まれます。 ```json // PaymentIntent Response { "id": "pi_xxx", "object": "payment_intent","amount": 1000, "amount_capturable": 1000, "amount_received": 0, ... // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 0, "amount_refunded": 0, "payment_method_details": { "card": { "multicapture": {"status": "available" // or "unavailable" } } } ... } ... } ``` ## PaymentIntent をキャプチャーする PaymentIntent が [requires_capture 状態](https://docs.stripe.com/payments/paymentintents/lifecycle.md)で、かつマルチキャプチャーが `available` の場合、オプションの `final_capture` パラメーターを `false` に設定すると、キャプチャー用の API を呼び出す際に未キャプチャーの残額をリリースしないよう Stripe に指示が送られます。たとえば、10 USD の PaymentInent を確定した場合に、7 USD を `final_capture=false` にしてキャプチャーすると、残りの 3 USD はオーソリ状態が維持されることになります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=700 \ -d final_capture=false \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 300, // 1000 - 700 = 300 "amount_received": 700, // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 700, "amount_refunded": 0, ... } ... } ``` ## 最終キャプチャー 以下のいずれかが実行されるまで、PaymentIntent のステータスは `requires_capture` のままです。 - `final_capture` を `true` に設定する。 - `final_capture` パラメーターを使わずにキャプチャーする (`final_capture` はデフォルトで `true` に設定されているため)。 - オーソリの有効期間が切れる。 この時点で Stripe は残りの売上をリリースし、PaymentIntent のステータスが `succeeded` に変わります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=200 \ -d final_capture=true \ -d "expand[]=latest_charge" ``` PI キャプチャーのレスポンスに含まれる [amount_capturable](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_capturable) と [amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) フィールドは適宜更新されます。 ```json // PaymentIntent Response { "id": "pi_ANipwO3zNfjeWODtRPIg", "object": "payment_intent","amount": 1000, "amount_capturable": 0, // not 100 due to final_capture=true "amount_received": 900, // 700 + 200 = 900 // if latest_charge is expanded "latest_charge": { "id": "ch_xxx", "object": "charge","amount": 1000, "amount_captured": 900, "amount_refunded": 0, ... } ... } ``` 未キャプチャーの PaymentIntent は `canceled` になりますが、一部キャプチャーされた PaymentIntent は `succeeded` になります。 ## Optional: キャプチャーされていない売上をリリースする 未キャプチャーの売上をリリースして支払いを一部キャプチャーする場合は、金額を 0 に設定し、`final_capture` を `true` にします。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxx/capture \ -u "<>:" \ -d amount_to_capture=0 \ -d final_capture=true ``` これにより PaymentIntent は `succeeded` に移行し、未キャプチャーの売上はカード保有者にリリースされます。 ## 構築したシステムをテストする Stripe テストカードと任意のセキュリティコード、郵便番号、将来の日付の有効期限を使用して、マルチキャプチャーによる決済をテストします。 | 番号 | 決済手段 | 説明 | | ---------------- | ---------------------------------------------- | --------------------------------------------------- | | 4242424242424242 | `pm_card_visa` | マルチキャプチャーに対応する Visa のテストカード。 | | 4000002500001001 | `pm_card_visa_cartesBancaires` | マルチキャプチャーをサポートする Cartes Bancaires または Visa のテストカード。 | | 4000008400000076 | `pm_card_credit_disableEnterpriseCardFeatures` | マルチキャプチャーに対応していない Visa のテストカード。 | ## 返金 PaymentIntent のステータスが `requires_capture` の場合、キャプチャー合計額から返金合計額を引いた金額 ([amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) — [amount_refunded](https://docs.stripe.com/api/charges/object.md#charge_object-amount_refunded) に達するまで、何度でも[返金](https://docs.stripe.com/api/refunds.md)できます。[charge.refunded](https://docs.stripe.com/api/charges/object.md#charge_object-refunded) フィールドは、最後のキャプチャーが実行され、[amount_received](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_received) の全額が返金された場合にのみ `true` に移行します。 Stripe は、[refund_application_fee=true](https://docs.stripe.com/api/refunds/create.md#create_refund-refund_application_fee) または [reverse_transfer=true](https://docs.stripe.com/api/refunds/create.md#create_refund-reverse_transfer) を指定した*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。代わりに、[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用して、手数料の一部返金と送金の差戻しを手動で実行できます。application fee refund エンドポイントまたは transfer reversal エンドポイントを使用すると、Stripe は `refund_application_fee=true` または `reverse_transfer=true` の返金に対応できなくなります。 ## Connect Multicapture は、[source_transaction](https://docs.stripe.com/api/transfers/create.md#create_transfer-source_transaction) パラメーターを伴う[支払いと送金別方式](https://docs.stripe.com/connect/separate-charges-and-transfers.md)を除き、Connect のすべてのユースケースに対応します。[application_fee_amount](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-application_fee_amount) と [transfer_data[amount]](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-transfer_data-amount) パラメーターにはいくつかの追加検証があります。Multicapture を Connect に実装する際は以下の検証を考慮してください。 - 最初のキャプチャー時に `application_fee_amount` または `transfer_data[amount]` を設定した場合、後続のすべてのキャプチャーで同じ値が要求されます。キャプチャー時に渡される `application_fee_amount` または `transfer_data[amount]` は、PaymentIntent の作成、確定、更新時に渡される値を上書きします。 - Stripe は、refund_application_fee=true または reverse_transfer=true を指定したマルチキャプチャーに対する*一部返金* (A partial refund is any refund in which less than the remaining refundable amount is refunded in a single request. The remaining refundable amount is the payment_intent.amount_received - charge.amount_refunded)に対応していません。[application fee refund (プラットフォーム手数料の返金)](https://docs.stripe.com/api/fee_refunds.md) エンドポイントと [transfer reversal (送金の差戻し)](https://docs.stripe.com/api/transfer_reversals.md) エンドポイントを使用すると、手数料の一部返金や送金の差戻しを実行できます。 ## Webhook ### 支払いの更新 Webhook Stripe は、支払いのキャプチャーが行われるたびに、[charge.updated](https://docs.stripe.com/api/events/types.md#event_types-charge.updated) Webhook を送信します。 たとえば、`application_fee_amount` が指定されたデスティネーション支払いをマルチキャプチャーする場合、最初のキャプチャーが行われると、Stripe はこれらの空のフィールドに値を入力します。 ```json // charge.updated { "data": { "id": "ch_xxx", "object": "charge", "amount": 1000,"balance_transaction": "txn_xxx", // applicable to all charges "transfer": "tr_xxx", // applicable to destination charges only "application_fee": "fee_xxx", // applicable to Connect only ... }, "previous_attributes": {"balance_transaction": null, // applicable to all charges "transfer": null, // applicable to destination charges only "application_fee": null, // applicable to Connect only } } ``` ### payment_intent.amount_capturable_updated Stripe は、`amount_to_capture` と `final_capture` の値に関係なく、キャプチャーのたびに [payment_intent.amount_capturable_updated](https://docs.stripe.com/api/events/types.md#event_types-payment_intent.amount_capturable_updated) を送信します。 たとえば、10 USD の金額の PaymentIntent から 1 USD をキャプチャーすると、PaymentIntent の amount_capturable フィールドが 9 USD に更新されます。 ```json // payment_intent.amount_capturable_updated { "data": { "id": "pi_xxx", "object": "payment_intent", "amount": 1000,"amount_capturable": 900 // 1000 - 100 = 900 ... }, "previous_attributes": {"amount_capturable": 1000 } } ``` ### 支払いのキャプチャーイベント Stripe は 最後のキャプチャー、またはオーソリ期間の終了時に、未キャプチャーの金額のオーソリを差戻すために [charge.captured](https://docs.stripe.com/api/events/types.md#event_types-charge.captured) イベントを送信します。支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) フィールドは、最後のキャプチャーまたはオーソリの差戻しが終わった時にのみ `true` になります。 たとえば、`amount=0` と `final_capture=true` を指定してキャプチャーを行うと、支払いの [captured](https://docs.stripe.com/api/charges/object.md#charge_object-captured) 属性は false から true に変わります。 ```json // charge.captured { "data": { "id": "ch_xxx", "object": "charge","captured": true ... }, "previous_attributes": {"captured": false } } ``` ### 返金 Webhook マルチキャプチャーの返金 Webhook は、マルチキャプチャー以外の返金 Webhook と同じです。 部分返金が行われるたびに、[refund.created](https://docs.stripe.com/api/events/types.md#event_types-refund.created) イベントが送信されます。連結アカウントの場合、これに加えてプラットフォーム手数料を返金する際には [application_fee.refunded](https://docs.stripe.com/api/events/types.md#event_types-application_fee.refunded) イベント、また送金を差戻す際には [transfer.reversed](https://docs.stripe.com/api/events/types.md#event_types-transfer.reversed) イベントも送信されます。