ds@mcpanalytics.aiEmail your data and your question and get an answer about your own data, with the method shown.Email your data and question. Get an answer.

How to Use Refund Analysis in Stripe: Step-by-Step Tutorial

By MCP Analytics Team | Published , updated

Category: Stripe Analytics | Published By MCP Analytics Team | Last reviewed: November 2, 2026

Understanding Why Customers Request Refunds

A refund rate is a fraction, and the first decision is what goes in the denominator. This tutorial computes it from paid charges (the denominator) and succeeded refunds (the numerator), then breaks it down by charge month, by reason and by product, and says how much weight each difference can bear.

About the numbers on this page. Every output below was produced by running the code shown against a small synthetic Stripe account, made by the generator in the next section: 3,000 paid charges between July and December 2024, three products, some euro charges, and refunds whose rates we set ourselves. It is not a real account, and your numbers will differ.

Prerequisites and Data Requirements

Two documented facts shape the method. A refund's reason is either supplied by you (duplicate, fraudulent or requested_by_customer), generated by Stripe (expired_uncaptured_charge), or null, and a refund's status can be pending, requires_action, succeeded, failed or canceled (Refund object). So reason is empty whenever nobody set it, and only succeeded refunds should count. Both list endpoints return at most 100 objects per request and accept a created filter (List refunds, List charges), so the code pages through with auto_paging_iter().

Try It Without a Stripe Account: The Synthetic Data

The block below makes fake charges and refunds that look like the objects the Stripe API returns, and swaps in a stand-in for the stripe package. Run it first, then run the Step 1 to 4 code unchanged. The seed is fixed, so you get the same numbers shown on this page. The settings are ours, not measured from any business: refund chances of 2% for plan_a, 3% for plan_b and 10% for plan_c, a refund delay that averages 8 days, 6% of charges in euros, 150 failed charge attempts, and 5 refunds that failed. The data stops on January 10, 2025, so December charges have had less time to collect refunds than July charges. To use your own account, skip this block and keep the real stripe package.

import random, sys, types
from datetime import datetime, timedelta, timezone
from types import SimpleNamespace as NS

def make_synthetic_stripe(seed=2024):
    """SYNTHETIC charges and refunds shaped like Stripe API objects. Not real data."""
    rng = random.Random(seed)
    cutoff = datetime(2025, 1, 10, tzinfo=timezone.utc)          # the day the data stops
    refund_prob = {'plan_a': 0.02, 'plan_b': 0.03, 'plan_c': 0.10}
    charges, refunds = [], []
    start = datetime(2024, 7, 1, tzinfo=timezone.utc)
    for i in range(3150):
        created = start + timedelta(seconds=rng.randint(0, 184 * 86400 - 1))   # July 1 to Dec 31
        product = rng.choices(['plan_a', 'plan_b', 'plan_c'], [0.41, 0.30, 0.29])[0]
        currency = 'eur' if rng.random() < 0.06 else 'usd'
        amount = rng.choice([2900, 4900, 7900]) if product != 'plan_c' else rng.choice([4900, 9900])
        paid = i >= 150                                          # the first 150 are failed attempts
        cid = f"ch_{i:05d}"
        charges.append(NS(id=cid, created=int(created.timestamp()), amount=amount, currency=currency,
                          paid=paid, status='succeeded' if paid else 'failed',
                          metadata=NS(to_dict=lambda p=product: {'product': p})))
        if paid and rng.random() < refund_prob[product]:
            when = created + timedelta(days=rng.expovariate(1 / 8.0))
            if when < cutoff:
                reason = rng.choices(['requested_by_customer', None, 'duplicate', 'fraudulent'], [65, 25, 6, 4])[0]
                full = rng.random() < 0.8
                refunds.append(NS(charge=cid, created=int(when.timestamp()),
                                  amount=amount if full else amount // 2, reason=reason, status='succeeded'))
    for _ in range(5):                                           # a few refunds that did not go through
        c = rng.choice(charges[150:])
        refunds.append(NS(charge=c.id, created=c.created + 86400, amount=c.amount, reason=None, status='failed'))
    return charges, refunds

_CHARGES, _REFUNDS = make_synthetic_stripe()

def _listing(items):
    def lst(created=None, limit=100):
        lo = (created or {}).get('gte', 0)
        hi = (created or {}).get('lt', 10**12)
        return NS(auto_paging_iter=lambda: iter([x for x in items if lo <= x.created < hi]))
    return lst

# Stand-in for the stripe package, so the Step 1 code runs unchanged without an account.
sys.modules['stripe'] = types.SimpleNamespace(
    api_key=None, Charge=NS(list=_listing(_CHARGES)), Refund=NS(list=_listing(_REFUNDS)))

This is a stand-in written for the tutorial, not a Stripe feature. If you would rather test against Stripe itself, its testing page says a sandbox lets you test without real charges or payments, using test API keys.

Step 1: Pull Charges and Refunds, and Join Them

A refund rate needs all paid charges, not only the refunded ones. A list of refunded payments alone has no denominator, so it cannot give a rate. The code lists every paid charge in the period and every succeeded refund created since the period began, then joins them on the charge ID. A charge can have several refunds, so refunds are summed per charge first. Amounts are in minor units; the two currencies are shown separately and are never added together.

import stripe
import pandas as pd
from datetime import datetime, timezone

stripe.api_key = 'sk_test_...'  # restricted key with read access to charges and refunds

start = int(datetime(2024, 7, 1, tzinfo=timezone.utc).timestamp())
end = int(datetime(2025, 1, 1, tzinfo=timezone.utc).timestamp())      # exclusive

charges = pd.DataFrame([{
    'charge_id': c.id, 'created': pd.to_datetime(c.created, unit='s', utc=True), 'amount': c.amount,
    'currency': c.currency, 'product': c.metadata.to_dict().get('product', 'unknown'),
} for c in stripe.Charge.list(created={'gte': start, 'lt': end}, limit=100).auto_paging_iter()
  if c.paid and c.status == 'succeeded'])

refunds = pd.DataFrame([{
    'charge_id': r.charge, 'refund_created': pd.to_datetime(r.created, unit='s', utc=True), 'refund_amount': r.amount,
    'reason': r.reason or 'not provided',
} for r in stripe.Refund.list(created={'gte': start}, limit=100).auto_paging_iter() if r.status == 'succeeded'])

# one row per charge: total refunded and first refund date (a charge can have several refunds)
by_charge = refunds.groupby('charge_id').agg(refunded=('refund_amount', 'sum'), first_refund=('refund_created', 'min'),
                                             reason=('reason', 'first')).reset_index()
df = charges.merge(by_charge, on='charge_id', how='left')
df['refunded'] = df['refunded'].fillna(0)
df['was_refunded'] = df['refunded'] > 0
df['days_to_refund'] = (df['first_refund'] - df['created']).dt.total_seconds() / 86400

print(f"{len(df)} paid charges, {int(df['was_refunded'].sum())} refunded at least once")
print(df.groupby('currency').agg(charges=('amount', 'size'), charged=('amount', 'sum'), refunded=('refunded', 'sum')).assign(
    charged=lambda x: x['charged'] / 100, refunded=lambda x: x['refunded'] / 100))

Expected Output

3000 paid charges, 154 refunded at least once
          charges   charged  refunded
currency
eur           156    8654.0     516.5
usd          2844  166296.0    9189.0

From here the analysis uses the USD charges only, so that amounts can be added. The euro charges would be analysed the same way on their own, or converted with an exchange rate you document.

Step 2: The Refund Rate by Month

Two rates answer different questions. The share of charges refunded counts events; the share of value refunded weights them by size. Both are grouped by the month of the charge, so each month's denominator is that month's paid charges. The median days from charge to first refund tells you how long a month stays open.

usd = df[df['currency'] == 'usd'].copy()      # one currency from here on, so amounts can be added
usd['month'] = usd['created'].dt.strftime('%Y-%m')
monthly = usd.groupby('month').agg(charges=('amount', 'size'), refunded_charges=('was_refunded', 'sum'),
                                   charged=('amount', 'sum'), refunded=('refunded', 'sum'))
monthly['refund_rate_%'] = (100 * monthly['refunded_charges'] / monthly['charges']).round(1)
monthly['refunded_value_%'] = (100 * monthly['refunded'] / monthly['charged']).round(1)
usd['within_7d'] = usd['days_to_refund'] <= 7      # refunded in the first 7 days; every month has had at least 7 days
monthly['rate_7d_%'] = (100 * usd.groupby('month')['within_7d'].sum() / monthly['charges']).round(1)
print(monthly[['charges', 'refunded_charges', 'refund_rate_%', 'refunded_value_%', 'rate_7d_%']].to_string())
print(f"\nMedian days from charge to first refund: {usd['days_to_refund'].median():.1f}")

Expected Output

         charges  refunded_charges  refund_rate_%  refunded_value_%  rate_7d_%
month
2024-07      503                18            3.6               3.6        1.8
2024-08      499                31            6.2               7.2        3.8
2024-09      466                22            4.7               4.7        2.8
2024-10      447                19            4.3               4.4        3.4
2024-11      455                32            7.0               7.4        4.8
2024-12      474                23            4.9               5.9        2.5

Median days from charge to first refund: 5.0

The rate bounces between 3.6% and 7.0% from month to month. In this synthetic account the refund chance for each product is the same in every month, so these swings are sampling noise, not a trend. Do not read a rise or fall into them. The last column, rate_7d_%, counts only refunds made in the first 7 days after the charge. Every month has had at least 7 days, so the months are compared on equal footing. Refunds arrive after the charge, so a recent month has had less time to collect them. Here the data stops on January 10, so the last few December charges have had only 10 days. Even on the equal footing, the 7-day rate still ranges from 1.8% to 4.8%, which is the same message: with about 450 to 500 charges a month and a few dozen refunds, one month's rate is a noisy number. In a real account, compare months only after they have had the same time to mature.

Step 3: Why Are Refunds Requested?

Count refunds by their reason, keeping the null group visible. Refunds with no reason are a large share here, and the reason field only says what the merchant recorded.

reasons = refunds.merge(charges[['charge_id', 'currency']], on='charge_id')
reasons = reasons[reasons['currency'] == 'usd']['reason'].value_counts()
print(pd.DataFrame({'refunds': reasons, 'share_%': (100 * reasons / reasons.sum()).round(1)}))

Expected Output

                       refunds  share_%
reason                                 
requested_by_customer       88     60.7
not provided                38     26.2
duplicate                   12      8.3
fraudulent                   7      4.8

The categories add to 100% because every refund falls in exactly one of them. Stripe's reason values are coarse, so they describe how the refund was recorded, not why the customer wanted their money back. For that you need your own notes or a survey.

Step 4: Which Product Is Refunded More, and How Sure Are You?

A product's refund rate is a proportion from a finite number of charges, so it carries sampling error. The Wilson interval gives a range of plausible values for each product's rate. When two products' intervals do not overlap, the difference is unlikely to be noise; when they overlap, it may be.

from statsmodels.stats.proportion import proportion_confint

overall = usd['was_refunded'].mean()
rows = []
for product, g in usd.groupby('product'):
    k, n = int(g['was_refunded'].sum()), len(g)
    lo, hi = proportion_confint(k, n, method='wilson')
    rows.append({'product': product, 'charges': n, 'refunded': k, 'rate_%': round(100 * k / n, 1),
                 'ci95_low_%': round(100 * lo, 1), 'ci95_high_%': round(100 * hi, 1)})
print(f"All products: {100 * overall:.1f}% of charges refunded")
print(pd.DataFrame(rows).to_string(index=False))

Expected Output

All products: 5.1% of charges refunded
product  charges  refunded  rate_%  ci95_low_%  ci95_high_%
 plan_a     1152        28     2.4         1.7          3.5
 plan_b      844        31     3.7         2.6          5.2
 plan_c      848        86    10.1         8.3         12.4

plan_c stands well apart: its interval (8.3% to 12.4%) sits above the overall rate and above both other products. plan_a and plan_b have 2.4% and 3.7% with intervals that overlap (1.7% to 3.5% and 2.6% to 5.2%), so the data supports "plan_c is refunded much more" more firmly than it supports ranking the other two. We set the true chances in the generator (2%, 3% and 10%), and all three intervals do contain them. That will not always happen: a 95% interval misses the true value about 1 time in 20. The intervals also assume charges are independent; repeat buyers refunding in clusters would make them too narrow.

Interpreting the Results

Sources

Run It on Your Own Stripe Export

Export your payments and refunds from Stripe as a CSV and upload it at MCP Analytics, then ask the question in plain language; the report names the method. Nothing connects to your Stripe account.

Try it on your data

Troubleshooting

Many refunds have no reason

The reason field is nullable and holds a value only when one was supplied or Stripe generated one, so refunds created without a reason cannot be filled in from Stripe afterwards. Set the reason in your own refund code from now on, and keep the null group in your tables.

No product on the charge

If charges were created without product metadata, join to your own orders table on the charge or payment ID to bring the product in. The code above labels such charges unknown rather than dropping them.

Several currencies

Report each currency separately, as Step 1 does, or convert to one currency with a stated rate and date before adding.

More than one page of results

Use auto_paging_iter(), as above. A single list call returns at most 100 objects.

Explore more: Stripe Analytics: all tools, tutorials, and guides →

Not sure which plan? Compare plans →

Your turn

Bring your own data and the question you actually need answered.

MCP AnalyticsData science by email Send us your data and your question, and we will reply. ds@mcpanalytics.ai