Comments (13)
I have found that with
$user->onGenericTrial();
Works great to check if the user is on any trial, since I am handling the trial in the model.
Is there something similar to check if the user is on any active plan or should I concatenate conditional statements of each plan to check it?
from cashier-paddle.
This seems to work well to check if the user has any active subscription :
$user->subscriptions()->where('paddle_status','active')->count() >= 1
from cashier-paddle.
Hey @techguydev, that's described here: https://laravel.com/docs/7.x/cashier-paddle#checking-subscription-status
Is that what you need?
from cashier-paddle.
Hi @driesvints
if ($user->subscribed('default')){
}
Works great if you have just one subscription type.
In my use case I have 3 subscriptions types:basic,pro,unlimited.
I am creating a workflow where I need to check if a given user has any subscriptions at all ( of any type) or if he/she is on trial, or on trial with a given subscription.
I might just join them like this:
if ($user->subscribed('basic') || $user->subscribed('pro') || $user->subscribed('unlimited') ){
//
}
I just wanted to know if there is any function that consider any active subscription to a given user.
from cashier-paddle.
Hey @techguydev, no there isn't such a feature atm it seems. If you indeed only need to check the active state you can do
$user->subscriptions()->active()->count() >= 1
But that's not the same as subscribed
which takes into account "valid" subscriptions:
/**
* Determine if the subscription is active, on trial, or within its grace period.
*
* @return bool
*/
public function valid()
{
return $this->active() || $this->onTrial() || $this->onPausedGracePeriod() || $this->onGracePeriod();
}
I'll mark this as a feature request.
from cashier-paddle.
Thanks @driesvints
from cashier-paddle.
Hey @techguydev, no there isn't such a feature atm it seems. If you indeed only need to check the active state you can do
$user->subscriptions()->active()->count() >= 1
This PR fixed this problem. #22
from cashier-paddle.
@frkcn looks interesting this approach.
from cashier-paddle.
I'm not sure but I think the right approach is to keep one subscription the "default"
and create 3 plans "Basic, pro, unlimited"
then you can check if the user subscribed and which plan the user subscribed to
if ($user->subscribedToPlan($basicMonthly = 12345, 'default')) {
//
}
I'm doing it this way in my SaaS,
from cashier-paddle.
Thanks @Hussam3bd
@driesvints What do you think about this approach?
from cashier-paddle.
In general I agree yeah. I think in your use case you want different plans but one type of subscription.
I'm gonna leave the issue open for a bit because I can still see a use case of adding a method to see if a user has any active subscription at all.
from cashier-paddle.
Closing this as it's now possible again to do $user->subscriptions()->active()->count()
if you want.
from cashier-paddle.
I am not sure I am understanding the difference between Subscription and Plan.
In my casa each plan has different access to my app, so the subscription if kind of different too.
how are you guys handling different access levels with different plans?
from cashier-paddle.
Related Issues (20)
- Disable generic trial once customer is subscribed HOT 1
- Fix incrementQuantity() & decrementQuantity() Throwing Error HOT 5
- Notice in the docs about "default checkout URL" HOT 1
- [2.x] add end at of the subscription period HOT 1
- Fix nextPayment() total HOT 1
- returnTo function added to checkout does not redirect HOT 6
- Bill for non-catalog items HOT 6
- Issues with subscriptions "price_id must be a string" HOT 4
- Webhook duplicating the response statuses HOT 8
- Cashier::findBillable($customerId) not returning anythying HOT 2
- Get subscription payment method HOT 1
- Add support for authentication via client-side tokens HOT 1
- Paddle webhook handler doesnt work HOT 10
- Laravel cashier-paddle package conflict with passport Auth Header HOT 1
- Paddle with Passport giving: Authentication header included, but incorrectly formatted HOT 3
- Pausing Subscriptions HOT 1
- Applying a discount on checkout HOT 1
- Problem with billing API - Transaction not created in the db HOT 13
- Changing email on the payment screen HOT 5
- Activate subscription is not working. HOT 10
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cashier-paddle.