> ## Documentation Index
> Fetch the complete documentation index at: https://docs.tesouro.com/llms.txt
> Use this file to discover all available pages before exploring further.

# refundPreviousPayment

> Refund a previously authorized payment using its payment ID and return a payload that includes details of the resulting transaction.

`Mutation`

## Arguments

<ParamField path="refundPreviousPaymentInput" type="RefundPreviousPaymentInput!" required>
  <Expandable title="child attributes">
    <ParamField path="acceptorId" type="UUID!" required>
      A unique, 36 character identifier created by Tesouro and assigned to the entity providing the goods or services to the cardholder, such as a Merchant, a Submerchant of a Payment Facilitator, a Seller within a Marketplace, or a Biller of a Consumer Bill Payment Service Provider (CBPS). Historically, processors have called this identifier the Merchant ID (or MID), Outlet ID, or Customer number.
    </ParamField>

    <ParamField path="lineItems" type="[LineItemInput!]">
      Line item details for this order. If line items are provided on the refund any line items from the original authorization will be overridden. If line items are provided, transactionAmountDetails must be provided.

      See [LineItemInput](/acquiring/reference/graphql/types/line-item-input)
    </ParamField>

    <ParamField path="orderDetails" type="OrderDetailsInput">
      Details pertaining to the customer's order. If null, order details from the original authorization will be used. If provided, all details from the original authorization will be overridden.

      See [OrderDetailsInput](/acquiring/reference/graphql/types/order-details-input)
    </ParamField>

    <ParamField path="paymentId" type="UUID!" required>
      The unique 'paymentId' of the payment that is to be refunded.
    </ParamField>

    <ParamField path="transactionAmountDetails" type="AmountDetailsInput">
      The partial or full amount of the transaction to be refunded. If you do not specify an amount, Tesouro will refund the full amount.

      <Expandable title="child attributes">
        <ParamField path="baseAmount" type="DecimalAmount" deprecated>
          The base transaction amount intended to be collected by this payment not including any cashback, gratuity, fees, or taxes.

          **Deprecated:** Use subtotalAmount instead.
        </ParamField>

        <ParamField path="cashBackAmount" type="DecimalAmount">
          The cash back amount. Must be a non-negative value.
        </ParamField>

        <ParamField path="currency" type="TransactionAmountCurrencyCode!" required>
          The purchasing currency code of the request amount.

          See [TransactionAmountCurrencyCode](/acquiring/reference/graphql/types/transaction-amount-currency-code)
        </ParamField>

        <ParamField path="discountAmount" type="Decimal">
          Total discount amount applied to the order. Must be a non-negative value.
        </ParamField>

        <ParamField path="dutyAmount" type="Decimal">
          Total charges for any import or export duties included in the order. Must be a non-negative value.
        </ParamField>

        <ParamField path="gratuityAmount" type="DecimalAmount">
          The gratuity amount. Must be a non-negative value.
        </ParamField>

        <ParamField path="localTaxAmount" type="Decimal">
          The total amount of local tax for this payment transaction request. Local tax is imposed by municipal, city, or regional governments and may include sales tax, service tax, or other location-based levies applicable to the transaction. Must be a non-negative value.
        </ParamField>

        <ParamField path="nationalTaxAmount" type="Decimal">
          The total amount of national tax for this payment transaction request. National tax is a government-imposed tax at the federal or country level, such as Goods and Services Tax (GST), or federal sales tax. Must be a non-negative value.
        </ParamField>

        <ParamField path="shippingAmount" type="Decimal">
          Total shipping charges for the transaction. Must be a non-negative value.
        </ParamField>

        <ParamField path="subtotalAmount" type="DecimalAmount">
          The sum of all item costs in the transaction before applying any additional charges such as taxes, or fees. Must be a non-negative value.
        </ParamField>

        <ParamField path="totalAmount" type="Decimal!" required>
          The requested amount intended to be collected by this transaction. A positive decimal with precision depending on transaction currency. For example: \$10.00 would be 10.00 or 10.
        </ParamField>

        <ParamField path="totalTaxAmount" type="Decimal">
          The total amount of all taxes for this payment transaction request. Must be present if either local or national tax are present. Must be a non-negative value.
        </ParamField>
      </Expandable>
    </ParamField>

    <ParamField path="transactionReference" type="Max36Text!" required>
      A unique identifier created by the entity holding the direct relationship with the Acceptor, and used by that entity for reconciliation and transaction search. Tesouro uses this identifier to manage idempotency.
    </ParamField>
  </Expandable>
</ParamField>

## Return type

`RefundPreviousPaymentPayload!`

<ResponseField name="errors" type="[RefundPreviousPaymentError!]">
  <Expandable title="Possible types">
    <Expandable title="InternalServiceError">
      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>
    </Expandable>

    <Expandable title="RuleInViolationError">
      This occurs when an internal Tesouro business rule is in violation.

      <ResponseField name="advice" type="String!" required>
        Advice on how to overcome the rule in the future.
      </ResponseField>

      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="explanationOfRule" type="String!" required>
        An explanation of why the rule exists.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="ruleName" type="RuleName!" required>
        The name of the rule in violation

        See [RuleName](/acquiring/reference/graphql/types/rule-name)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>
    </Expandable>

    <Expandable title="SyntaxOnNetworkResponseError">
      <ResponseField name="attemptedNetwork" type="Network!" required>
        The network the transaction request was attempted with.

        See [Network](/acquiring/reference/graphql/types/network)
      </ResponseField>

      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>
    </Expandable>

    <Expandable title="TimeoutOnNetworkResponseError">
      <ResponseField name="attemptedNetwork" type="Network!" required>
        The network the authorization was attempted.

        See [Network](/acquiring/reference/graphql/types/network)
      </ResponseField>

      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>

      <ResponseField name="waitTime" type="Int!" required>
        The amount of time Tesouro waited for a response in milliseconds.
      </ResponseField>
    </Expandable>

    <Expandable title="ValidationFailureError">
      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="fieldName" type="String!" required>
        The name of the graphql field in error.
      </ResponseField>

      <ResponseField name="fieldPath" type="String!" required>
        The path to the graphql field in error.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>

      <ResponseField name="valueInError" type="String!" required>
        The value of the graphql field in error.
      </ResponseField>
    </Expandable>

    <Expandable title="PriorPaymentNotFoundError">
      This occurs when a prior referenced payment cannot be found

      <ResponseField name="dateTimeUtc" type="DateTime!" required deprecated>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.

        **Deprecated:** Use errorDateTime instead.
      </ResponseField>

      <ResponseField name="errorDateTime" type="DateTime!" required>
        The date and time, in UTC, that the error occured. Formatted as 2024-03-27T02:40:00Z.
      </ResponseField>

      <ResponseField name="message" type="String!" required>
        A human readable description of the error.
      </ResponseField>

      <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
        Tesouro response code indicating the error.

        See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
      </ResponseField>

      <ResponseField name="transactionId" type="UUID!" required>
        Unique ID for the transaction assigned by Tesouro.
      </ResponseField>

      <ResponseField name="unknownPaymentId" type="UUID!" required>
        The payment id that cannot be found.
      </ResponseField>
    </Expandable>
  </Expandable>
</ResponseField>

<ResponseField name="refundPreviousPaymentResponse" type="RefundPreviousPaymentResponse">
  <Expandable title="child attributes">
    <ResponseField name="activityDate" type="Date!" required>
      The date Tesouro received the transaction based on acceptor cutoff time
    </ResponseField>

    <ResponseField name="cardDetails" type="CardInformation" deprecated>
      Details related to the card used on the transaction

      **Deprecated:** Use paymentMethodResponse instead.

      See [CardInformation](/acquiring/reference/graphql/types/card-information)
    </ResponseField>

    <ResponseField name="duration" type="Int!" required deprecated>
      Difference between request receipt and response in milliseconds.

      **Deprecated:** New durations coming soon.
    </ResponseField>

    <ResponseField name="isDuplicateRequest" type="Boolean!" required>
      Result of Tesouro's idempotency check. If the transaction reference matches that of another transaction from that presenter it will be treated as a duplicate.
    </ResponseField>

    <ResponseField name="message" type="String!" required>
      A detailed description of the response code. e.g., Insufficient funds.
    </ResponseField>

    <ResponseField name="networkResponseDetails" type="NetworkResponseDetails!" required deprecated>
      The response code from the network.

      **Deprecated:** Use paymentMethodResponse instead.

      See [NetworkResponseDetails](/acquiring/reference/graphql/types/network-response-details)
    </ResponseField>

    <ResponseField name="paymentId" type="UUID!" required>
      A unique 36 character identifier created by Tesouro and assigned to a group of transactions in the same payment request cohort. e.g., An authorization request, incremental authorization request, and the final capture would have the same paymentID.
    </ResponseField>

    <ResponseField name="paymentMethodResponse" type="PaymentMethodResponse!" required>
      Details related to the payment method used on the transaction

      <Expandable title="child attributes">
        <ResponseField name="bankPaymentMethodDetails" type="BankPaymentMethodDetailsResponse">
          <Expandable title="child attributes">
            <ResponseField name="acquirerTokenDetails" type="AcquirerTokenDetails!" required>
              Details associated with the token generated on a tokenization request.
            </ResponseField>

            <ResponseField name="paymentBrand" type="PaymentBrand!" required>
              Specifies which payment brand was used, e.g., Visa, MasterCard, Discover, American Express, etc.

              See [PaymentBrand](/acquiring/reference/graphql/types/payment-brand)
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="cardPaymentMethodDetails" type="CardPaymentMethodDetailsResponse">
          <Expandable title="child attributes">
            <ResponseField name="acquirerTokenDetails" type="AcquirerTokenDetails!" required>
              Details associated with the token generated on a tokenization request.
            </ResponseField>

            <ResponseField name="cardDetails" type="CardInformation!" required>
              Details related to the card used on the transaction
            </ResponseField>

            <ResponseField name="networkResponseDetails" type="NetworkResponseDetails!" required>
              The response code from the network.
            </ResponseField>

            <ResponseField name="paymentBrand" type="PaymentBrand!" required>
              Specifies which payment brand was used, e.g., Visa, MasterCard, Discover, American Express, etc.

              See [PaymentBrand](/acquiring/reference/graphql/types/payment-brand)
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>

    <ResponseField name="processorResponseCode" type="ProcessorResponseCode!" required>
      A normalized 4-character response code defined by Tesouro that represents the outcome of the payment transaction request.

      See [ProcessorResponseCode](/acquiring/reference/graphql/types/processor-response-code)
    </ResponseField>

    <ResponseField name="sanitizedFields" type="[SanitizedFieldOutput!]!" required>
      List of fields that were detected as invalid and sanitized by Tesouro to prevent the payment transaction request from failing.

      See [SanitizedFieldOutput](/acquiring/reference/graphql/types/sanitized-field-output)
    </ResponseField>

    <ResponseField name="timestampUtc" type="DateTime!" required>
      The UTC date and time the transaction was received by Tesouro.
    </ResponseField>

    <ResponseField name="tokenDetails" type="TokenDetails">
      Details associated with the token generated on a tokenization request.

      See [TokenDetails](/acquiring/reference/graphql/types/token-details)
    </ResponseField>

    <ResponseField name="transactionId" type="UUID!" required>
      A unique identifier created by Tesouro and assigned to the transaction.
    </ResponseField>
  </Expandable>
</ResponseField>

<RequestExample>
  ```graphql Operation lines expandable theme={null}
  mutation RefundPreviousPayment($refundPreviousPaymentInput: RefundPreviousPaymentInput!) {
    refundPreviousPayment(refundPreviousPaymentInput: $refundPreviousPaymentInput) {
      errors {
        ... on InternalServiceError {
          dateTimeUtc
          errorDateTime
          message
          processorResponseCode
          transactionId
        }
        ... on RuleInViolationError {
          advice
          dateTimeUtc
          errorDateTime
          explanationOfRule
          message
        }
        ... on SyntaxOnNetworkResponseError {
          attemptedNetwork
          dateTimeUtc
          errorDateTime
          message
          processorResponseCode
        }
        ... on TimeoutOnNetworkResponseError {
          attemptedNetwork
          dateTimeUtc
          errorDateTime
          message
          processorResponseCode
        }
        ... on ValidationFailureError {
          dateTimeUtc
          errorDateTime
          fieldName
          fieldPath
          message
        }
        ... on PriorPaymentNotFoundError {
          dateTimeUtc
          errorDateTime
          message
          processorResponseCode
          transactionId
        }
      }
      refundPreviousPaymentResponse {
        activityDate
        cardDetails {
          last4
          paymentBrand
        }
        duration
        isDuplicateRequest
        message
        networkResponseDetails {
          networkResponseCode
          processorResponseCode
        }
        paymentId
        paymentMethodResponse {

        }
        processorResponseCode
        sanitizedFields {
          fieldName
          fieldPath
          originalValue
          reason
          sanitizedValue
        }
        timestampUtc
        tokenDetails {
          token
          tokenizedPan
        }
        transactionId
      }

  }
  }

  ```

  ```json Variables lines expandable theme={null}
  {
    "refundPreviousPaymentInput": {
      "acceptorId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
      "paymentId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
      "transactionReference": "example"
    }
  }
  ```

  ```bash cURL lines expandable theme={null}
  curl --request POST \
    --url https://api.sandbox.com/graphql \
    --header 'Content-Type: application/json' \
    --header 'Authorization: Bearer <YOUR_ACCESS_TOKEN>' \
    --data '{
    "query": "mutation RefundPreviousPayment($refundPreviousPaymentInput: RefundPreviousPaymentInput!) {\n  refundPreviousPayment(refundPreviousPaymentInput: $refundPreviousPaymentInput) {\n    errors {\n      ... on InternalServiceError {\n        dateTimeUtc\n        errorDateTime\n        message\n        processorResponseCode\n        transactionId\n      }\n      ... on RuleInViolationError {\n        advice\n        dateTimeUtc\n        errorDateTime\n        explanationOfRule\n        message\n      }\n      ... on SyntaxOnNetworkResponseError {\n        attemptedNetwork\n        dateTimeUtc\n        errorDateTime\n        message\n        processorResponseCode\n      }\n      ... on TimeoutOnNetworkResponseError {\n        attemptedNetwork\n        dateTimeUtc\n        errorDateTime\n        message\n        processorResponseCode\n      }\n      ... on ValidationFailureError {\n        dateTimeUtc\n        errorDateTime\n        fieldName\n        fieldPath\n        message\n      }\n      ... on PriorPaymentNotFoundError {\n        dateTimeUtc\n        errorDateTime\n        message\n        processorResponseCode\n        transactionId\n      }\n    }\n    refundPreviousPaymentResponse {\n      activityDate\n      cardDetails {\n        last4\n        paymentBrand\n      }\n      duration\n      isDuplicateRequest\n      message\n      networkResponseDetails {\n        networkResponseCode\n        processorResponseCode\n      }\n      paymentId\n      paymentMethodResponse {\n\n      }\n      processorResponseCode\n      sanitizedFields {\n        fieldName\n        fieldPath\n        originalValue\n        reason\n        sanitizedValue\n      }\n      timestampUtc\n      tokenDetails {\n        token\n        tokenizedPan\n      }\n      transactionId\n    }\n  }\n}",
    "variables": {
      "refundPreviousPaymentInput": {
        "acceptorId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
        "paymentId": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
        "transactionReference": "example"
      }
    }
  }'
  ```
</RequestExample>

<ResponseExample>
  ```json Response lines expandable theme={null}
  {
    "data": {
      "refundPreviousPayment": {
        "errors": [
          {
            "__typename": "InternalServiceError",
            "dateTimeUtc": "2026-01-15T14:30:00Z",
            "errorDateTime": "2026-01-15T14:30:00Z",
            "message": "example",
            "processorResponseCode": "A0000",
            "transactionId": "c9a1e2d3-4b5f-6789-0abc-def123456789"
          }
        ],
        "refundPreviousPaymentResponse": {
          "activityDate": "2026-01-15",
          "cardDetails": {
            "last4": "1234",
            "paymentBrand": "VISA"
          },
          "duration": 0,
          "isDuplicateRequest": true,
          "message": "example",
          "networkResponseDetails": {
            "networkResponseCode": "example",
            "processorResponseCode": "A0000"
          },
          "paymentId": "d8b2f3e4-5c6a-7890-1bcd-ef2345678901",
          "paymentMethodResponse": {
            "bankPaymentMethodDetails": "example",
            "cardPaymentMethodDetails": "example"
          },
          "processorResponseCode": "A0000",
          "sanitizedFields": [
            {
              "fieldName": "example",
              "fieldPath": "example",
              "originalValue": "example",
              "reason": "example",
              "sanitizedValue": "example"
            }
          ],
          "timestampUtc": "2026-01-15T14:30:00Z",
          "tokenDetails": {
            "token": "example",
            "tokenizedPan": "example"
          },
          "transactionId": "e7c3a4b5-6d7e-8901-2cde-f34567890123"
        }
      }
    }
  }
  ```
</ResponseExample>
