Process Refund Credit Memo Action

Initiates a refund against a posted credit memo. This action locks the credit memo, calls the Commerce Refund API, and returns the refund and application record IDs.

This action is available in API version 68.0 and later.

Special Access Rules 

The Process Refund Credit Memo action is available in Enterprise, Unlimited, and Developer Editions where Billing is enabled. To use this action, your org needs the Payment Run Advance permission.

Supported REST HTTP Methods 

URI:/services/data/v68.0/actions/standard/processUnreferencedRefund

Formats: JSON, XML

HTTP Methods: POST

Authentication:Authorization: Bearer TOKEN

Where TOKEN is a placeholder for your OAuth access token.

Inputs 

InputTypeDescription
appliedToIdreferenceRequired. ID of the posted credit memo to refund against.
currencyIsoCodestringOptional. ISO currency code for the refund. Required when multi-currency is enabled. The value must match the currency of the credit memo.
refundNotesstringOptional. Notes stored in the refund record comments.
paymentMethodIdreferenceOptional. ID of the payment method to issue the refund on. The payment method must be valid and active.
refundAmountdoubleRequired. Amount to refund. The value must be greater than 0 and less than or equal to the remaining balance of the credit memo.
refundReasonstringOptional. Reason for the refund.

Outputs 

OutputTypeDescription
processRefundResponseApex-defined (ProcessRefundCreditMemoResponse)Result of the refund operation. Contains these fields success (boolean)—Indicates whether the refund was processed successfully ( true ) or not ( false ); refundId (string)—ID of the created refund record; applicationId (string)—ID of the created application junction record (CreditMemoRefund or CreditMemoLineRefund ) that links the refund to the credit memo; or errors (list of Apex-defined ProcessRefundCreditMemoErrorResponse )—List of errors returned if the refund wasn’t processed successfully. Each error contains an errorCode and a message. Possible error codes are INVALID_CREDIT_MEMO—The specified credit memo isn’t in a valid state for refund processing, AMOUNT_EXCEEDS_BALANCE—The refund amount exceeds the remaining balance on the credit memo, CREDIT_MEMO_LOCKED—The credit memo is locked by another operation, LIMIT_EXCEEDED—The number of requests exceeds the maximum allowed (50), MISSING_REQUIRED_FIELD—A required input parameter is missing, or EXTERNAL_SERVICE_EXCEPTION—The Commerce Refund API call failed without a more specific error.

Example 

POST

This sample request is for the Process Refund Credit Memo action.

1{
2  "inputs": [
3    {
4      "appliedToId": "0PMxx0000000001AAA",
5      "refundAmount": 100,
6      "currencyIsoCode": "USD",
7      "refundReason": "Customer requested refund",
8      "paymentMethodId": "08pxx0000000001AAA",
9      "refundNotes": "Refund processed per case 00298475."
10    }
11  ]
12}

This sample response shows a successful invocation.

1[
2  {
3    "actionName": "processUnreferencedRefund",
4    "errors": null,
5    "invocationId": null,
6    "isSuccess": true,
7    "outcome": null,
8    "outputValues": {
9      "processRefundResponse": {
10        "success": true,
11        "refundId": "0Rfxx0000000001AAA",
12        "applicationId": "0CMxx0000000001AAA",
13        "errors": []
14      }
15    },
16    "sortOrder": -1,
17    "version": 1
18  }
19]

This sample shows an error response for a credit memo already locked by another operation.

1[
2  {
3    "actionName": "processUnreferencedRefund",
4    "errors": [
5      {
6        "statusCode": "CREDIT_MEMO_LOCKED",
7        "message": "The Credit Memo is currently locked by another operation. Please try again.",
8        "fields": []
9      }
10    ],
11    "invocationId": null,
12    "isSuccess": false,
13    "outcome": null,
14    "outputValues": null,
15    "sortOrder": -1,
16    "version": 1
17  }
18]