柔軟な支払いに支払いラインアイテムを使用する
マルチキャプチャーやオーバーキャプチャーなどの複雑な決済で支払いラインアイテムを使用する方法をご紹介します。
マルチキャプチャやオーバーキャプチャなどの 複雑な決済 に支払いラインアイテムを使用できます。
Multicapture
決済項目は、マルチキャプチャー中に使用できます。
メモ
KlarnaまたはPayPalではマルチキャプチャーはサポートされていません。
未キャプチャーの PaymentIntent を作成して確定する
メモ
APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、amount_ を拡張します。
PaymentIntentの作成時にcapture_をmanualとして指定し、if_パラメーターを使用してこの決済のマルチキャプチャーをリクエストします。作成される PaymentIntent では、支払い方法がサポートしている場合に、マルチキャプチャーが許可されます。
レスポンスでは、amount_ フィールドに 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_にも適用されます。作成時に指定されていない場合は、最初のキャプチャーで追加できますが、作成時に指定されていた場合は、追加するか明示的に設定解除する必要があります。
レスポンスのamount_フィールドには、最初のキャプチャーで指定されたライン項目が含まれます。
{ "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_ のままです。この時点で、次のいずれかを実行できます。
- PaymentIntent の全額まで PaymentIntent を複数回キャプチャーします。
final_をcapture trueに設定するか、final_パラメーターを指定せずにキャプチャーを行うことで、PaymentIntent をcapture succeeded状態に移行します (final_のデフォルトはcapture trueであるため)。
オーバーキャプチャー
決済項目は、オーバーキャプチャー中に使用できます。
未キャプチャーの PaymentIntent を作成して確定する
メモ
APIレスポンスには、デフォルトではライン項目は含まれません。ライン項目を返すには、amount_ を拡張します。
PaymentIntent の作成時に capture_ を manual として指定し、if_ パラメーターを使用して、この決済のオーバーキャプチャーをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合にオーバーキャプチャーが許可されます。
レスポンスでは、amount_ フィールドに 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_ ハッシュを渡します。
レスポンスの amount_ フィールドには、キャプチャー中に指定された項目が含まれます。
{ "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_ を拡張します。
PaymentIntent の作成時に capture_ を manual として指定し、if_ パラメーターを使用して、この決済の増分オーソリをリクエストします。作成された PaymentIntent では、決済手段がサポートしている場合に増分オーソリが許可されます。
レスポンスでは、amount_ フィールドに 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_ ハッシュを渡します。
レスポンスの amount_ フィールドには、増分オーソリ時に指定された明細項目が含まれ、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" ... }