Skip to main content

refund Method

Overview

The refund method returns funds to a customer's payment method after a successful payment. Use this for returns, cancellations after fulfillment, or goodwill adjustments.

Business Use Case: A customer returns an item they purchased. The original payment was already captured. You process a refund to return their money.

Purpose

Why use refund?

ScenarioBenefit
Product returns - Refund customers for returned merchandise
Service cancellation - Refund for unrendered services
Goodwill gestures - Partial refunds for service issues
Duplicate charges - Correct accidental charges

Request Fields

FieldTypeRequiredDescription
merchantRefundIdstringYesYour unique refund reference
connectorTransactionIdstringYesThe connector's transaction ID from the payment
refundAmountMoneyYesAmount to refund (can be partial)
reasonstringNoReason for refund
metadataobjectNoAdditional data (max 20 keys)

Response Fields

FieldTypeDescription
merchantRefundIdstringYour refund reference (echoed back)
connectorRefundIdstringConnector's refund ID (e.g., re_xxx)
statusRefundStatusCurrent status: PENDING, SUCCEEDED, FAILED
refundAmountMoneyRefund amount
errorErrorInfoError details if status is FAILED
statusCodenumberHTTP-style status code (200, 422, etc.)

Example

SDK Setup

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

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

Request

const request = {
merchantRefundId: "refund_001",
connectorTransactionId: "pi_3Oxxx...",
refundAmount: {
minorAmount: 1000,
currency: "USD"
},
reason: "Customer returned item"
};

const response = await paymentClient.refund(request);

Response

{
merchantRefundId: "refund_001",
connectorRefundId: "re_3Oxxx...",
status: "PENDING",
refundAmount: {
minorAmount: 1000,
currency: "USD"
},
statusCode: 200
}

Refund vs Void vs Reverse

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

Next Steps

  • getRefund - Check refund status
  • capture - Ensure payment is captured before refunding
  • void - Cancel if still in authorized state