Flat-rate billing charges a fixed recurring amount regardless of how much a subscriber uses the product. Every subscriber on the same plan pays the same price each period, making it the simplest model to reason about and the easiest for customers to understand. Subscribd implements flat-rate plans with rule: 'flat' in your plan configuration.
Define flat-rate plans
Add your plans to config/subscribd.php under the plans key. All prices are in minor currency units — for USD, that means cents.
'plans' => [
'starter' => [
'name' => 'Starter',
'description' => 'Full product access for individuals.',
'rule' => 'flat',
'price' => 1900, // $19.00/month
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 1,
'trial_days' => 14,
'features' => [
'projects' => 5,
'api_access' => true,
'support' => 'email',
],
],
'pro' => [
'name' => 'Pro',
'description' => 'Everything in Starter, plus priority support.',
'rule' => 'flat',
'price' => 4900, // $49.00/month
'currency' => 'USD',
'interval' => 'month',
'interval_count' => 1,
'trial_days' => 14,
'features' => [
'projects' => null, // unlimited
'api_access' => true,
'support' => 'priority',
],
],
],
Set 'projects' => null to indicate an unlimited allowance. Subscribd’s entitlement checker interprets null as no cap.
After defining your plans, sync them to the database:
php artisan subscribd:plan sync
Subscribe a user
Use the fluent facade
The quickest way to subscribe a billable model is the Subscribd::for() facade:use Pixelworxio\Subscribd\Facades\Subscribd;
Subscribd::for($user)->subscribe('starter');
Or resolve the action directly
If you need more control — for example, in a queued job or when you already have a resolved Plan model — use the CreateSubscription action:use Pixelworxio\Subscribd\Actions\CreateSubscription;
use Pixelworxio\Subscribd\Models\Plan;
$plan = Plan::query()->where('key', 'starter')->firstOrFail();
app(CreateSubscription::class)->execute($user, $plan);
Upgrade with swap
When a subscriber upgrades (or downgrades) mid-cycle, use swap(). By default, Subscribd calculates a prorated credit or charge immediately.
You can change the global default proration behavior in config/subscribd.php by setting 'proration_strategy' to 'now', 'renewal', or 'none'. The per-call ['prorate' => ...] option always takes precedence.
Cancel a subscription
At period end
Immediately
Subscribd::for($user)->cancel();
The subscription moves to a grace period. The subscriber retains access until the current billing period expires, then the subscription cancels automatically.Subscribd::for($user)->cancel('default', immediately: true);
Access ends right away. Use this for fraud, abuse, or explicit user requests to stop billing immediately.
Canceling immediately does not issue a refund. Issue a refund separately through your payment gateway dashboard or via the Subscribd facade’s charge method with a negative amount if your gateway supports it.
Check subscription status
After subscribing, use the helpers provided by the ManagesBilling trait to gate access in your application:
$user->subscribed(); // has any active or trialing subscription
$user->subscribed('default'); // has the named subscription slot
$user->onTrial('default'); // currently in the trial period
$user->onGracePeriod('default'); // canceled but still within the paid period