Subscriptions
I am enjoying discovering the features of the Wave template. I have a few new questions. I have set up a test connection to a Stripe account and I am able to register and subscribe as a new user. I am redirected back to the subscription welcome page but it appears that the user is not actually granted the subscription. Is that because I am only in testing mode? The stripe webhook obviously can't connect to my local test environment.
As an admin, how can I grant a user a subscription from the admin panel? I tried adding a role but the user still does not appear subscribed.
Also, as a side note: what does marking a blog post as 'featured' do? I didn't notice any changes to the appearance.
Hi there!
The subscription should work with the testing mode as well. But you would indeed need the webhook in place as per the documentation here:
Also, did you create the plan and associate the plan with a role?
There are a few ways to test Stripe webhooks locally, here is a discussion that covers this:
https://laracasts.com/discuss/channels/laravel/troubleshooting-stripe-webhook-setup-in-laravel-10-invalid-url-exception
One suggestion is to use the Stripe CLI and another option is to use https://expose.dev/
To grant a user a subscription, you can just change their role rather than actually creating an active subscription in Stripe and etc. Make sure to go over the docs here:
Marking a post as "featured" doesn't automatically change its appearance or behavior. Instead, it provides a way for you to query and display featured posts as needed. For example, you can customize your homepage to only show featured posts. However, you'll need to add the logic in your views or controllers to make use of the "featured" flag.
Hope that this helps!
Once I successfully hit the endpoint by using https://expose.dev, the test checkout process worked when I subscribed as a test user. Cool!
However, if I were trying to grant access to a user as the admin by assigning them a role, it doesn't work. I am using the default roles and plans. The only thing I modified was I deleted the premium plan. I am trying to assign a user a basic role.
I guess this is because I gated some of my pages with middleware('subscribed'), but even if I assign a role to a user, that doesn't mean they are subscribed. I am guessing here, but if I check for role instead, it will work. However, what happens to a user's role when their subscription expires? Does it reset to registered, or does it stay at the expired user role?
Hi there,
However, what happens to a user's role when their subscription expires? Does it reset to registered, or does it stay at the expired user role?
Yes this should be the case, there is a webhook endpoint for this as well:
wave/src/Http/Controllers/Billing/Webhooks/StripeWebhook.php#L44
If you want to have some custom behaviour you could either change the middleware or update the subscriber()
method on the user model to match your exact needs. For example if you want to grant user access to the app without them being a subscriber just based on a role, you could plug in that logic into the middleware or the method.
OK, so changing a user's role to basic, premium, or pro does not change their subscription status, so using middleware('subscribed') still blocks them? Also finally, is there any built-in functionality with the trial counter? And how is verified and verification code used? I see that it is separate from email verification.
Hi,
OK, so changing a user's role to basic, premium, or pro does not change their subscription status, so using middleware('subscribed') still blocks them
Yep correct, this is why I mentioned updating the middleware or the subscriber() method on the user model to match your exact needs.
The trail is something that you would setup on the payment provider side, and then on the wave side you can use the onTrial
method to check if the user is on trail: wave/src/User.php#L62
For Stripe, wave uses the Cashier package, you can reference the docs here: