File tree Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Expand file tree Collapse file tree 3 files changed +35
-1
lines changed Original file line number Diff line number Diff line change 3737 */
3838 'profile ' => \Spatie \StripeWebhooks \StripeWebhookProfile::class,
3939
40+ /*
41+ * Specify a connection and or a queue to process the webhooks
42+ */
43+ 'connection ' => env ('STRIPE_WEBHOOK_CONNECTION ' ),
44+ 'queue ' => env ('STRIPE_WEBHOOK_QUEUE ' ),
45+
4046 /*
4147 * When disabled, the package will not verify if the signature is valid.
4248 * This can be handy in local environments.
Original file line number Diff line number Diff line change 44
55use Spatie \StripeWebhooks \Exceptions \WebhookFailed ;
66use Spatie \WebhookClient \Jobs \ProcessWebhookJob ;
7+ use Spatie \WebhookClient \Models \WebhookCall ;
78
89class ProcessStripeWebhookJob extends ProcessWebhookJob
910{
11+ public function __construct (WebhookCall $ webhookCall )
12+ {
13+ parent ::__construct ($ webhookCall );
14+ $ this ->onConnection (config ('stripe-webhooks.connection ' ));
15+ $ this ->onQueue (config ('stripe-webhooks.queue ' ));
16+ }
17+
1018 public function handle ()
1119 {
1220 if (! isset ($ this ->webhookCall ->payload ['type ' ]) || $ this ->webhookCall ->payload ['type ' ] === '' ) {
@@ -31,7 +39,7 @@ public function handle()
3139 protected function determineJobClass (string $ eventType ): string
3240 {
3341 $ jobConfigKey = str_replace ('. ' , '_ ' , $ eventType );
34-
42+
3543 $ defaultJob = config ('stripe-webhooks.default_job ' , '' );
3644
3745 return config ("stripe-webhooks.jobs. {$ jobConfigKey }" , $ defaultJob );
Original file line number Diff line number Diff line change @@ -88,4 +88,24 @@ public function it_will_dispatch_events_even_when_no_corresponding_job_is_config
8888
8989 $ this ->assertNull (cache ('dummyjob ' ));
9090 }
91+
92+ /** @test */
93+ public function it_can_specify_a_connection_in_the_config ()
94+ {
95+ config (['stripe-webhooks.connection ' => 'some-connection ' ]);
96+
97+ $ processStripeWebhookJob = new ProcessStripeWebhookJob ($ this ->webhookCall );
98+
99+ $ this ->assertEquals ('some-connection ' , $ processStripeWebhookJob ->connection );
100+ }
101+
102+ /** @test */
103+ public function it_can_specify_a_queue_in_the_config ()
104+ {
105+ config (['stripe-webhooks.queue ' => 'some-queue ' ]);
106+
107+ $ processStripeWebhookJob = new ProcessStripeWebhookJob ($ this ->webhookCall );
108+
109+ $ this ->assertEquals ('some-queue ' , $ processStripeWebhookJob ->queue );
110+ }
91111}
You can’t perform that action at this time.
0 commit comments