Skip to content

Commit

Permalink
Update WebhookCommand
Browse files Browse the repository at this point in the history
  • Loading branch information
driesvints committed Jun 22, 2021
1 parent f650efa commit 1d9cce8
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions src/Console/WebhookCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@

use Illuminate\Console\Command;
use Laravel\Cashier\Cashier;
use Stripe\WebhookEndpoint;

class WebhookCommand extends Command
{
Expand Down Expand Up @@ -32,7 +31,7 @@ class WebhookCommand extends Command
*/
public function handle()
{
$endpoint = WebhookEndpoint::create([
$endpoint = Cashier::stripe()->webhookEndpoints->create([
'enabled_events' => [
'customer.subscription.created',
'customer.subscription.updated',
Expand All @@ -43,12 +42,12 @@ public function handle()
],
'url' => $this->option('url') ?? route('cashier.webhook'),
'api_version' => $this->option('api-version') ?? Cashier::STRIPE_VERSION,
], Cashier::stripeOptions());
]);

$this->info('The Stripe webhook was created successfully. Retrieve the webhook secret in your Stripe dashboard and define it as an environment variable.');

if ($this->option('disabled')) {
WebhookEndpoint::update($endpoint->id, ['disabled' => true], Cashier::stripeOptions());
$endpoint->update($endpoint->id, ['disabled' => true]);

$this->info('The Stripe webhook was disabled as requested. You may enable the webhook via the Stripe dashboard when needed.');
}
Expand Down

0 comments on commit 1d9cce8

Please sign in to comment.