#mactavish_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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.
What do you see when you log out the body?
Do you see JSON?
Or do you see binary (a buffer data type)?
The payload is raw JSON
Yup. that's what I mentioned initially. been there some time ago ๐ and suggested to add a note in docs (which is done now)
As for Framework, It's Laravel 10
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);
How are you initializing $request ?
It's received in controller function like this:
public function webhooksHandler(Request $request)
{
// above code here
}
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?
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
Great, Thank you!
You may close the thread now
Have a great day ahead!! ๐