# 柔軟な支払いに支払いラインアイテムを使用する マルチキャプチャーやオーバーキャプチャーなどの複雑な決済で支払いラインアイテムを使用する方法をご紹介します。 マルチキャプチャやオーバーキャプチャなどの [複雑な決済](https://docs.stripe.com/payments/flexible-payments.md) に支払いラインアイテムを使用できます。 ## Multicapture 決済項目は、マルチキャプチャー中に使用できます。 > KlarnaまたはPayPalではマルチキャプチャーはサポートされていません。 #### 未キャプチャーの PaymentIntent を作成して確定する > APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、`amount_details.line_items` を[拡張](https://docs.stripe.com/expand.md#includable-properties)します。 PaymentIntentの作成時に`capture_method`を`manual`として指定し、`if_available`パラメーターを使用してこの決済のマルチキャプチャーをリクエストします。作成される PaymentIntent では、支払い方法がサポートしている場合に、マルチキャプチャーが許可されます。 ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=4600 \ -d currency=usd \ -d "payment_method_types[0]=card" \ -d payment_method=pm_card_visa \ -d "payment_method_options[card][request_multicapture]=if_available" \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=200" \ -d "amount_details[tax][total_tax_amount]=400" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=400" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d "amount_details[line_items][1][product_code]=SKU002" \ -d "amount_details[line_items][1][product_name]=Product 002" \ -d "amount_details[line_items][1][unit_cost]=2000" \ -d "amount_details[line_items][1][quantity]=1" \ -d "amount_details[line_items][1][unit_of_measure]=gallons" \ -d "amount_details[line_items][1][payment_method_options][card][commodity_code]=123123" \ -d confirm=true \ -d capture_method=manual \ -d "expand[0]=amount_details.line_items" ``` レスポンスでは、`amount_details` フィールドに PaymentIntent で指定されたライン項目が含まれます。 ```json { "amount": 4600, "amount_capturable": 4600, "amount_received": 0, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 400 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 400 }, "line_items": [ { "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } ... } ``` #### PaymentIntent をキャプチャする - `amount_details` は、作成時に指定されていない場合でも、最初のキャプチャーに追加できます。 - 作成時に`amount_details`を指定した場合は、最初のキャプチャー時に`amount_details`を渡すか、設定を解除する必要があります。 同じルールが`amount_details[line_items]`にも適用されます。作成時に指定されていない場合は、最初のキャプチャーで追加できますが、作成時に指定されていた場合は、追加するか明示的に設定解除する必要があります。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \ -u "<>:" \ -d amount_to_capture=2300 \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=100" \ -d "amount_details[tax][total_tax_amount]=200" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=200" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d final_capture=false \ -d "expand[0]=amount_details.line_items" ``` レスポンスの`amount_details`フィールドには、最初のキャプチャーで指定されたライン項目が含まれます。 ```json { "amount": 4600, "amount_capturable": 2300, "amount_received": 2300, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 100, "tax": { "total_tax_amount": 200 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 200 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_123", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } }, "status": "requires_capture" ... } ``` PaymentIntent のステータスは `requires_capture` のままです。この時点で、次のいずれかを実行できます。 - PaymentIntent の全額まで PaymentIntent を複数回キャプチャーします。 - `final_capture` を `true` に設定するか、`final_capture` パラメーターを指定せずにキャプチャーを行うことで、PaymentIntent を `succeeded` 状態に移行します (`final_capture` のデフォルトは `true` であるため)。 #### PaymentIntent を再度キャプチャー - 以前のキャプチャーに `amount_details` または `amount_details[line_items]` が含まれている場合は、後続のキャプチャーにそれらを引き続き含める必要があります。 - 以前のキャプチャーにこれらのフィールドが含まれていなかった場合、以降のキャプチャーでフィールドを追加することはできません。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \ -u "<>:" \ -d amount_to_capture=2300 \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=100" \ -d "amount_details[tax][total_tax_amount]=200" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=200" \ -d "amount_details[line_items][0][product_code]=SKU002" \ -d "amount_details[line_items][0][product_name]=Product 002" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=gallons" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d final_capture=false \ -d "expand[0]=amount_details.line_items" ``` レスポンスの `amount_details` フィールドには、以下のルールに従って、最初の 2 件のキャプチャーのライン項目が含まれます。 - `discount_amount`、`tax.total_tax_amount`、`shipping.amount` はキャプチャー全体で合計されます。 - キャプチャーでは `shipping.from_postal_code` と `shipping.to_postal_code` が省略されることがありますが、指定されている場合はキャプチャー間で変更しないでください。 - `line_items` はキャプチャー全体で集計されます。 ```json { "amount": 4600, "amount_capturable": 0, "amount_received": 4600, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 400 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 400 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_123", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "_id": "li_234", "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } }, "status": "succeeded" ... } ``` #### PaymentIntent の部分キャプチャー `0` で `amount_to_capture` を、`true` で `final_capture` を渡して、部分的にキャプチャーされた PaymentIntent を `succeeded` 状態に移行します。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \ -u "<>:" \ -d amount_to_capture=0 \ -d final_capture=true \ -d "expand[]=amount_details.line_items" ``` レスポンスの`amount_details`フィールドには、最初のキャプチャーで指定されたライン項目のみが含まれます。 ```json { "amount": 4600, "amount_capturable": 2300, "amount_received": 2300, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 100, "tax": { "total_tax_amount": 200 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 200 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_123", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } }, "status": "succeeded" ... } ``` ## オーバーキャプチャー 決済項目は、オーバーキャプチャー中に使用できます。 #### 未キャプチャーの PaymentIntent を作成して確定する > APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、`amount_details.line_items` を[拡張](https://docs.stripe.com/expand.md#includable-properties)します。 PaymentIntent の作成時に `capture_method` を `manual` として指定し、`if_available` パラメーターを使用して、この決済のオーバーキャプチャーをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合にオーバーキャプチャーが許可されます。 ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=4600 \ -d currency=usd \ -d "payment_method_types[0]=card" \ -d payment_method=pm_card_visa \ -d "payment_method_options[card][request_overcapture]=if_available" \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=200" \ -d "amount_details[tax][total_tax_amount]=400" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=400" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d "amount_details[line_items][1][product_code]=SKU002" \ -d "amount_details[line_items][1][product_name]=Product 002" \ -d "amount_details[line_items][1][unit_cost]=2000" \ -d "amount_details[line_items][1][quantity]=1" \ -d "amount_details[line_items][1][unit_of_measure]=gallons" \ -d "amount_details[line_items][1][payment_method_options][card][commodity_code]=123123" \ -d confirm=true \ -d capture_method=manual \ -d "expand[0]=amount_details.line_items" ``` レスポンスでは、`amount_details` フィールドに PaymentIntent で指定されたライン項目が含まれます。 ```json { "amount": 4600, "amount_capturable": 4600, "amount_received": 0, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 400 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 400 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_345", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "_id": "li_456", "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } } ... } ``` #### PaymentIntent をキャプチャする PaymentIntent で現在オーソリゼーションされている金額を超える金額をキャプチャーするには、[ capture ](https://docs.stripe.com/api/payment_intents/capture.md) エンドポイントを使用し、[maximum_amount_capturable](https://docs.stripe.com/api/charges/object.md#charge_object-payment_method_details-card-overcapture) までの [amount_to_capture](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-amount_to_capture) を指定します。 キャプチャー中のキャプチャー金額と整合性のとれた更新後の `amount_details` ハッシュを渡します。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \ -u "<>:" \ -d amount_to_capture=5000 \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=200" \ -d "amount_details[tax][total_tax_amount]=600" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=600" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d "amount_details[line_items][1][product_code]=SKU002" \ -d "amount_details[line_items][1][product_name]=Product 002" \ -d "amount_details[line_items][1][unit_cost]=2000" \ -d "amount_details[line_items][1][quantity]=1" \ -d "amount_details[line_items][1][unit_of_measure]=gallons" \ -d "amount_details[line_items][1][payment_method_options][card][commodity_code]=123123" \ -d "expand[0]=amount_details.line_items" ``` レスポンスの `amount_details` フィールドには、キャプチャー中に指定された項目が含まれます。 ```json { "amount": 5000, "amount_capturable": 0, "amount_received": 5000, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 600 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 600 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_567", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "_id": "li_678", "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } }, "status": "succeeded" ... } ``` ## 増分オーソリ 増分オーソリ中に決済明細項目を使用して、最初のオーソリ後に PaymentIntent で追加の金額をオーソリできます。 #### 未キャプチャーの PaymentIntent を作成して確定する > APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、`amount_details.line_items` を[拡張](https://docs.stripe.com/expand.md#includable-properties)します。 PaymentIntent の作成時に `capture_method` を `manual` として指定し、`if_available` パラメーターを使用して、この決済の増分オーソリをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合に増分オーソリが許可されます。 ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=4600 \ -d currency=usd \ -d "payment_method_types[0]=card" \ -d payment_method=pm_card_visa \ -d "payment_method_options[card][request_incremental_authorization]=if_available" \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=200" \ -d "amount_details[tax][total_tax_amount]=400" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=400" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d "amount_details[line_items][1][product_code]=SKU002" \ -d "amount_details[line_items][1][product_name]=Product 002" \ -d "amount_details[line_items][1][unit_cost]=2000" \ -d "amount_details[line_items][1][quantity]=1" \ -d "amount_details[line_items][1][unit_of_measure]=gallons" \ -d "amount_details[line_items][1][payment_method_options][card][commodity_code]=123123" \ -d confirm=true \ -d capture_method=manual \ -d "expand[0]=amount_details.line_items" ``` レスポンスでは、`amount_details` フィールドに PaymentIntent で指定されたライン項目が含まれます。 ```json { "amount": 4600, "amount_capturable": 4600, "amount_received": 0, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 400 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 400 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_789", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "_id": "li_890", "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } } ... } ``` #### オーソリを増やす PaymentIntent で当初のオーソリ金額を超える金額をオーソリするには、[increment_authorization](https://docs.stripe.com/api/payment_intents/increment_authorization.md) エンドポイントを使用し、決済手段でサポートされている最大増分オーソリ金額を上限とする [amount](https://docs.stripe.com/api/payment_intents/increment_authorization.md#increment_authorization-amount) を指定します。 増分後のオーソリされた合計金額と整合性の取れた、更新後の `amount_details` ハッシュを渡します。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/increment_authorization \ -u "<>:" \ -d amount=5000 \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[discount_amount]=200" \ -d "amount_details[tax][total_tax_amount]=600" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=600" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=2000" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "amount_details[line_items][0][payment_method_options][card][commodity_code]=123123" \ -d "amount_details[line_items][1][product_code]=SKU002" \ -d "amount_details[line_items][1][product_name]=Product 002" \ -d "amount_details[line_items][1][unit_cost]=2000" \ -d "amount_details[line_items][1][quantity]=1" \ -d "amount_details[line_items][1][unit_of_measure]=gallons" \ -d "amount_details[line_items][1][payment_method_options][card][commodity_code]=123123" \ -d "expand[0]=amount_details.line_items" ``` レスポンスの `amount_details` フィールドには、増分オーソリ時に指定された明細項目が含まれ、PaymentIntent のオーソリされた合計金額が更新されます。 ```json { "amount": 5000, "amount_capturable": 5000, "amount_received": 0, "payment_details": { "customer_reference": "customer_reference", "order_reference": "order_reference" }, "amount_details": { "discount_amount": 200, "tax": { "total_tax_amount": 600 }, "shipping": { "from_postal_code": "94110", "to_postal_code": "94117", "amount": 600 }, "line_items": { "object": "list", "url": "/v1/payment_intents/pi_xxxxxxxx/amount_details_line_items", "has_more": false, "data": [ { "_id": "li_901", "product_code": "SKU001", "product_name": "Product 001", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "feet", "payment_method_options": { "card": { "commodity_code": "123123" } } }, { "_id": "li_012", "product_code": "SKU002", "product_name": "Product 002", "unit_cost": 2000, "quantity": 1, "unit_of_measure": "gallons", "payment_method_options": { "card": { "commodity_code": "123123" } } } ] } }, "status": "requires_capture" ... } ``` ## 部分オーソリ 支払いラインアイテムは部分的なオーソリで使用できます。 ### 未キャプチャーの PaymentIntent を作成して確定 > APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、`amount_details.line_items` を[拡張](https://docs.stripe.com/expand.md#includable-properties)します。 `PaymentIntent`を作成する際に `capture_method` を `manual` として指定し、この支払いで部分オーソリをリクエストするために `if_available` パラメータを使用します。 ```curl curl https://api.stripe.com/v1/payment_intents \ -u "<>:" \ -d amount=1000 \ -d currency=usd \ -d "payment_method_types[0]=card" \ -d payment_method=pm_card_debit_partialAuthorization \ -d "payment_method_options[card][request_partial_authorization]=if_available" \ -d "payment_details[customer_reference]=customer_reference" \ -d "payment_details[order_reference]=order_reference" \ -d "amount_details[tax][total_tax_amount]=100" \ -d "amount_details[shipping][from_postal_code]=94110" \ -d "amount_details[shipping][to_postal_code]=94117" \ -d "amount_details[shipping][amount]=100" \ -d "amount_details[line_items][0][product_code]=SKU001" \ -d "amount_details[line_items][0][product_name]=Product 001" \ -d "amount_details[line_items][0][unit_cost]=800" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d confirm=true \ -d capture_method=manual \ -d "expand[0]=amount_details.line_items" ``` 部分オーソリ前に項目データを提供した場合、項目の金額の合計が `PaymentIntent` の合計金額と一致しないことがあります。この場合、レスポンスの [amount_details.error](https://docs.stripe.com/api/payment_intents/object.md#payment_intent_object-amount_details-error) ハッシュの`コード`は `amount_details_amount_mismatch` で、不一致の金額は`メッセージ` プロパティに含まれています。 以下の応答例は、取引が部分的に 7 USD でオーソリされていることを示しています。これは、最初にリクエストされた 10 USD を下回っています。 ```json { "id": "pi_3SpkXE2QCQbYXizB1WscY8lW", "object": "payment_intent","amount": 700, "amount_capturable": 700, "amount_details": {"error": { "code": "amount_details_amount_mismatch", "message": "Invalid amount_details. The calculated amount is Sum(line_items[#].unit_cost * line_items[#].quantity + line_items[#].tax.total_tax_amount - line_items[#].discount_amount) + shipping.amount or Sum(line_items[#].unit_cost * line_items[#].quantity) + tax.total_tax_amount + shipping.amount - discount_amount which does not match the total amount charged. In this case the calculated amount 1000 is not equal to the total amount 700 on the PaymentIntent." }, "line_items": { "object": "list", "data": [ { "id": "uli_TnLDKPQgGwfFxD", "object": "payment_intent_amount_details_line_item", "discount_amount": null, "payment_method_options": null, "product_code": "SKU001", "product_name": "Product 001", "quantity": 1, "tax": null, "unit_cost": 800, "unit_of_measure": "feet" } ], "has_more": false, "url": "/v1/payment_intents/pi_3SpkXE2QCQbYXizB1WscY8lW/amount_details_line_items" }, "shipping": { "amount": 100, "from_postal_code": "94110", "to_postal_code": "94117" }, "tax": { "total_tax_amount": 100 }, "tip": {} }, "status": "requires_capture" } ``` ### PaymentIntent をキャプチャー #### 更新されたラインアイテムで PaymentIntent をキャプチャーする `PaymentIntent` を[キャプチャーし](https://docs.stripe.com/api/payment_intents/capture.md)、部分的にオーソリされた金額と一致する更新後の [amount_details](https://docs.stripe.com/api/payment_intents/capture.md#capture_payment_intent-amount_details) を渡します。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_3SpkXE2QCQbYXizB1WscY8lW/capture \ -u "<>:" \ -d "amount_details[line_items][0][product_code]=SKU002" \ -d "amount_details[line_items][0][product_name]=Product 002" \ -d "amount_details[line_items][0][unit_cost]=500" \ -d "amount_details[line_items][0][quantity]=1" \ -d "amount_details[line_items][0][unit_of_measure]=feet" \ -d "expand[0]=amount_details.line_items" ``` `amount_details` を更新すると、不一致`エラー` ハッシュが `PaymentIntent` から削除されます。カード支払いの場合、Stripe はライン項目データをカードネットワークに送信できます。 ```json { "id": "pi_3SpkXE2QCQbYXizB1WscY8lW", "object": "payment_intent", "amount": 700, "amount_capturable": 0, "amount_details": { "line_items": { "object": "list", "data": [ { "id": "uli_TnM6fcFHBk7BMk", "object": "payment_intent_amount_details_line_item", "discount_amount": null, "payment_method_options": null, "product_code": "SKU002", "product_name": "Product 002", "quantity": 1, "tax": null, "unit_cost": 500, "unit_of_measure": "feet" } ], "has_more": false, "url": "/v1/payment_intents/pi_3SplOI2QCQbYXizB0DaGWmQT/amount_details_line_items" }, "shipping": { "amount": 100, "from_postal_code": "94110", "to_postal_code": "94117" }, "tax": { "total_tax_amount": 100 }, "tip": {} }, "amount_received": 700, "status": "succeeded" } ``` #### ラインアイテムを更新せずに PaymentIntent をキャプチャーする `amount_details` を更新せずに`PaymentIntent` を[キャプチャーします](https://docs.stripe.com/api/payment_intents/capture.md)。 カード支払いの場合、Stripe は不一致のラインアイテムデータをカードネットワークに送信しません。そのため、取引は L2/L3 インターチェンジ割引の対象になりません。 ```curl curl https://api.stripe.com/v1/payment_intents/pi_3SpkXE2QCQbYXizB1WscY8lW/capture \ -u "<>:" \ -d "expand[]=amount_details.line_items" ``` ```json { "id": "pi_3SpkXE2QCQbYXizB1WscY8lW", "object": "payment_intent", "amount": 700, "amount_capturable": 0, "amount_details": { "error": { "code": "amount_details_amount_mismatch", "message": "Invalid amount_details. The calculated amount is Sum(line_items[#].unit_cost * line_items[#].quantity + line_items[#].tax.total_tax_amount - line_items[#].discount_amount) + shipping.amount or Sum(line_items[#].unit_cost * line_items[#].quantity) + tax.total_tax_amount + shipping.amount - discount_amount which does not match the total amount charged. In this case the calculated amount 1000 is not equal to the total amount 700 on the PaymentIntent." }, "line_items": { "object": "list", "data": [ { "id": "uli_TnLDKPQgGwfFxD", "object": "payment_intent_amount_details_line_item", "discount_amount": null, "payment_method_options": null, "product_code": "SKU001", "product_name": "Product 001", "quantity": 1, "tax": null, "unit_cost": 800, "unit_of_measure": "feet" } ], "has_more": false, "url": "/v1/payment_intents/pi_3SpkXE2QCQbYXizB1WscY8lW/amount_details_line_items" }, "shipping": { "amount": 100, "from_postal_code": "94110", "to_postal_code": "94117" }, "tax": { "total_tax_amount": 100 }, "tip": {} }, "amount_received": 700, "status": "succeeded" } ```