Order Summaries, Ensure Funds Async

Ensure funds for an Invoice and apply them to it. If needed, capture authorized funds by sending a request to a payment provider. This method inserts a background operation into an asynchronous job queue and returns the ID of that operation so you can track its status. Payment gateway responses appear in the payment gateway log and do not affect the background operation status.
Resource
/commerce/order-management/order-summaries/orderSummaryId/async-actions/ensure-funds-async
Available version
48.0
HTTP methods
POST
Request body for POST
Ensure Funds Async Input
Root XML tag
<ensureFundsAsyncInput>
JSON example
{
  "invoiceId": "3ttR000000000JNIAY"
}
Properties
Name Type Description Required or Optional Available Version
invoiceId String ID of the Invoice. Required 48.0
isConsiderReservedBalanceAmount Boolean If true, the reserved balance amount is used for the Order Summary to fund the invoice. If not enough reserved balance amount, any available balance that isn’t reserved by another Order Summary is used. If false, any available balance is used. Optional 59.0
Response body for POST
  • When the HTTP status code indicates success, the response body is an Ensure Funds Async Output. The response body can still indicate processing errors.
  • When the HTTP status code is in the 400 (client error) or 500 (server error) range, the response body is an Error with Output. The output property is an Ensure Funds Async Output, and the value of the enhancedErrorType property can be ignored.
Usage

This method checks the OrderPaymentSummaries associated with the specified OrderSummary for funds to apply to the Invoice balance following this logic:

If multiple OrderPaymentSummaries have equal BalanceAmount values, their order of selection is random.

Note

  1. Verify that the Invoice balance doesn’t exceed the total BalanceAmount of all the OrderPaymentSummaries associated with the OrderSummary.
  2. If an OrderPaymentSummary has a BalanceAmount equal to the Invoice balance, apply the funds from that OrderPaymentSummary.
  3. If no exact match was found, apply funds from the OrderPaymentSummary with the largest BalanceAmount.
  4. If the Invoice still has a balance to ensure, repeat steps 2 and 3 until the full balance is ensured or no captured funds remain.
  5. If the Invoice still has a balance, look for an OrderPaymentSummary with an authorized amount equal to the remaining Invoice balance. If one exists, capture and apply the funds from that OrderPaymentSummary.
  6. If no exact match was found, capture and apply funds from the OrderPaymentSummary with the largest authorized amount.
  7. If the Invoice still has a balance to ensure, repeat steps 5 and 6 until the full balance is ensured.

If the method creates a payment, the payment record’s ClientContext value isn’t predictable. Don't use it in custom logic.

Note