0Pricing
AI Powered SaaS: Stripe + Auth + Billing + Deploy · Lesson

Handling Refunds & Disputes

Complete your one-time payment flow by issuing refunds with the Stripe API, handling partial refunds, and responding to chargebacks and disputes.

Handling Refunds & Disputes is a free AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson on CoddyKit — lesson 4 of 4. You can read the complete lesson below for free — then practise it hands-on in the browser with a built-in code editor and a 24/7 AI tutor. It is part of the AI Powered SaaS: Stripe + Auth + Billing + Deploy learning path, one of 4 lessons in the course, and your progress syncs across the web and the CoddyKit app.

Why Refunds Matter

Charging customers is only half the job. A smooth refund process builds trust, meets legal obligations, and reduces costly chargebacks. Stripe makes refunds a single API call.

What You Need to Refund

To refund, you need the original PaymentIntent or charge ID. Store it on your order record at purchase time so you can look it up later.

await prisma.order.update({
  where: { id },
  data: { paymentIntentId: session.payment_intent }
});

Issuing a Full Refund

Create a refund by passing the PaymentIntent. With no amount, Stripe refunds the full charge.

const refund = await stripe.refunds.create({
  payment_intent: order.paymentIntentId
});

Partial Refunds

To refund part of a payment, pass an amount in the smallest currency unit (cents).

await stripe.refunds.create({
  payment_intent: order.paymentIntentId,
  amount: 500
});

Refund Reasons

Tag refunds with a reason for your records and Stripe's analytics. Valid values include requested_by_customer, duplicate, and fraudulent.

await stripe.refunds.create({
  payment_intent: id,
  reason: 'requested_by_customer'
});

Updating Your Database

Reflect the refund in your own system so the order status is accurate and the customer cannot use a refunded product.

await prisma.order.update({
  where: { id }, data: { status: 'REFUNDED' }
});

Refund Webhooks

Refunds can also be issued from the Stripe Dashboard. Listen for the charge.refunded webhook so your database stays in sync no matter where the refund originates.

if (event.type === 'charge.refunded') {
  await markOrderRefunded(event.data.object);
}

What is a Dispute?

A dispute (chargeback) happens when a customer asks their bank to reverse a charge. Stripe withdraws the funds and a dispute fee, then asks you for evidence.

Responding to Disputes

Listen for charge.dispute.created and submit evidence — receipts, delivery proof, customer communication — to contest it.

await stripe.disputes.update(disputeId, {
  evidence: { receipt: fileId, customer_email_address: email }
});

Preventing Chargebacks

The best defense is prevention:

  • Use a clear billing descriptor
  • Send receipts immediately
  • Offer easy self-serve refunds
  • Keep records of every transaction

Best Practices

Handle money responsibly:

  • Store the PaymentIntent on each order
  • Support full and partial refunds with reasons
  • Sync via the charge.refunded webhook
  • Contest disputes with evidence and prevent them upfront

Quick Check

Test your refund knowledge.

Recap

You completed the payment lifecycle:

  • Store the PaymentIntent to enable refunds
  • Issue full or partial refunds with a reason
  • Sync via the charge.refunded webhook
  • Respond to disputes with evidence and prevent chargebacks

Your one-time payment flow now handles money end to end.

Frequently asked questions

Is the “Handling Refunds & Disputes” lesson free?

Yes — the full text of “Handling Refunds & Disputes” is free to read here on the web, and the AI Powered SaaS: Stripe + Auth + Billing + Deploy course includes 4 lessons in total. To practise it interactively (a built-in code editor and a 24/7 AI tutor) and unlock the rest of the AI Powered SaaS: Stripe + Auth + Billing + Deploy course, upgrade to CoddyKit PRO.

What will I learn in “Handling Refunds & Disputes”?

Complete your one-time payment flow by issuing refunds with the Stripe API, handling partial refunds, and responding to chargebacks and disputes. You practise AI Powered SaaS: Stripe + Auth + Billing + Deploy with hands-on code you run directly in the browser, and a 24/7 AI tutor answers your questions as you work through the lesson.

Do I need any experience to start AI Powered SaaS: Stripe + Auth + Billing + Deploy?

No prior experience is required. AI Powered SaaS: Stripe + Auth + Billing + Deploy on CoddyKit is structured for beginners through advanced learners; this is — lesson 4 of 4, so you can start here or from the beginning and move at your own pace.

How long does the “Handling Refunds & Disputes” lesson take?

Most CoddyKit lessons take about 5–10 minutes. Each one is bite-sized and interactive, so you make steady progress and pick up exactly where you left off across the web and the app.

Can I write and run code in this AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson?

Yes. Every AI Powered SaaS: Stripe + Auth + Billing + Deploy lesson includes a built-in code editor, so you write and run real code right in your browser and get instant AI feedback — no local setup required.

All lessons in this course

  1. Stripe Account & API Keys
  2. Creating Products & Prices
  3. Implementing Checkout Sessions
  4. Handling Refunds & Disputes
← Back to AI Powered SaaS: Stripe + Auth + Billing + Deploy