Skip to content

Call to undefined method Laravel\\Cashier\\SubscriptionBuilder::applyCoupon() #1790

@sts-ryan-holton

Description

@sts-ryan-holton

Cashier Stripe Version

16.0.2

Laravel Version

12.34.0

PHP Version

8.4

Database Driver & Version

MySQL 8

Description

After upgrading to Cashier v16, attempting to apply a coupon to my user's subscription is throwing an error. This worked in v15.

The error is thrown:

Call to undefined method Laravel\\Cashier\\SubscriptionBuilder::applyCoupon()

Steps To Reproduce

Attempt to use applyCoupon method on subscription:

$subscriptionOptions = [
    'success_url' => "$frontendURL".$request->input('success_url', 'account/billing/checkout/success/'),
    'cancel_url' => "$frontendURL".$request->input('cancel_url', 'account/billing/plans/'),
];

$user = User::find(Auth::id());
$subscription = $user->newSubscription('default', $plan->stripe_id);

if (Str::of($request->input('plan', ''))->contains(['monthly-75', 'yearly-75'])) {
    if (config('domain-monitor.new_customers_discount')) {
        $subscription = $subscription->applyCoupon(config('domain-monitor.new_customers_discount'));
    }
}

$subscription = $subscription->checkout($subscriptionOptions);

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions