Getting the user ID in the job handler so as to process Stripe webhook payload #148
Replies: 2 comments 2 replies
-
The webhook is processing an API call that Stripe is making to your system; it's not a user-initiated action and it doesn't come through your web routing or authentication (which is why there's a secret to verify against). The easiest way I've found is to add metadata in the payment intent - that gets sent back to you in the webhook payload so you can use it to see who was it that did the buying (and anything else you want to put in the metadata). |
Beta Was this translation helpful? Give feedback.
-
I got it! You CAN add parameters to the Stripe payment link that come back in the payload. I found this article in the Stripe docs, Use URL parameters to customize the checkout experience I can pass the |
Beta Was this translation helpful? Give feedback.
-
So with Laravel-stripe-webhooks I can successfully receive and parse a Stripe payload in my dev system, with the help of Stripe CLI and listening for my endpoint. However, if I try to get the current user ID in the job, so as to process the payment they just made, the
Auth::User()
object comes back null. I can't get any user parameters, nor anydd()
responses out of the job code. I can, however, write to the logfile.What am I missing? Shouldn't I still be able to reference
Auth::User()
, or is there another designated way to get my user's ID in the processing code?This is my job used as the Stripe endpoint:
CustomerCreatedJob.php
The route:
Web.php
Route::stripeWebhooks('stripe-webhook');
In stripe-webhooks.php:
This is my logfile output, line-for-line where you can see the first two lines show blanks for the user data.
Seems like, an essential part to processing webhooks is to know who the authenticated user is that make them, right? I must be missing something....
Beta Was this translation helpful? Give feedback.
All reactions