Coupons

View as Markdown

Create and manage discounts with coupons and promotion codes. Offer percentage discounts, fixed amounts, or extended trial periods with flexible rules and limits.

How coupons work

The coupon system has three components:

┌─────────────┐ ┌──────────────┐ ┌─────────────┐
│ Coupon │────▶│ Promotion │────▶│ Customer │
│ (Template) │ │ Code │ │ Redeems │
│ │ │ (Shareable) │ │ Code │
└─────────────┘ └──────────────┘ └─────────────┘
│ │
│ ▼
│ ┌─────────────────┐
│ │ Discount │
│ │ Applied to │
└────────────────────────────▶│ Subscription │
└─────────────────┘
  • Coupons - Reusable discount templates with rules and limits
  • Promotion codes - Customer-facing codes that link to coupons
  • Discounts - Applied instances of coupons on subscriptions or invoices

Discount types

TypeDescriptionExample
PercentagePercentage off the total (1-100%)20% off
Fixed amountFixed discount in a currency$10 off
Trial extensionAdditional free trial days14 extra days

Duration options

Control how long a discount lasts:

DurationBehaviorUse case
OnceApplies to first invoice onlyOne-time promotions
RepeatingApplies for N monthsLimited-time offers (e.g., “3 months free”)
ForeverApplies indefinitelyLoyalty discounts, partner pricing

Creating a coupon

Create coupons in the dashboard or via API:

  1. Navigate to Coupons in the sidebar
  2. Click Create Coupon
  3. Configure discount type, amount, and duration
  4. Set optional limits (max redemptions, expiration date)
  5. Save the coupon

Promotion codes

Promotion codes are shareable codes that customers enter at checkout. Each code links to a coupon and can have its own restrictions.

Creating a promotion code:

$curl -X POST https://api.paymentkit.com/v1/promotion-codes \
> -H "Authorization: Bearer sk_live_..." \
> -d coupon_id="coupon_abc123" \
> -d code="SUMMER20" \
> -d max_redemptions=50

Promotion code restrictions

Add additional rules to promotion codes:

RestrictionDescription
First-time onlyOnly customers with no prior transactions
Minimum amountMinimum order total required
Expiration dateCode expires after a specific date
Max redemptionsTotal number of times code can be used

Promotion code restrictions are checked in addition to the coupon’s rules. Both must pass for the discount to apply.

Product restrictions

Limit coupons to specific products:

$curl -X POST https://api.paymentkit.com/v1/coupons \
> -H "Authorization: Bearer sk_live_..." \
> -d name="Enterprise Discount" \
> -d percent_off=15 \
> -d duration="forever" \
> -d product_ids[]="prod_enterprise" \
> -d product_ids[]="prod_enterprise_annual"

When product IDs are specified, the discount only applies to line items matching those products.

Applying discounts

Discounts can be attached at different levels:

LevelScopeUse case
CustomerAll future subscriptionsVIP customers, partner accounts
SubscriptionSpecific subscriptionPromotional pricing on one plan
InvoiceSingle invoiceOne-time adjustment
Invoice itemSingle line itemPer-product discounts

More specific discounts take priority over general ones.

Coupon states

Coupons have a lifecycle with automatic state transitions:

StateCan redeem?Description
ActiveYesAvailable for use
InactiveNoManually paused, can be reactivated
DepletedNoMax redemptions reached (terminal)
ExpiredNoPast expiration date (terminal)

Checkout integration

Apply coupons during checkout session creation:

$curl -X POST https://api.paymentkit.com/v1/checkout/sessions \
> -H "Authorization: Bearer sk_live_..." \
> -d customer_id="cus_xyz" \
> -d line_items[0][price_id]="price_abc" \
> -d promotion_code="SUMMER20"

Or allow customers to enter codes at checkout:

$curl -X POST https://api.paymentkit.com/v1/checkout/sessions \
> -H "Authorization: Bearer sk_live_..." \
> -d allow_promotion_codes=true

Invoice discount calculation

When an invoice is generated:

  1. Check for invoice-level discount
  2. Fall back to subscription-level discount
  3. Fall back to customer-level discount

Percentage discounts:

item_discount = item_amount × (percent_off / 100)

Fixed amount discounts (distributed proportionally):

item_discount = total_discount × (item_amount / invoice_total)

Validating promotion codes

Check if a code is valid before applying:

$curl -X POST https://api.paymentkit.com/v1/promotion-codes/validate \
> -H "Authorization: Bearer sk_live_..." \
> -d code="SUMMER20" \
> -d customer_id="cus_xyz"

The response indicates whether the code can be used and any restrictions that apply.

Best practices

Use coupons as templates

Create coupons with business rules, then distribute via multiple promotion codes.

Set redemption limits

Always configure max_redemptions for promotional campaigns to control costs.

Use validity periods

Set expiration dates to create urgency and manage campaign timelines.

Track redemption sources

Use different promotion codes for different channels to measure effectiveness.


[MBCC]