Newer Version Available
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
-
1/commerce/order-management/order-summaries/orderSummaryId/async-actions/ensure-funds-async - Available version
- 48.0
- Requires Chatter
- No
- HTTP methods
- POST
- Request body for POST
-
Ensure Funds Async Input
- Root XML tag
- <ensureFundsAsyncInput>
- JSON example
-
1{ 2 "invoiceId": "50gR000000000JNIAY" 3} - Properties
- 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:
- Verify that the invoice balance doesn’t exceed the total amount of all the OrderPaymentSummaries.
- Look for an OrderPaymentSummary with a captured amount equal to the invoice balance. If one exists, apply those funds.
- If no exact match was found, identify all OrderPaymentSummaries with captured amounts greater than the invoice balance. If any exist, select the smallest one and apply funds from it equal to the invoice balance.
- If no captured amounts greater than the invoice balance were found, traverse the OrderPaymentSummaries in order of captured amount, from largest to smallest. Apply each captured amount to the invoice until the invoice balance is zero or all captured funds are applied.
- 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 those funds.
- If no exact match was found, identify all OrderPaymentSummaries with authorized amounts greater than the invoice balance. If any exist, select the smallest one and apply funds from it equal to the invoice balance.
- If no authorized amounts greater than the invoice balance were found, traverse the OrderPaymentSummaries in order of authorized amount, from largest to smallest. Capture and apply funds until the invoice balance is zero.