Skip to main content
The process of sending money back to a customer who has returned a purchase or no longer wants to receive services.
When to Use
  • A customer returns a product or cancels a service after you’ve already captured payment.
  • You need to issue a full or partial refund for a completed transaction.
  • You’ve made a billing error and need to return funds to the customer.
ScenarioBen returns two mechanical keyboards he purchased with his card ending in 4242. Upon receiving the merchandise, CoolTechGear.com verifies the original order number and issues a $300 refund back to Ben’s card.

Steps

  1. Retrieve the paymentId from the original transaction. This is how we link the refund to the previous payment.
  2. Call the refundPreviousPayment mutation, passing in the required input fields:
    Required inputDescription
    paymentIdThe unique “payment ID” returned on the original, approved transaction, used to tie that transactions together.
    acceptorIdThe unique, 36 character identifier assigned to the entity providing the goods or services to the customer. Other processors may refer to this as the Merchant ID (MID), Outlet ID, or Customer number.
    transactionReferenceThe unique transaction identifier created by YOU to distinguish this transaction from another.
    transactionAmountDetailsThe transaction currency and amount to be refunded. You can refund the full amount or only a portion of it. If you do not specify an amount, Tesouro will by default refund the full amount.
mutation refundPreviousPayment($input: RefundPreviousPaymentInput!) {
  refundPreviousPayment(refundPreviousPaymentInput: $input) {
    refundPreviousPaymentResponse {
      status: __typename
      activityDate
      transactionId
      paymentId
      activityDate
    }
    errors {
      errorType: __typename
      ... on RuleInViolationError {
        advice
        explanationOfRule
        ruleName
      }
      ... on ValidationFailureError {
        fieldName
        fieldPath
        valueInError
      }
      ... on IGraphQlError {
        message
        transactionId
        processorResponseCode
      }
    }
  }
}
{
  "data": {
    "refundWithReference": {
      "transactionInformation": {
        "paymentId": "64495c8b-4c0f-11ee-bf97-0e7d489d8cb0"
      }
    }
  }
}
Run in Playground