You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace App\Console\Commands;
  3. use App\Models\Banking\ConnectedBankAccount;
  4. use App\Services\PlaidService;
  5. use Illuminate\Console\Command;
  6. class FirePlaidWebhook extends Command
  7. {
  8. /**
  9. * The name and signature of the console command.
  10. *
  11. * @var string
  12. */
  13. protected $signature = 'plaid:fire-webhook';
  14. /**
  15. * The console command description.
  16. *
  17. * @var string
  18. */
  19. protected $description = 'Command description';
  20. /**
  21. * Execute the console command.
  22. */
  23. public function handle(PlaidService $plaidService): void
  24. {
  25. $accessToken = ConnectedBankAccount::first()->access_token;
  26. $webhookCode = 'DEFAULT_UPDATE';
  27. $webhookType = 'TRANSACTIONS';
  28. try {
  29. $response = $plaidService->fireSandboxWebhook($accessToken, $webhookCode, $webhookType);
  30. $this->info('Webhook Fired Successfully' . PHP_EOL . json_encode($response, JSON_PRETTY_PRINT));
  31. } catch (\Exception $e) {
  32. $this->error('Failed to Fire Webhook' . PHP_EOL . $e->getMessage());
  33. }
  34. }
  35. }