Skip to main content

reverse Method

Overview

The reverse method cancels a captured payment before the funds have been settled. Unlike voids (which apply to authorized but not captured payments), reverses apply to captured payments that haven't completed bank settlement.

Business Use Case: When an error is discovered immediately after capture, such as incorrect amount charged or duplicate transaction. Reverse allows you to recover funds before they enter the settlement cycle.

Purpose

ScenarioBenefit
Same-day cancellationRecover funds before settlement
Processing errorUndo incorrect capture
Duplicate transactionReverse accidental double charge

Request Fields

FieldTypeRequiredDescription
merchantReverseIdstringYesYour unique reverse operation ID
connectorTransactionIdstringYesThe connector's transaction ID
cancellationReasonstringNoReason for reversing

Response Fields

FieldTypeDescription
merchantReverseIdstringYour reference (echoed back)
connectorTransactionIdstringConnector's transaction ID
statusPaymentStatusVOIDED, REVERSED
errorErrorInfoError details if failed
statusCodenumberHTTP status code

Example

SDK Setup

const { PaymentClient } = require('hyperswitch-prism');

const paymentClient = new PaymentClient({
connector: 'stripe',
apiKey: 'YOUR_API_KEY',
environment: 'SANDBOX'
});

Request

const request = {
merchantReverseId: "reverse_001",
connectorTransactionId: "pi_3Oxxx...",
cancellationReason: "Duplicate charge detected"
};

const response = await paymentClient.reverse(request);

Response

{
merchantReverseId: "reverse_001",
connectorTransactionId: "pi_3Oxxx...",
status: "VOIDED",
statusCode: 200
}

Reverse vs Void vs Refund

ActionWhen to UseTimeline
VoidBefore captureSame day
ReverseAfter capture, before settlementSame day
RefundAfter settlement5-10 business days

Next Steps

  • capture - Capture a payment after authorization
  • void - Cancel before capture
  • refund - Return funds after settlement