Newer Version Available

This content describes an older version of this product. View Latest

Order Summaries, Ensure Refunds Async

Ensure refunds for a credit memo or excess 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-refunds-async
Available version
48.0
Requires Chatter
No
HTTP methods
POST
Request body for POST
Ensure Refunds Async Input
Root XML tag
<ensureRefundsAsyncInput>
JSON example
1{
2  "creditMemoId": "50gR000000000JNIAY"
3}
Properties
Name Type Description Required or Optional Available Version
creditMemoId String ID of the credit memo that represents a refund amount. Optional, but at least one input property is required 48.0
excessFundsAmount Double Amount of excess funds to refund. Optional, but at least one input property is required 49.0
Response body for POST
  • When the HTTP status code indicates success, the response body is an Ensure Refunds 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 Refunds Async Output, and the value of the enhancedErrorType property can be ignored.
Usage

This method checks the OrderPaymentSummaries associated with the specified OrderSummary for amounts to refund following this logic:

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

Note

  1. If a credit memo is specified, identify OrderPaymentSummaries with captured amounts that were applied to the corresponding invoice.
    1. Examine those OrderPaymentSummaries. If one has a captured amount matching the credit memo amount, apply the refund to that payment.
    2. If no exact match was found, look for captured amounts greater than the credit memo amount. If any exist, apply the refund to the smallest one.
    3. If no greater amounts were found, traverse the OrderPaymentSummaries in order of captured amount, from largest to smallest. Apply the refund to them until it’s fully applied.
  2. If an excess funds amount is specified, identify OrderPaymentSummaries with captured amounts that weren’t applied to any invoice.
    1. Examine those OrderPaymentSummaries. If one has a captured amount matching the excess funds amount, apply the refund to that payment.
    2. If no exact match was found, look for captured amounts greater than the excess funds amount. If any exist, apply the refund to the smallest one.
    3. If no greater amounts were found, traverse the OrderPaymentSummaries in order of captured amount, from largest to smallest. Apply the refund to them until it’s fully applied.