# Refund transactions

Cancel or refund Stripe Terminal payments.

Stripe Terminal supports both *automatic* (Automatically capture funds when a charge is authorized) and *manual* (Manually capture funds separately from an authorization) capture.

If a payment is authorized but hasn’t been [captured](https://docs.stripe.com/terminal/payments/collect-card-payment.md#capture-payment), you can [cancel](https://docs.stripe.com/terminal/features/refunds.md#canceling-payments) it. With manual capture, a confirmed `PaymentIntent` stays uncaptured until you capture it. With automatic capture, Stripe captures it for you. After the payment is captured, [refund](https://docs.stripe.com/terminal/features/refunds.md#refunds) it using the [Refunds API](https://docs.stripe.com/api.md#create_refund), the [Dashboard](https://docs.stripe.com/refunds.md?dashboard-or-api=dashboard), or, in private preview, the [Terminal iOS or Android SDK](https://docs.stripe.com/terminal/features/refunds.md#client-side-refunds).

We recommend [reconciling payments](https://docs.stripe.com/terminal/payments/collect-card-payment.md?terminal-sdk-platform=js#reconciling) on your back end after a day’s activity to prevent unintended authorizations and uncollected funds.

## Availability

**Canceling payments** is available on Visa, Mastercard, American Express, Discover, and girocard. For single-message payment methods like [Interac](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#interac-payments) and [eftpos](https://docs.stripe.com/terminal/payments/regional.md?integration-country=AU#eftpos-payments), PaymentIntents are automatically captured. In lieu of canceling PaymentIntents, make sure your application can allow initiating a refund at the end of the checkout flow.

**Online refunds** are available on all card networks except for Interac. You can also initiate online refunds for card payments from the [Terminal iOS or Android SDK](https://docs.stripe.com/terminal/features/refunds.md#client-side-refunds) (Private preview).

[In-person refunds](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#refund-an-interac-payment) are only available on Interac.

## Cancel payments (Client-side)(Server-side) 

- [cancelPaymentIntent (iOS)](https://stripe.dev/stripe-terminal-ios/docs/Classes/SCPTerminal.html#/c:objc\(cs\)SCPTerminal\(im\)cancelPaymentIntent:completion:)
- [cancelPaymentIntent (Android)](https://stripe.dev/stripe-terminal-android/core/com.stripe.stripeterminal/-terminal/cancel-payment-intent.html)
- [cancelPaymentIntent (React Native)](https://stripe.dev/stripe-terminal-react-native/api-reference/interfaces/WithStripeTerminalProps.html#cancelpaymentintent)
- [cancelPaymentIntent (Java)](https://stripe.dev/stripe-terminal-java/core/com.stripe.stripeterminal/-terminal/cancel-payment-intent.html)

You can [cancel](https://docs.stripe.com/api.md#cancel_payment_intent) a `card_present` PaymentIntent at any time before it has been captured. Canceling a PaymentIntent releases all uncaptured funds, and a canceled PaymentIntent can no longer be used to perform charges.

Use this when, for example, your customer decides to use a different payment method or pay with cash after the payment has been processed. In your application’s UI, consider allowing your customer to cancel after they [confirm the payment](https://docs.stripe.com/terminal/payments/collect-card-payment.md?process=inspect#confirm-payment), and before you finalize it and notify your back end to [capture](https://docs.stripe.com/terminal/payments/collect-card-payment.md#capture-payment).

#### Client-side

Cancel a `PaymentIntent` from your client using the iOS, Android, or React Native SDK:

# JavaScript


> Client-side `PaymentIntent` cancellation is possible with the other client SDKs. If you’re using the JavaScript SDK for Stripe Terminal, cancel the `PaymentIntent` server-side.


#### Server-side

- [Cancel a PaymentIntent](https://docs.stripe.com/api/payment_intents/cancel.md)

The JavaScript SDK and server-driven integration require you to cancel the `PaymentIntent` on your server. For the other client SDKs, you can cancel the `PaymentIntent` on your server if the information required to start a payment isn’t readily available in your app.

```curl
curl -X POST https://api.stripe.com/v1/payment_intents/{{PAYMENT_INTENT_ID}}/cancel \
  -u "<<YOUR_SECRET_KEY>>:"
```

## Perform refunds (Server-side) 

When you use a PaymentIntent to collect payment from a customer, Stripe creates a [charge](https://docs.stripe.com/api/charges/object.md) behind the scenes. To refund the customer’s payment after the PaymentIntent has succeeded, [create a refund](https://docs.stripe.com/api.md#create_refund) by passing in the PaymentIntent ID or the charge ID. You can also optionally refund part of a payment by specifying an amount.

You can perform refunds [with the API](https://docs.stripe.com/refunds.md?dashboard-or-api=api), [through the Dashboard](https://docs.stripe.com/refunds.md?dashboard-or-api=dashboard), or, in private preview, [from the iOS or Android SDK](https://docs.stripe.com/terminal/features/refunds.md#client-side-refunds). For Interac transactions in Canada, you can provide [in-person refunds](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#refund-an-interac-payment) on the BBPOS WisePad 3, BBPOS WisePOS E, Stripe Reader S700/S710, Tap to Pay on iPhone, or Tap to Pay on Android.

Online refunds don’t require a cardholder to present their card again at the point of sale. The following example shows how to create a full refund by passing in the PaymentIntent ID.

```curl
curl https://api.stripe.com/v1/refunds \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d payment_intent=pi_Aabcxyz01aDfoo
```

To refund part of a PaymentIntent, provide an `amount` parameter, as an integer in cents (or the charge currency’s smallest currency unit):

```curl
curl https://api.stripe.com/v1/refunds \
  -u "<<YOUR_SECRET_KEY>>:" \
  -d payment_intent=pi_Aabcxyz01aDfoo \
  -d amount=1000
```

## Refund from the iOS or Android SDK (Client-side) (Private preview) 

- [confirmRefund (iOS)](https://stripe.dev/stripe-terminal-ios/docs/Classes/SCPTerminal.html#/c:objc\(cs\)SCPTerminal\(im\)confirmRefund:completion:)
- [ConfirmRefundParameters (iOS)](https://stripe.dev/stripe-terminal-ios/docs/Classes/SCPConfirmRefundParameters.html)
- [confirmRefund (Android)](https://stripe.dev/stripe-terminal-android/core/com.stripe.stripeterminal/-terminal/confirm-refund.html)
- [ConfirmRefundParameters (Android)](https://stripe.dev/stripe-terminal-android/external/com.stripe.stripeterminal.external.models/-confirm-refund-parameters/index.html)

Use `confirmRefund` to refund a captured card payment from your iOS or Android app with [Terminal SDK](https://docs.stripe.com/terminal/payments/setup-integration.md) version 6.0.0 or later. The method doesn’t collect a payment method, display reader UI, or require the cardholder to present their card. It needs an internet connection and a [connected reader](https://docs.stripe.com/terminal/payments/connect-reader.md), which authenticates the request. To request access to the private preview, contact [Stripe Support](https://support.stripe.com/).

For server-driven integrations and the Terminal JavaScript, React Native, Java, and .NET SDKs, [create the refund on your server](https://docs.stripe.com/terminal/features/refunds.md#refunds) using the [Refunds API](https://docs.stripe.com/api/refunds/create.md).

### Choose a refund method

`confirmRefund` is one of several ways to refund a Terminal payment:

| Method | When to use | Requires card presentation | Reader UI |
| --- | --- | --- | --- |
| `confirmRefund` (Private preview) | Refund a captured card `PaymentIntent` from your iOS or Android app without a server endpoint for creating refunds | No | No |
| `processRefund` | Interac refunds | Yes | Yes |
| Refunds API or Dashboard | Refund from your server or the Dashboard | No | No |

For [Interac refunds](https://docs.stripe.com/terminal/payments/regional.md?integration-country=CA#refund-an-interac-payment), use `processRefund` instead of `confirmRefund`.

### Create a full or partial refund

Build `ConfirmRefundParameters` with the ID and matching client secret of the captured `PaymentIntent`, and pass them to `confirmRefund`. If these values aren’t available in your app, retrieve the `PaymentIntent` on your server and pass them securely to your app. Charge IDs aren’t supported. Don’t log or store the client secret.

> #### Protect the client secret
> 
> `confirmRefund` uses the client secret to authorize a refund of the payment. If your server returns a client secret to your app, first authenticate the app user and confirm that they’re authorized to refund that payment. Keep your secret API key on your server.

If you omit `amount`, Stripe refunds the full remaining refundable amount. To refund part of a payment, set `amount` in the payment currency’s [smallest unit](https://docs.stripe.com/currencies.md). The amount can’t exceed the remaining refundable amount.

The following examples refund `1000` of the payment and pass the result to `handleRefund` and `handleRefundError`, which are methods that you define.

#### iOS

#### Swift

```swift
do {
    let refundParams = try ConfirmRefundParametersBuilder(
        paymentIntentId: paymentIntentId,
        clientSecret: paymentIntentClientSecret
    )
    .setAmount(1000)
    .build()

    Terminal.shared.confirmRefund(refundParams) { refund, error in
        if let refund = refund {
            // Stripe created the refund. Check refund.status.
            self.handleRefund(refund)
        } else if let error = error {
            if let failedRefund = error.refund {
                // Stripe created the refund, but it failed.
                self.handleRefund(failedRefund)
            } else {
                // No refund is attached. Reconcile before retrying.
                self.handleRefundError(error)
            }
        }
    }
} catch {
    // Handle invalid refund parameters.
}
```

#### Android

#### Kotlin

```kotlin
val refundParams = ConfirmRefundParameters.Builder(
    paymentIntentId = paymentIntentId,
    clientSecret = paymentIntentClientSecret
)
    .setAmount(1000L)
    .build()

Terminal.getInstance().confirmRefund(
    refundParams,
    object : RefundCallback {
        override fun onSuccess(refund: Refund) {
            // Stripe created the refund. Check refund.status.
            handleRefund(refund)
        }

        override fun onFailure(e: TerminalException) {
            val failedRefund = e.refund
            if (failedRefund != null) {
                // Stripe created the refund, but it failed.
                handleRefund(failedRefund)
            } else {
                // No refund is attached. Reconcile before retrying.
                handleRefundError(e)
            }
        }
    }
)
```

### Handle the result 

A successful result means that Stripe created a `Refund`, not that the refund is complete. Check the [refund status](https://docs.stripe.com/api/refunds/object.md#refund_object-status) in your `handleRefund` method.

If the request fails without an attached `Refund`, the outcome might be unknown. Reconcile it on your server before you create another refund.

## See also

- [Cart display](https://docs.stripe.com/terminal/features/display.md)
- [Receipts](https://docs.stripe.com/terminal/features/receipts.md)
