Loading
Salesforce now sends email only from verified domains. Read More
Automate Your Business Processes
Table of Contents
Select Filters

          No results
          No results
          Here are some search tips

          Check the spelling of your keywords.
          Use more general search terms.
          Select fewer filters to broaden your search.

          Search all of Salesforce Help
          Ensure Refunds Async Action

          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.

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

          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.

          • creditMemoId—The ID of the credit memo to ensure refunds for.
          • excessFundsAmount—The amount of excess funds to apply the refunds against.
          • invoicesToPay—List of invoices for fees that reduce the refund, such as return fees.
          • isAllowPartial—This value controls the behavior when the amounts included in the sequences list don’t cover the entire refund amount. If this value is false, the default refund logic is applied to ensure the remaining refund amount. If this value is true, the unrefunded balance remains on the credit memo. If you don’t specify a sequences list, this value is ignored, and the default refund logic is applied. The default is false.
          • sequences—This input is an ordered list of refund amounts and the OrderPaymentSummaries to apply them to. The process traverses this list in order and stops when it has refunded the full amount. It’s a list of Apex-defined variables of class SequenceOrderPaymentSummaryInputRepresentation. It contains these fields:
            • amount—Amount of the refund to apply to the OrderPaymentSummary.
            • orderPaymentSummaryId—ID of the OrderPaymentSummary to apply the Amount to.
          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.

          Note
          Note If multiple order payment summaries have equal AvailableToRefund amounts, their order of selection is random.
          • 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.
           
          Loading
          Salesforce Help | Article