Install the package via composer:
composer require think.studio/laravel-cashier-subscription-pause
You can publish the migrations files with:
php artisan vendor:publish --provider="CashierSubscriptionPause\ServiceProvider" --tag="migrations"
use CashierSubscriptionPause\Eloquent\UsesPauseCollection;
use CashierSubscriptionPause\Eloquent\WithPauseCollection;
class Subscription extends \Laravel\Cashier\Subscription implements WithPauseCollection {
use UsesPauseCollection;
protected $table = 'stripe_subscriptions';
/**
* The attributes that should be cast to native types.
*
* @var array
*/
protected $casts = [
'quantity' => 'integer',
'pause_collection' => 'array',
];
}
$subscription = $user->subscription( 'main' );
$resumesAt = Carbon::now()->addWeek();
$subscription->pause(WithPauseCollection::BEHAVIOR_MARK_UNCOLLECTIBLE, $resumesAt);
$subscription->unpause();
$subscription->pauseBehaviorMarkUncollectible($resumesAt);
$subscription->pauseBehaviorKeepAsDraft($resumesAt);
$subscription->pauseBehaviorVoid($resumesAt);
$subscription->syncStripePauseCollection();
$subscription->paused());
$subscription->paused(WithPauseCollection::BEHAVIOR_MARK_UNCOLLECTIBLE);
$subscription->paused(WithPauseCollection::BEHAVIOR_KEEP_AS_DRAFT);
$subscription->paused(WithPauseCollection::BEHAVIOR_VOID);
$subscription->pauseResumesAtTimestamp();
$subscription->pauseResumesAt();
Subscription::query()->paused()->count();
Subscription::query()->notPaused()->count();
Subscription::query()->paused(WithPauseCollection::BEHAVIOR_VOID)->count();
Subscription::query()->notPaused(WithPauseCollection::BEHAVIOR_VOID)->count();
Subscription::query()->paused(WithPauseCollection::BEHAVIOR_MARK_UNCOLLECTIBLE)->count();
Subscription::query()->notPaused(WithPauseCollection::BEHAVIOR_MARK_UNCOLLECTIBLE)->count();
Subscription::query()->paused(WithPauseCollection::BEHAVIOR_KEEP_AS_DRAFT)->count();
Subscription::query()->notPaused(WithPauseCollection::BEHAVIOR_KEEP_AS_DRAFT)->count();
Do not use default listener:
<?php
namespace App\Providers;
use CashierSubscriptionPause\Listeners\CashierWebhookHandledEventListener;
use Illuminate\Support\ServiceProvider;
class AppServiceProvider extends ServiceProvider
{
public function boot()
{
// ...
CashierWebhookHandledEventListener::deactivateListener();
}
}