How to retrieve Stripe Webhook post data into $request
Hello Ladies and Gents, I need help with this. I have a Stripe Webhook that posts to a route within my app. This is assigned to a controller, at the moment I am just trying to log what I get to confirm I am getting the right information before I submit to my DB, my goal is to take this information and create a user so I'd like to get $request->name, $request->email, etc. But those return null, the current code on my controller functions returns Array to string conversion error. Any help on how to navigate through the json to get the data I need? Also I see Cashier already pulled in the Stripe class, is there a way to use functions from that class? Do have I have to use include(Stripe....) or is there a provider and facade for it?
Thank you in advance
Controller:
public function newcustomer(Request $request){
$created = $request->created;
$customer = $request->only('customer');
Log::info('Webhook : '.$created . ' and ' . $customer);
}
I did dd($request) and was able to get the following json response :
In your user model you should be storing the stripe id that is generated when you add the user to stripe, then you should query your users like so when a web hook is received:
The webhook is being triggered from another website, so when they first pay they are not interacting with this app yet. The client submits a form on another website, this form gets processed by Stripe and the Stripe webhook sends me a post with the information after processing credit card. So I need the webhook information to create the User. Is that request drilling down and getting the customer number ?
So my issue was navigating through Json, turns out you can just do $request->input('data.object.sources.data'); to navigate inside array within the json.