#bhanu-webhooks-localhost

1 messages ยท Page 1 of 1 (latest)

zealous forum
#

Hi there

visual latch
#

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

zealous forum
#

You are specifically talking about that your invoice.payment_failed trigger is ending up failing?

visual latch
#

Yes but then I have changed the event

visual latch
#

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;

}

zealous forum
#

So the issue is your server endpoint doesn't receive the webhook?

visual latch
#

yes

zealous forum
#

Is there any error on your server?

#

Can you add an error_log after $payload like error_log($payload);?

visual latch
#

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?

zealous forum
#

The screenshot doesn't show a whole lot

visual latch
zealous forum
#

Yeah that seems fine

#

Is your server running on port 8000?

#

How are you starting your server?

visual latch
#

then in another tab i have call event

zealous forum
#

And where is the endpoint located in your project exactly?

visual latch
#

I am using laravel

#

I have started server using this port

zealous forum
#

Hmmm that is likely unrelated to the webhook itself... webhooks use POST requests

zealous forum
#

Okay so you have a WebhooksController.php file

#

Is that where your webhook code is located?

visual latch
zealous forum
#

What does your route look like?

#

Can I see it?

visual latch
zealous forum
#

Okay wait a second

visual latch
#

sure

zealous forum
#

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);

visual latch
#

Not like that

zealous forum
#

In that endpoint

visual latch
#

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

zealous forum
#

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?

visual latch
visual latch
zealous forum
#

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.

zealous forum
#

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

visual latch
#

yes exactly

visual latch
#

is there any solution?

zealous forum
#

Did you do the above?

visual latch
#

Yes

#

Already did

zealous forum
#

Okay great

#

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

visual latch
#

Still not working

#

I followed all the steps

#

But still not getting any email not in the spam

zealous forum
#

Can you provide the event ID for that payment_intent.succeeded?

visual latch
#

evt_3Lb7WZFmM52WOkSo1qKyJwTy

#

See no webhook event triggered

zealous forum
#

What version of the CLI are you on?

visual latch
#

How can I check?

zealous forum
#

stripe -v

visual latch
#

I'm using stripe shell

#

This one

zealous forum
#

Ah right forgot that won't show you CLI version

#

Okay testing on my own shell to make sure it works on my end

visual latch
#

ok

zealous forum
#

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

visual latch
zealous forum
#

๐Ÿ‘

#

Ah shoooot

#

I just have never run into this before

#

Dang. TIL

visual latch
#

evt_3Lb7t8FmM52WOkSo1akYguo0

zealous forum
#

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

visual latch
#

Got it

#

Let me try

#

Working!

#

Thanks for your help!

zealous forum
#

๐ŸŽ‰

#

Sorry again for the rabbit hole ๐Ÿ™‚

visual latch
#

I am doing first time to integrate the stripe API so that's why I am facing so many issues

zealous forum
#

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

visual latch
#

And my english is not good so there is some understanding issues

zealous forum
#

Ah yes that's an added challenge