You are here:
Ensure Refunds Async Action
In Salesforce Order Management, ensure refunds for a credit memo or excess funds by sending a request to a payment provider. This action 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 don’t affect the background operation status.
Required Editions
| Available in: Lightning Experience |
| View supported editions. |
| This feature requires the Salesforce Order Management add-on. To purchase, contact your Salesforce account executive. |
In Flow Builder, add an Action element to your flow. Select the Order Management category, and search for Ensure Refunds Async.
Set Input Values
Use values from earlier in the flow to set the inputs.
| Input Parameter | Description |
|---|---|
| Ensure Refunds Async Input | This input is an Apex-defined variable of class ConnectApi.EnsureReundsAsyncInputRepresentation. The variable has these fields. You can specify either creditMemoId or excessFundsAmount, or you can specify both. If you're requesting a refund for a cancelled item, but an invoice was already generated and sent to ensureFunds, you must specify creditMemoId.
|
| Order Summary Id | Reference to the order summary associated with the credit memo. |
Store Output Values
| Output Parameter | Description |
|---|---|
| Ensure Refunds Async Output | This value is an Apex-defined variable of class EnsureRefundsAsyncOutputRepresentation. It only returns the ID of the asynchronous background operation, regardless of whether a call is made to an external payment gateway. It doesn’t include any errors from the operation. The backgroundOperationId field contains the ID of the background operation. |
Usage
This action applies the refund to order payment summaries associated with the specified order summary following this logic.
- Verify that the credit memo balance and excess funds amount don't exceed the total AvailableToRefund amount of all the order payment summaries associated with the order summary.
- If sequences is specified, follow these steps.
- Traverse the sequences list in order and apply the specified refund amounts to the specified order payment summaries.
- If the specified credit memo and excess funds are fully refunded, or if isAllowPartial is true, then the action stops here.
- If a credit memo is specified, follow these steps.
- If an order payment summary has an AvailableToRefund amount matching the credit memo’s remaining balance, apply the refund to that payment.
- If no exact match was found, apply the refund to the order payment summary with the largest AvailableToRefund amount.
- If the credit memo has any remaining balance, repeat steps a and b until that balance is fully refunded.
- If only one OrderPaymentSummary is specified but has multiple payments, follow these
steps.
- If a payment has an amount matching the CreditMemo’s remaining balance, apply the refund to that payment.
- If no exact match was found but one or more payment has a large enough amount to cover the balance, use the payment with the smallest amount.
- If no single payment has a large enough amount, use multiple payments in descending order of amount. This ensures the fewest payments are used.
- If an excess funds amount is specified, follow these steps.
- Examine those order payment summaries. If one has an AvailableToRefund amount matching the excess funds amount, apply the refund to that payment.
- If no exact match was found, apply the refund to the order payment summary with the largest AvailableToRefund amount.
- If any excess funds amount remains, repeat steps a and b until it’s fully refunded.

