Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ixudra's avatar

Stripe: applying coupons

Hi

I'm using Stripe in my project to bill users for my services. I would like to integrate coupons in this app to give some customers a "discount" of x months for free. This can easily be done using Stripe Coupons, but as far as I can see, coupons can only be applied when creating the subscription. I would like to be able to do this at any point in time, e.g. when a user (with an existing subscription) refers another user to my website. Does anyone know if this is possible? And if so, where can I find an example or some documentation on this?

0 likes
2 replies
ixudra's avatar
ixudra
OP
Best Answer
Level 4

Found a solution for my problem in the Stripe documentation:

// Set your secret key: remember to change this to your live secret key in production
// See your keys here https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_BQokikJOvBiI2HlWgH4olfQ2");

$cu = \Stripe\Customer::retrieve("cus_3R1W8PG2DmsmM9");
$cu->coupon = "coupon_ID";
$cu->save();

And also in Laravel Cashier: $this->subscription()->applyCoupon('coupon_ID');

2 likes
yash54's avatar

Hello @ixudra,

You can apply coupons to existing subscriptions/users.

//applying a coupon
        try {
            $company->applyCoupon($stripe_coupon->id);
        } catch (Exception $e) {
            return api()->error(__('Coupon Error: '. $e));
        }

Please or to participate in this conversation.