#Temple
1 messages · Page 1 of 1 (latest)
👋 happy to help
Hey
400s are bad requests, meaning that there's something wrong in the params you sent
do you have a request ID I can take a look at?
So taking a look at the response i am getting this is what i recieve ```Stripe\Exception\SignatureVerificationException: No signatures found matching the expected signature for payload in C:\Projects\WebServer\www_php_includes\stripe-php\lib\Exception\SignatureVerificationException.php:28
In our logs it does not show and failed requests
only in our webhooks
I have event ids if that helps
did you go through the steps described here https://stripe.com/docs/webhooks/signatures ?
exit;
require 'stripe-php/init.php';
// The library needs to be configured with your account's secret key.
// Ensure the key is kept out of any version control system you might be using.
$stripe = new \Stripe\StripeClient(STRIPE_PRIVATE_KEY);
// This is your Stripe CLI webhook secret for testing your endpoint locally.
$endpoint_secret = 'whsec_***';
$payload = @file_get_contents('php://input');
$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
$event = null;
try {
$event = \Stripe\Webhook::constructEvent(
$payload, $sig_header, $endpoint_secret
);
} catch(\UnexpectedValueException $e) {
// Invalid payload
http_response_code(400);
exit();
} catch(\Stripe\Exception\SignatureVerificationException $e) {
// Invalid signature
echo $e;
http_response_code(400);
exit();
}
// Handle the event
switch ($event->type) {
case 'checkout.session.async_payment_failed':
$session = $event->data->object;
case 'checkout.session.async_payment_succeeded':
$session = $event->data->object;
case 'checkout.session.completed':
$session = $event->data->object;
// ... handle other event types
default:
echo 'Received unknown event type ' . $event->type;
}
http_response_code(200);``` I have commented out our endpoint secret, here is the code we are using
it seems ok
maybe the secret is wrong
you need to get the secret from the terminal after running stripe listen --forward-to
I will look into the secret, give me a moment
It appears the secret was incorrect however now we are getting a different 400 error Stripe\Exception\SignatureVerificationException: Timestamp outside the tolerance zone
what's the event ID?
evt_1MgkXXLOGsYi0T0ccQnEKNf7
We use UTC time and confirmed the time is in sync with Stripe so we are not too sure where to go from here
still taking a look just give me a second
basically you can't retry an event past a certain time
Im guessing the reason for the error is I see all the tests are being done with the same event id
I tried again with a different event id and we are getting a time difference of 3648
evt_1Mgm91LOGsYi0T0cmg4GM0qm
well there's two possible reasons
one is your server's clock is out of sync and is running slow/fast compared to the actual time
the other is that you are manually sending an old copy of the event to your server for testing instead of triggering new events from Stripe directly
This is the code we have for the time
We have fixed the issue by manually adding 1 hour
that's the code in our library yes https://github.com/stripe/stripe-php/blob/91876a7d/lib/WebhookSignature.php#L65-L72
what does that mean, what did you add where?
Asking my dev right now, I will get back to you when he responds
ah ok I thought we were talking to the dev, this server is for dev questions
Here is the updated code
he other is that you are manually sending an old copy of the event to your server for testing instead of triggering new events from Stripe directly
can you clarify that too
there's absolutely no reason you should need to be changing our library
We are now triggering new events so that part has been resolved
My bad, our dev doesn't like to use discord for privacy reasons so I thought I'd step in for him
so is the issue resolved?
great!