---
schema_version: "1"
id: d8b3ceea58fc0005582d8c87eb81ea6ada257f0854561b7a7843440c29d3fbf1
title: Payment Authorization Reversal Service API
collection: legacydeveloper
version: current
locale: en-us
portal_url: https://docs.salesforce.com/legacydeveloper/current/en-us/apexcode/apex_commercepayments_rev_service_api.md
canonical_url: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_commercepayments_rev_service_api.htm
source_site: developer.salesforce.com
content_type: documentation
content_hash: 749401f015300c8f73c02c5931c2ce504b08ceada75e0e80e3a044918ac19b83
description: An authorization reversal is a transaction that negates an authorization by releasing the hold on funds in a customer’s payment method. Use the authorization reversal service to provide users with the ability to reverse an outstanding payment authorization.
---
# Payment Authorization Reversal Service API

An authorization reversal is a transaction that negates an authorization by releasing the hold on funds in a customer’s payment method. Use the authorization reversal service to provide users with the ability to reverse an outstanding payment authorization.

Sometimes, a customer performs a payment authorization but then needs to cancel all or part of the authorization later. For example, the customer bought three items, and then realized that the first item is already in their stock. Commerce Payments API allows you to reverse all or part of an outstanding payment authorization.

After the customer payment gateway authorizes a payment, Commerce Payments creates a payment authorization record to store information about the authorization. When a user or process performs a reversal against the authorization, the authorization reversal service creates a payment authorization adjustment to store information. The adjustment is related to the authorization.

If the payment authorization is associated with an order payment summary, then the reversal amount is added to the order payment summary’s AuthorizationReversalAmount and subtracted from its AvailableToCaptureAmount. But the AvailableToCaptureAmount is never below 0, even if a reversal makes its calculation a negative amount.

![Note](https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/images/icon_note.png)

#### Note

For an authorization reversal, the payment gateway log’s OrderPaymentSummaryId always defaults to null. If there’s an associated order payment summary, your code can set the value.

Call the authorization reversal service by making a POST request to the following endpoint.

**Endpoint**

/commerce/payments/authorizations/${\*authorizationId\*}/reversals

The service accepts one authorization reversal request per call. The following payment authorization adjustment API parameters are accepted.

<table class="featureTable sort_table" summary="">
        <caption><span class="tablecap">Table 1. Reversal Service Input Parameters</span></caption>



        <thead class="thead sorted" align="left">
          <tr>
            <th class="featureTableHeader  " id="d104064e85">Parameter</th>

            <th class="featureTableHeader  " id="d104064e88">Required</th>

            <th class="featureTableHeader  " id="d104064e91">Description</th>

          </tr>

        </thead>

        <tbody class="tbody">
          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">amount</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Required</td>

            <td class="entry" headers="d104064e91" data-title="Description">
              <p class="p">Amount to be reversed from the authorization. Must be greater than zero. </p>

              <p class="p">Salesforce doesn't provide validations comparing <samp class="codeph nolang">PaymentAuthorizationAdjustment.Amount</samp> to <samp class="codeph nolang">PaymentAuthorization.Amount</samp>. </p>

              <p class="p">If the payment gateway allows the reversal amount to be greater than the authorization
                amount, the authorization's resulting balance can be negative. If your gateway supports
                authorization balances below zero and you want to avoid gateway calls, configure your
                adapter to query the authorization amount, balance, and total reversal amount, and don’t
                call the endpoint if the balance is less than zero.</p>

            </td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">accountId</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">Account ID to which this authorization reversal is linked.</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">effectiveDate</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">The date that the reversal applies to the authorization.</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">email</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">Fraud parameter</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">ipAddress</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">Fraud parameter</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">macAddress</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">Fraud parameter</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">phone</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">Fraud parameter</td>

          </tr>

          <tr>
            <td class="entry" headers="d104064e85" data-title="Parameter"><span class="keyword parmname">comments</span></td>

            <td class="entry" headers="d104064e88" data-title="Required">Optional</td>

            <td class="entry" headers="d104064e91" data-title="Description">User-provided comments about the authorization reversal. Must be less than 1000
              characters.</td>

          </tr>

        </tbody>

      </table>

## Sample Request and Response

This request calls a $150 reversal against an authorization.

{
  "accountId":"",
  "amount": "150",\*  "comments": "authorization reversal request",
  "effectiveDate":"2020-10-18T11:32:27.000Z",
  "ipAddress": "202.95.77.70",
  "macAddress": "00-14-22-01-23-45",
  "phone": "100-456-67",
  "email": "test@example.org",
  "additionalData":{
       //add additional parameters if needed
      "key1":"value1",
      "key2":"value2",
      "key3":"value3",
      "key4":"value4",
      "key5":"value5"
    }
}

**Sample Response - Success**

A successful authorization reversal response provides information about the gateway’s response and the values to construct a payment authorization adjustment entity.

HPP Status Code: 201
{
  "gatewayResponse" : {
    "gatewayDate" : "2020-10-23T15:21:58.833Z",
    "gatewayReferenceNumber" : "439XXXXXXX",
    "gatewayResultCode" : "00",
    "gatewayResultCodeDescription" : "Transaction Normal",
    "salesforceResultCode" : "Success"
  },
  "paymentAuthAdjustment" : {
    "amount" : "150.0",
    "currencyIsoCode" : "USD",
    "effectiveDate" : "2020-10-18T11:32:27.000Z",
    "id" : "9tvR00000004Cf1MAE",
    "paymentAuthAdjustmentNumber" : "PAA-00XXXXXXX",
    "requestDate" : "2020-10-23T15:21:58.000Z",
    "status" : "Processed"
  },
  "paymentGatewayLogs" : \[ {
    "createdDate" : "2020-10-23T15:21:58.000Z",
    "gatewayResultCode" : "00",
    "id" : "0XtXXXXXXXXXXXXXXX",
    "interactionStatus" : "Success"
  } \]
}

The resulting payment authorization adjustment in Salesforce would look like this.

If an error is returned, the response contains the gateway's error code and error message.

**Sample Response - Error**

{
    "errorCode":"",
    "errorMessage":""
}