Allow users to enter promo code on checkout

Solved
produkt

May 2nd, 2025 09:48 AM

How do I allow this?

brianh

May 2nd, 2025 11:33 AM

Hi Produkt,

The ability to apply discounts depends on the specific payment processor you’re using.

For instance, with Paddle, you can log in to your Paddle billing interface, navigate to the Catalog section, and select Discounts. From there, you can configure the desired discount details.

Screenshot 2025-05-02 at 20.31.11.png

During checkout, users will have the option to enter the discount code, which will then be applied automatically to their billing.

Hope that helps.

produkt

May 2nd, 2025 11:47 AM

I’m using stripe. I added coupon codes but I believe it’s within the stripe client code that you allow codes to be applied. Where do I do that?

produkt

May 2nd, 2025 06:56 PM

Best Answer

I discovered the answer. Edit wave/src/Http/Livewire/Billing/Checkout.php:

public function redirectToStripeCheckout(Plan $plan)
    {
        $stripe = new StripeClient(config('wave.stripe.secret_key'));

        $price_id = $this->billing_cycle_selected == 'month' ? $plan->monthly_price_id : $plan->yearly_price_id ?? null;

        $checkout_session = $stripe->checkout->sessions->create([
            'line_items' => [[
                'price' => $price_id,
                'quantity' => 1
            ]],
            'metadata' => [
                'billable_type' => 'user',
                'billable_id' => auth()->user()->id,
                'plan_id' => $plan->id,
                'billing_cycle' => $this->billing_cycle_selected
            ],
            'mode' => 'subscription',
            'success_url' => url('subscription/welcome'),
            'cancel_url' => url('settings/subscription'),
            'allow_promotion_codes' => true, // add this line
        ]);
Report
1