#mactavish_webhooks

1 messages ยท Page 1 of 1 (latest)

potent peakBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1240655842685096018

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

azure galleon
#

Hello

#

Have you logged out the body that you are passing to constructEvent()?

thin kiln
#

Hi bismarck, Hope you're doing well.

As for the issue, it seems like it might be an overlook but my eyes are unable to figure out.

azure galleon
#

What do you see when you log out the body?

#

Do you see JSON?

#

Or do you see binary (a buffer data type)?

thin kiln
#

The payload is raw JSON

azure galleon
#

Yep okay so that isn't the raw body then

#

What framework are you using?

thin kiln
azure galleon
#

Can you show me your handler code?

thin kiln
# azure galleon Can you show me your handler code?
$paymentGatewayCredentials = $this->getStripeCredentials();
        \Stripe\Stripe::setApiKey($paymentGatewayCredentials->StripeSecretKey);
        $endpoint_secret = $paymentGatewayCredentials->StripeWebhookSecret;

        $signature = $request->header('stripe-signature');
        $payload = $request->getContent();

        Log::channel('stripeWebhooks')->info("------------------------- Payload Dump -------------------------");
        Log::channel('stripeWebhooks')->info($payload);

        try {
            $event = \Stripe\Webhook::constructEvent($payload, $signature, $endpoint_secret, 999999999999);

            if ($event->type === 'checkout.session.completed') {
                $this->onCheckoutSessionCompleted($event);
            }
            elseif ($event->type === 'customer.subscription.updated') {
                Log::channel('stripeWebhooks')->info("Subscription Updated Event, about to call stored procedure!");
                $this->onSubscriptionUpdated($event);
            }
        } catch (\UnexpectedValueException $e) { // Invalid payload
            Log::channel('stripeWebhooks')->info("@webhooksHandler(): Invalid payload");
            return response('', 400);
        }
        catch(\Stripe\Exception\SignatureVerificationException $e) { // Invalid signature
            Log::channel('stripeWebhooks')->info("@webhooksHandler(): Invalid signature. Signature Used : {$signature}");
            return response('', 400);
        }
        return response('', 200);
azure galleon
#

How are you initializing $request ?

thin kiln
azure galleon
#

Can you log out $request to see its properties?

#

Maybe there is something there that indicates a way to get the raw body as opposed to getContent() which seems to JSONify it

#

Also what is the exact error message that you see in your Webhook handler?

#

You have double checked that you are using your Webhook secret from the Dashboard for that specific endpoint?

#

And you aren't forwarding via the CLI correct?

thin kiln
#

Nvm, Internal stupidity.
It was livemode secret being used.

Can Stripe SDK mention that secret from other mode is being used? just like it does for other objects in SDK?

#

will save up instances like this

azure galleon
#

That's a good idea

#

I'll file some feedback internally about that

thin kiln
#

Great, Thank you!
You may close the thread now

Have a great day ahead!! ๐Ÿ™‚