diff --git a/composer.json b/composer.json index d59fd54..92a363d 100644 --- a/composer.json +++ b/composer.json @@ -18,20 +18,20 @@ } ], "require": { - "php": ">=7.1.3", - "illuminate/database": "~5.6", - "illuminate/support": "~5.6", - "nesbot/carbon": "^2.0", - "symfony/http-kernel": "~2.7|~3.0|~4.0", - "guzzlehttp/guzzle": "^6.0" + "php": "^8.0", + "illuminate/database": "^9.21|^10.0|^11.0", + "illuminate/support": "^9.21|^10.0|^11.0", + "nesbot/carbon": "^2.0|^3.0", + "symfony/http-kernel": "^6.0|^7.0", + "guzzlehttp/guzzle": "^7.2" }, "require-dev": { - "illuminate/http": "~5.6", - "illuminate/routing": "~5.6", + "illuminate/http": "^9.21|^10.0|^11.0", + "illuminate/routing": "^9.21|^10.0|^11.0", "mockery/mockery": "~1.0", - "phpunit/phpunit": "~7.0", + "phpunit/phpunit": "^9.0", "vlucas/phpdotenv": "^3.3", - "orchestra/testbench": "~3.6" + "orchestra/testbench": "^7.0|^8.0" }, "autoload": { "psr-4": { diff --git a/readme.md b/readme.md index 888266d..440c912 100644 --- a/readme.md +++ b/readme.md @@ -91,7 +91,7 @@ After publishing them, you can find migration files in your `database/migrations Next, add the Billable trait to your model definition. This trait provides various methods to allow you to perform common billing tasks, such as creating and checking subscriptions, getting orders etc. ```php -use Laravel\Cashier\Billable; +use TwentyTwoDigital\CashierFastspring\Billable; class User extends Authenticatable { @@ -108,7 +108,6 @@ You should add Fastspring configuration to `config/services.php` file. 'model' => App\User::class, 'username' => env('FASTSPRING_USERNAME'), 'password' => env('FASTSPRING_PASSWORD'), - 'store_id' => env('FASTSPRING_STORE_ID'), // strongly recommend to set hmac secret in webhook configuration // to prevent webhook spoofing @@ -121,10 +120,9 @@ You should add Fastspring configuration to `config/services.php` file. Fastspring can notify your application of a variety of events via webhooks. To handle webhooks, define a route and also set it in Fastspring settings. ```php -Route::post( - 'fastspring/webhook', - '\TwentyTwoDigital\CashierFastspring\Http\Controllers\WebhookController@handleWebhook' -)->name('fastspringWebhook'); +use TwentyTwoDigital\CashierFastspring\Http\Controllers\WebhookController; + +Route::post('/webhook/fastspring', [WebhookController::class, 'handleWebhook'])->name('webhook.fastspring'); ``` #### Webhooks & CSRF Protection @@ -150,26 +148,37 @@ Remember that you can create and use your listeners and database structure accor In Cashier Fastspring, every webhook request fires related events. You can register listeners to webhook events in `app/providers/EventServiceProvider.php`. You can see more at [Webhooks](#webhooks). ```php +use TwentyTwoDigital\CashierFastspring\Events\OrderCompleted; +use TwentyTwoDigital\CashierFastspring\Events\SubscriptionActivated; +use TwentyTwoDigital\CashierFastspring\Events\SubscriptionCanceled; +use TwentyTwoDigital\CashierFastspring\Events\SubscriptionChargeCompleted; +use TwentyTwoDigital\CashierFastspring\Events\SubscriptionDeactivated; +use TwentyTwoDigital\CashierFastspring\Events\SubscriptionPaymentOverdue; +use TwentyTwoDigital\CashierFastspring\Listeners\OrderCompleted as OrderCompletedListener; +use TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionChargeCompleted as SubscriptionChargeCompletedListener; +use TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionDeactivated as SubscriptionDeactivatedListener; +use TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionStateChanged; + protected $listen = [ // some others - 'TwentyTwoDigital\CashierFastspring\Events\SubscriptionCanceled' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionStateChanged' + SubscriptionCanceled::class => [ + SubscriptionStateChanged::class, ], - 'TwentyTwoDigital\CashierFastspring\Events\SubscriptionDeactivated' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionDeactivated' + SubscriptionDeactivated::class => [ + SubscriptionDeactivatedListener::class, ], - 'TwentyTwoDigital\CashierFastspring\Events\SubscriptionPaymentOverdue' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionStateChanged' + SubscriptionPaymentOverdue::class => [ + SubscriptionStateChanged::class, ], - 'TwentyTwoDigital\CashierFastspring\Events\OrderCompleted' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\OrderCompleted' + OrderCompleted::class => [ + OrderCompletedListener::class, ], - 'TwentyTwoDigital\CashierFastspring\Events\SubscriptionActivated' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionActivated' + SubscriptionActivated::class => [ + SubscriptionActivatedListener::class, + ], + SubscriptionChargeCompleted::class => [ + SubscriptionChargeCompletedListener::class, ], - 'TwentyTwoDigital\CashierFastspring\Events\SubscriptionChargeCompleted' => [ - 'TwentyTwoDigital\CashierFastspring\Listeners\SubscriptionChargeCompleted' - ] ]; ``` diff --git a/src/Events/SubscriptionUncanceled.php b/src/Events/SubscriptionUncanceled.php new file mode 100644 index 0000000..246a232 --- /dev/null +++ b/src/Events/SubscriptionUncanceled.php @@ -0,0 +1,7 @@ +