Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ Available tap actions are:
- **Purchase:** Begins the purchase flow for a specific product. Choose a product directly, or use **Selected** to purchase whichever product the user selected earlier in the paywall.
- **Select Product:** Puts the chosen product in a selected state. Useful for scenarios such as focusing a product in a paywall drawer, for example, when something is tapped or clicked.
- **Restore:** Begins a purchase restore operation. Useful for restoring purchases someone may have made prior.
- **Redeem Discount:** For web checkout paywalls, validates a Stripe promotion code, re-prices the paywall's products in place, and applies the code at Stripe checkout. Point its **code** at a state variable bound to a text input (for customer-entered codes) or at a hardcoded literal (for a fixed promotion). See [Discount Codes](/web-checkout/web-checkout-discount-codes).

#### Purchase outcome actions

Expand Down
1 change: 1 addition & 0 deletions content/docs/web-checkout/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
"web-checkout-adding-a-stripe-product",
"web-checkout-adaptive-pricing",
"web-checkout-stripe-one-time-purchases",
"web-checkout-discount-codes",
"web-checkout-creating-campaigns-to-show-paywalls",

"---Implementation---",
Expand Down
74 changes: 74 additions & 0 deletions content/docs/web-checkout/web-checkout-discount-codes.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
---
title: "Discount Codes"
description: "Let customers enter a Stripe promotion code on your web paywall, update the price in place, and carry the discount through to Stripe checkout."
---

Discount codes let a customer type a promotion code into your web paywall, have it validated against Stripe, and see the price update before they check out. The code is then carried through to the Stripe checkout session, so the discount is applied to the purchase they complete.

This works entirely on your paywall — there is no separate discount widget to configure. You add a normal text **Input** for the customer to type into, then a button whose tap behavior runs the **Redeem Discount** action. When the customer taps it, Superwall resolves the code against your Stripe promotion codes, re-prices the products on the paywall, and applies the code at checkout.

<Note>
Discount codes are a Stripe web checkout feature. The customer redeems a promotion code you have
already created in your Stripe dashboard — Superwall does not create or manage the coupon itself.
</Note>

## Before you start

Create the coupon and promotion code in Stripe first. Superwall resolves whatever the customer types against your existing Stripe promotion codes at redeem time, so the code has to exist before it can be applied.

1. In your [Stripe dashboard](https://dashboard.stripe.com/coupons), create a **coupon** with the discount you want to offer (for example, 20% off, or a fixed amount off).
2. Create a **promotion code** for that coupon. The promotion code is the customer-facing string a customer will type into your paywall (for example, `LAUNCH20`).

<Tip>
Make sure the promotion code exists in the same Stripe environment (live or sandbox) as the
products on the paywall you are testing. A live promotion code will not resolve against a sandbox
checkout, and vice versa.
</Tip>

## Add discount code redemption to a paywall

You will add a text input for the customer to type into, then a button that redeems whatever they entered. Open the paywall you want to edit in the [paywall editor](/dashboard/dashboard-creating-paywalls/paywall-editor-overview) and follow along.

<Steps>
<Step title="Add an input for the code">
Add an [Input element](/dashboard/dashboard-creating-paywalls/paywall-editor-input-component) where the customer will type their code, and give it a helpful placeholder such as "Promo code". Bind the input to a state variable — for example, `state.discountCode` — so the value the customer types is available to the redeem action.
</Step>
<Step title="Add a button to redeem">
Add a button (or reuse an existing one) next to the input. This is the element the customer taps to apply their code.
</Step>
<Step title="Add the Redeem Discount action">
Select the button and, under [Tap Behavior](/dashboard/dashboard-creating-paywalls/paywall-editor-styling-elements#tap-behaviors), click **+ Add Action**. In the **Purchases** group, choose **Redeem Discount**.
</Step>
<Step title="Point the action at the code">
Set the action's **code** to reference the input's state variable using Liquid, for example `{{ state.discountCode }}`. This redeems whatever the customer typed.

To offer a single fixed promotion instead of customer-entered codes, you can skip the input and set the code to a hardcoded literal such as `LAUNCH20`. Tapping the button then always applies that one code.
</Step>
<Step title="Publish and test">
[Publish](/dashboard/dashboard-creating-paywalls/paywall-editor-publishing) the paywall, then enter a real promotion code to confirm the price updates and the discount carries through to checkout. See [Testing purchases](/web-checkout/web-checkout-testing-purchases) for how to run test checkouts safely.
</Step>
</Steps>

## What happens when a code is redeemed

When the customer taps the button, Superwall:

1. Validates the code against your Stripe promotion codes.
2. Re-prices the products on the paywall in place, so the customer sees the discounted price immediately.
3. Forwards the code to the Stripe checkout session, so the discount is applied to the purchase they complete.

If the code is not valid, the products stay at their original price.

## Showing the discounted price

After a code applies, discount display variables become available so your paywall can react to the discount and show the new price. You can insert these from the variable picker in a text element or wherever you use [dynamic values](/dashboard/dashboard-creating-paywalls/paywall-editor-dynamic-values), for example:

- `hasDiscount` — whether a discount is currently applied. Use it to show or hide a "discount applied" message, a strikethrough of the original price, or a badge.
- `discountCode` — the code that was applied.
- `discountedPrice` — the price after the discount.

A common pattern is to show the original price with a strikethrough alongside `discountedPrice` once `hasDiscount` is true, so the savings are obvious before the customer checks out.

## Where discount codes apply

A redeemed code carries through Superwall's web checkout flows — redirect, embedded, and elements checkout all apply it at the Stripe checkout session. The one exception is deferred **Apple Pay** checkout, which does not apply a redeemed discount code.
Loading