#bhanu-webhooks-localhost
1 messages ยท Page 1 of 1 (latest)
I have triggered a mail when webhook call
But not getting email and I have double check my email function but that's working
This is my localhost url
You are specifically talking about that your invoice.payment_failed trigger is ending up failing?
No I am not talking about specifically invoice.payment_failed
I am talking about the the all webhooks
public function subscription(Request $request)
{
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
$payload = @file_get_contents('php://input');
$event = null;
try {
$event = \Stripe\Event::constructFrom(
json_decode($payload, true)
);
} catch(\UnexpectedValueException $e) {
http_response_code(400);
exit();
}
Mail::raw('Hello World!', function($msg) {$msg->to('developer131220@gmail.com')->subject('Test Email'); });
die;
}
So the issue is your server endpoint doesn't receive the webhook?
yes
Is there any error on your server?
Can you add an error_log after $payload like error_log($payload);?
No I think the url not hitting up
because I have place an email function line no 1
I think i am doing something wrong with the local URL
Have you checked in the screenshot?
The screenshot doesn't show a whole lot
First I call stripe listen --forword-to http://127.0.0.1:8000/webhook/subscription this command
Yeah that seems fine
Is your server running on port 8000?
How are you starting your server?
then in another tab i have call event
And where is the endpoint located in your project exactly?
Hmmm that is likely unrelated to the webhook itself... webhooks use POST requests
Yes
Okay so you have a WebhooksController.php file
Is that where your webhook code is located?
I was sharing for just to show you the URL
Yes
Okay wait a second
sure
I'm not intimately familiar with Laravel so trying to piece this together
But your endpoint does subscription(Request $request)
Which this means that when a request hits your endpoint it will be stored in $request, no?
What happens when you error_log($request);
Not like that
In that endpoint
I can remove Request $request
Request $request are not using here this was just added by someone
I just removed Request $request
This will not effect in the webhook request
public function subscription()
{
Mail::raw('Hello World!', function($msg) {$msg->to('developer131220@gmail.com')->subject('Test Email'); });
}
When i use this code but not working. It should be working if endpoint is hitting up correctly
using the webhook
Sure. That's what I'm trying to help you debug... why is the webhook not hitting your endpoint.
Can I see one of the events real quick that you have sent?
Don't know I'm asking you. have you checked my previous message that i have sent you the steps that i am following to hit the localhost endpoint
Not getting you what you need basically
If you used stripe listen --forward-to http://127.0.0.1:8000/webhook/subscriptions and your server is running on port 8000 and your endpoint is set up at that URL then it will work.
So there is something out of those things that is incorrect.
Yeah okay so I'd start from the beginning. First I'd simplify the code you have at that endpoint to just echo something back to the browser.
Then I'd try to hit that endpoint in the browser
And ensure that you are seeing that code run correctly when you hit the endpoint
That would be the first step to make sure your endpoint is set up correctly
yes exactly
is there any solution?
Did you do the above?
Okay great
Then let's re-add your webhook code but tweak it to use our default integration builder that we show here: https://stripe.com/docs/webhooks/quickstart
Let's make sure that works before you tweak it for your own use.
Once you add that, let's restart your CLI using stripe listen --forward-to xxxx
Still not working
I followed all the steps
But still not getting any email not in the spam
Can you provide the event ID for that payment_intent.succeeded?
What version of the CLI are you on?
How can I check?
stripe -v
Ah right forgot that won't show you CLI version
Okay testing on my own shell to make sure it works on my end
ok
Ugh
Not working for me either
Let's test on yours without Stripe Shell
Using the CLI directly
And I'll put in a bug report assuming that is actually the issue here
Sorry that you ran into this ๐ฆ
Do you know how to test with CLI directly?
Otherwise I can walk you through it
No worry, I'm trying to install CLI using command in my terminal
๐
Ah shoooot
We actually do call this out: https://stripe.com/docs/stripe-shell/overview#use-the-stripe-cli-for-local-development
I just have never run into this before
Dang. TIL
Okay that's good. It is successfully hitting your endpoint now and you are just sending back a 403 based on your webhook code. So it all does seem to be working now.
Now you can play with your code to ensure emails are sent based on the event you receive
And you'll want to make sure you return a 200 to Stripe in response to the webhook
I have to step away but @wraith arrow can help with anything else you need here
I am doing first time to integrate the stripe API so that's why I am facing so many issues
Yeah our documentation is really good โ like it did call this out... but it is also very verbose so easy to miss stuff like this.
I missed it too clearly
And my english is not good so there is some understanding issues
Ah yes that's an added challenge