Sub topic 15
Refunds, Leaked Codes and Abuse
This chapter assumes you understand list price, net revenue, conversion rate, and basic coupon rules. The goal is to protect the learner experience and your margin without rejecting legitimate buyers.
Treat a sale as a lifecycle
A coupon sale does not end at payment. It moves through several states:
- A buyer applies a coupon.
- The payment provider confirms payment.
- You record the order and coupon redemption.
- The buyer may request a refund.
- You reverse the appropriate redemption and revenue records.
A refund is money returned to the buyer. A coupon redemption is the use of a coupon against its limit. Keep these records separate. A refund does not always mean that the coupon should become available again. For example, a public launch code may have been intended for one use per buyer even if an order is later refunded.
| Event | Record to update | Main question |
|---|---|---|
| Successful payment | Order and redemption | Was the payment confirmed? |
| Refund | Order status and returned amount | Is the refund inside your policy? |
| Leaked code | Coupon status or eligibility | Should the code be disabled or restricted? |
| Suspicious use | Risk review record | Is the behavior unusual enough to investigate? |
Design a refund policy before selling
State the refund window, eligible products, and treatment of access clearly. On your own site, your payment processor and local consumer law may impose additional requirements. On a marketplace such as Udemy, follow the platform's current refund process and terms rather than promising a separate instructor-controlled rule.
When a refund is approved, revoke or limit access according to the applicable policy. Do not silently alter a buyer's access or retain money that the stated policy requires you to return.
Calculate promotion performance using both gross and net figures. A refunded order should not remain in the successful-sales total.
from dataclasses import dataclass
from decimal import Decimal
@dataclass
class Order:
amount_paid: Decimal
refunded: Decimal = Decimal("0.00")
@property
def net_revenue(self) -> Decimal:
return self.amount_paid - self.refunded
def refund(self, amount: Decimal) -> None:
if amount <= 0:
raise ValueError("Refund must be positive")
if self.refunded + amount > self.amount_paid:
raise ValueError("Refund exceeds payment")
self.refunded += amount
order = Order(Decimal("69.30"))
order.refund(Decimal("69.30"))
print(order.net_revenue) # 0.00Respond to leaked codes
A leaked code is a coupon shared outside its intended audience. Leakage is not automatically abuse. A buyer may have received the code from a legitimate partner or public post.
Use graduated controls:
- Disable a code if it was meant to be private and has spread widely.
- Replace it with a new code with a lower redemption limit.
- Restrict eligibility to a customer segment, email domain, or campaign link.
- Record where each code was distributed.
- Avoid publishing a private code in a page that search engines can index.
A coupon should have an owner, purpose, expiry, discount, maximum redemptions, and eligibility rule. These details make an incident reversible.
Detect abuse without harming buyers
Abuse signals include many accounts using the same payment method, repeated refunds after course access, unusually rapid code attempts, and a high number of orders from one device or address. A signal is not proof. Review several signals together and provide a path for legitimate customers to contact you.
Use server-side validation. Never trust a discount calculated only in browser code. Make redemption atomic, meaning the check and the increment happen as one protected operation. Otherwise, simultaneous requests can exceed the coupon limit.
Exercise
A private coupon has 100 redemptions, but 40 buyers request refunds. Should you automatically restore all 40 redemptions?
Show answer
No. Apply the documented campaign rule. Restore redemptions only when the campaign is designed to do so and the refund was valid. Otherwise, keep the original redemption history and create a replacement campaign if needed.