#Josef-webhooks
1 messages ยท Page 1 of 1 (latest)
๐ happy to help
could you please share the code you've implemented and your account id if you don't mind?
Sure, account id = acct_1L5RdUIrXZ5Do56H
<?php
echo "Starting \n";
require_once('./stripe-php-9.2.0/init.php');
echo "require working! \n";
// This is your Stripe CLI webhook secret for testing your endpoint locally.
$endpoint_secret = 'whsec_8bf11c6b6b58fdd01c4d2ae-----------------------------a95e6357da';
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
echo "starting try catch sequence! \n";
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
echo "stripe: invalid payload";
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
http_response_code(400);
echo "stripe: invalid signature";
exit();
}
// Handle the event
switch ($event->type) {
case 'checkout.session.completed':
$session = $event->data->object;
// ... handle other event types
echo "TODO: data output";
default:
echo 'Received unknown event type ' . $event->type;
}
http_response_code(200);
echo "stripe: working";
?>
// This is your Stripe CLI webhook secret for testing your endpoint locally.
$endpoint_secret = 'whsec_8bf11c6b6b58fdd01c4d2ae2f88b8e4c42a0b8a722dc186335a957a95e6357da';
did you by any chance change the whsec to the one from your created webhook endpoint?
Oh okay I updated the secret and the code runs further now, thanks!
I returns
"TODO: data output" (what is is supposed to do) but also
"Received unknown event type checkout.session.completed"
yes because you don't break on your switch case
alright, thank you for the help ๐
let me know if you need any more help
Are these discord threads private? Because of the secret keys (they are test keys anyway)
the webhook endpoint secret is safe to share
it's really the secret key sk_xxxx the one that you should never share
great, thank you
sure let me know if you need any more help