マルチキャプチャやオーバーキャプチャなどの 複雑な決済 に支払いラインアイテムを使用できます。
Multicapture 決済項目は、マルチキャプチャー中に使用できます。
メモ KlarnaまたはPayPalではマルチキャプチャーはサポートされていません。
未キャプチャーの PaymentIntent を作成して確定する メモ APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、amount_ details. line_ items を拡張 します。
PaymentIntentの作成時にcapture_ methodをmanualとして指定し、if_ availableパラメーターを使用してこの決済のマルチキャプチャーをリクエストします。作成される PaymentIntent では、支払い方法がサポートしている場合に、マルチキャプチャーが許可されます。
curl https://api.stripe.com/v1/payment_intents \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 で指定されたライン項目が含まれます。
{
"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 https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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フィールドには、最初のキャプチャーで指定されたライン項目が含まれます。
{
"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 であるため)。以前のキャプチャーに amount_ details または amount_ details[line_ items] が含まれている場合は、後続のキャプチャーにそれらを引き続き含める必要があります。 以前のキャプチャーにこれらのフィールドが含まれていなかった場合、以降のキャプチャーでフィールドを追加することはできません。 curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 はキャプチャー全体で集計されます。{
"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 を作成して確定する メモ APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、amount_ details. line_ items を拡張 します。
PaymentIntent の作成時に capture_ method を manual として指定し、if_ available パラメーターを使用して、この決済のオーバーキャプチャーをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合にオーバーキャプチャーが許可されます。
curl https://api.stripe.com/v1/payment_intents \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 で指定されたライン項目が含まれます。
{
"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 エンドポイントを使用し、maximum_amount_capturable までの amount_to_capture を指定します。
キャプチャー中のキャプチャー金額と整合性のとれた更新後の amount_ details ハッシュを渡します。
curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/capture \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 フィールドには、キャプチャー中に指定された項目が含まれます。
{
"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 を拡張 します。
PaymentIntent の作成時に capture_ method を manual として指定し、if_ available パラメーターを使用して、この決済の増分オーソリをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合に増分オーソリが許可されます。
curl https://api.stripe.com/v1/payment_intents \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 で指定されたライン項目が含まれます。
{
"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 エンドポイントを使用し、決済手段でサポートされている最大増分オーソリ金額を上限とする amount を指定します。
増分後のオーソリされた合計金額と整合性の取れた、更新後の amount_ details ハッシュを渡します。
curl https://api.stripe.com/v1/payment_intents/pi_xxxxxxxx/increment_authorization \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 のオーソリされた合計金額が更新されます。
{
"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 を拡張 します。
PaymentIntentを作成する際に capture_ method を manual として指定し、この支払いで部分オーソリをリクエストするために if_ available パラメータを使用します。
curl https://api.stripe.com/v1/payment_intents \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 ハッシュのコードは amount_ details_ amount_ mismatch で、不一致の金額はメッセージ プロパティに含まれています。
以下の応答例は、取引が部分的に 7 USD でオーソリされていることを示しています。これは、最初にリクエストされた 10 USD を下回っています。
{
"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 をキャプチャーする
PaymentIntent をキャプチャーし 、部分的にオーソリされた金額と一致する更新後の amount_details を渡します。
curl https://api.stripe.com/v1/payment_intents/pi_3SpkXE2QCQbYXizB1WscY8lW/capture \
-u "sk_test_BQokikJOvBiI2HlWgH4olfQ2
:" \
-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 はライン項目データをカードネットワークに送信できます。
{
"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"
}