Comments (8)
Sorry. I had to edit all my comment.
This is also was important:
Change...
new PlanFeature(['name' => 'listing_duration_days', 'value' => 30, 'sort_order' => 10, 'resettable_period' => 1, 'resettable_interval' => 'month']),
To...
new PlanFeature(['name' => 'listing_duration_days', 'value' => 30, 'sort_order' => 10, 'resettable_period' => 1, 'resettable_interval' => 'm']),
So, 'resettable_interval' => 'month'
to 'resettable_interval' => 'm'
Now the method looks like this:
private function _createAPlan() {
$plan = app('rinvex.subscriptions.plan')->create([
'name' => 'Pro',
'description' => 'Pro plan',
'price' => 9.99,
'signup_fee' => 0.00,
'invoice_period' => 1,
'invoice_interval' => 'm',
'trial_period' => 15,
'trial_interval' => 'd',
'sort_order' => 1,
'currency' => 'BRL',
]);
$plan->features()->saveMany([
new PlanFeature(['name' => 'listings', 'value' => 50, 'sort_order' => 1]),
new PlanFeature(['name' => 'pictures_per_listing', 'value' => 10, 'sort_order' => 5]),
new PlanFeature(['name' => 'listing_duration_days', 'value' => 30, 'sort_order' => 10, 'resettable_period' => 1, 'resettable_interval' => 'm']),
new PlanFeature(['name' => 'listing_title_bold', 'value' => 'Y', 'sort_order' => 15])
]);
return $plan;
}
I will get my tests to green and back to you soon.
Thanks!!
from laravel-subscriptions.
Just to make sure this is not some dumb mistake made by me, this is the complete test method:
/** @test */
public function a_user_can_subscribe_to_a_plan()
{
// Create a plan and a user
$user = factory(\App\User::class)->create([
"email" => "[email protected]",
]);
$plan = app('rinvex.subscriptions.plan')->create([
'name' => 'Pro',
'description' => 'Pro plan',
'price' => 9.99,
'invoice_period' => 1,
'invoice_interval' => 'month',
'trial_period' => 15,
'trial_interval' => 'd',
'sort_order' => 1,
'currency' => 'USD',
]);
$plan->features()->saveMany([
new PlanFeature(['name' => 'listings', 'value' => 50, 'sort_order' => 1]),
new PlanFeature(['name' => 'pictures_per_listing', 'value' => 10, 'sort_order' => 5]),
new PlanFeature(['name' => 'listing_duration_days', 'value' => 30, 'sort_order' => 10, 'resettable_period' => 1, 'resettable_interval' => 'month']),
new PlanFeature(['name' => 'listing_title_bold', 'value' => 'Y', 'sort_order' => 15])
]);
// User makes a subscription:
$user->newSubscription("Pro", $plan);
// Assertions:
$this->assertEquals(1, $plan->subscriptions->count());
}
from laravel-subscriptions.
Can you try:
[
'name' => 'Pro',
'description' => 'Pro plan',
'price' => 9.99,
'signup_fee' => 0.00,
'invoice_period' => 1,
'invoice_interval' => 'm',
'trial_period' => 15,
'trial_interval' => 'd',
'sort_order' => 1,
'currency' => 'USD',
]
instead of:
[
'name' => 'Pro',
'description' => 'Pro plan',
'price' => 9.99,
'invoice_period' => 1,
'invoice_interval' => 'month',
'trial_period' => 15,
'trial_interval' => 'd',
'sort_order' => 1,
'currency' => 'USD',
]
invoice interval definition:
https://github.com/rinvex/subscriptions/blob/develop/src/Models/Plan.php#L188
signup fee definition:
https://github.com/rinvex/subscriptions/blob/develop/src/Models/Plan.php#L183
from laravel-subscriptions.
All interval
fields are now string-based that accepts (hour
, day
, week
, month
) .. You should be able to use the latest release without any issues bf8b67b
from laravel-subscriptions.
Hi, @noxify
I got the latest version of dev-develop
branch and now, when I run the code, it give these errors:
Illuminate\Support\MessageBag {#689
#messages: array:2 [
"trial_interval" => array:1 [
0 => "The selected trial interval is invalid."
]
"invoice_interval" => array:1 [
0 => "The selected invoice interval is invalid."
]
]
#format: ":message"
}
And with PlanFeature:
Illuminate\Support\MessageBag {#710
#messages: array:1 [
"resettable_interval" => array:1 [
0 => "The selected resettable interval is invalid."
]
]
#format: ":message"
}
array:8 [
"plan_id" => "required|integer|exists:plans,id"
"slug" => "required|alpha_dash|max:150|unique:plan_features,slug"
"name" => "required|string|max:150"
"description" => "nullable|string|max:10000"
"value" => "required|string"
"resettable_period" => "sometimes|integer"
"resettable_interval" => "sometimes|string|in:hour,day,week,month"
"sort_order" => "nullable|integer|max:10000000"
]
So, If I use "d" or "m" as periods, the rules are against it. Could you please, recheck them?
For example: in Plan Model (https://github.com/rinvex/subscriptions/blob/77e3f025915549b6329f6f0ffbc321a208678fa2/src/Models/Plan.php#L177) the rules are validating "month", "day" etc.
Thank you.
from laravel-subscriptions.
@ppalmeida you can NOT use short intervals any more. That said above already:
All interval
fields are now string-based that accepts (hour
, day
, week
, month
) .. You should be able to use the latest release without any issues bf8b67b
So would you please try with the long intervals 🙂
from laravel-subscriptions.
Hi, @Omranic.
What you said above is very strange. Because I get this error from my tests:
Method Illuminate\Support\Carbon::addMs does not exist
And in the Period.php class I can see this line:
$this->interval = in_array($interval, ['d', 'w', 'm', 'y']) ? $interval : 'm';
if ($count > 0) {
$this->period = $count;
}
$method = 'add'.ucfirst($this->interval).'s';
And this is exactly what I think is giving the erros. Because my factory looks like this:
$factory->define(Plan::class, function (Faker $faker) {
return [
'title' => 'Pro',
'description' => "pro plan", // $faker->sentence($nbWords = 6, $variableNbWords = true),
'price' => 9.99, // $faker->randomFloat($nbMaxDecimals = 2, $min = 9.0, $max = 50.0),
'signup_fee' => 0.00,
'invoice_period' => 1,
'invoice_interval' => 'month',
'trial_period' => 15,
'trial_interval' => 'day',
'sort_order' => 1,
'currency' => 'BRL',
];
});
$factory->define(PlanFeature::class, function (Faker $faker) {
return [
'title' => 'listing_duration_days',
'value' => 30,
'sort_order' => 10,
'resettable_period' => 1,
'resettable_interval' => 'month'
];
});
And the errors still happening, because of this IF:
https://github.com/rinvex/subscriptions/blob/f3d51ff17639c45ee0864ea1158111335bc35d87/src/Services/Period.php#L58
from laravel-subscriptions.
Nice catch, thank you @ppalmeida 👍
That was a mistakenly leftover, and now fixed on 285f08e 😉
from laravel-subscriptions.
Related Issues (20)
- Renew Subscription and try to use record feature usage, Unique Key constraint voilation HOT 2
- Problem with surcharging models (tenancy case) HOT 1
- Problem with surcharged models (multi-tenancy architecture) HOT 2
- sort_order doesnt take the value i have given it take increment value automatically in version 4.1.0 any help ? HOT 3
- Wrong morph columns name of migrated table HOT 2
- Mutiple currencies and prices HOT 1
- whats different starts_at and trial_ends_at HOT 1
- ERROR: There are no commands defined in the "rinvex:publish" namespace HOT 1
- Get bookings of the given user with plan price HOT 2
- what are prorate_period,prorate_extend_due, prorate_extend_day for? HOT 1
- How to get user current subscription HOT 7
- Trait "Rinvex\Subscriptions\Traits\HasPlanSubscriptions" not found HOT 2
- The model PlanSubscription returns false on canUseFeature
- Problem with installation on Laravel 7 HOT 2
- Laravel doesn't read migrations and configs from published files HOT 1
- How to implement default plan on user signup? [DONE] HOT 1
- How to get list of subscriptions that are due/past due?
- HasPlanSubscriptions Error HOT 5
- Creating Plans using Seeders Failing HOT 4
- Laravel 9 HOT 4
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 laravel-subscriptions.