← Back to Gallery

Promo Codes

Enable promo code support with the onApplyPromo callback. The input starts collapsed as a "Have a promo code?" link, expands to show an input + Apply button, and displays success or error states.

States

Collapsed

Expanded

Loading

Success

✓ BLAZE20 — 20% off Remove

Error

Code not found

Implementation

<BlazeCheckout
  onApplyPromo={async (code) => {
    const result = await validatePromoCode(code)
    return {
      valid: result.ok,
      discount: result.label,    // e.g. "20% off"
      error: result.errorMessage // e.g. "Code not found"
    }
  }}
  onRemovePromo={() => clearPromo()}
  appliedPromoCode={promo?.code}
  appliedPromoDiscount={promo?.label}
  // ... other props
/>

API Reference

Prop Type Description
onApplyPromo (code: string) => Promise<{ valid: boolean; discount?: string; error?: string }> Enables promo input when provided. Called when user clicks Apply.
onRemovePromo () => void Called when user removes an applied promo code.
appliedPromoCode string | null Pre-applied promo code for controlled mode.
appliedPromoDiscount string | null Pre-applied discount label for controlled mode.

Styling and Behavior