#Asdrubale
1 messages · Page 1 of 1 (latest)
Sounds like your webhook endpoint is redirecting, which is that the 301 status denotes
This is not something that's configured in Stripe, but in your integration. Do you have a redirect configured on your domain/server? What does your code look like?
Also, what's the webhook endpoint URL?
I don't think to have redirect configured but apparently it seems to be like that
Ok, I tested that endpoint and I actually get a 400 error:
<br />\n<b>Warning</b>: Undefined array key \"HTTP_STRIPE_SIGNATURE\" in <b>/var/www/vhosts/albertiservice.it/httpdocs/api/webhook.php</b> on line <b>24</b><br />\n
Do you have a specific evt_xxx that returned a 301 response?
yep the 400 response returned the 301
Reading that error, sounds like there's an error in your code. Can you share your webhook code here?
<?php
// webhook.php
//
// Use this sample code to handle webhook events in your integration.
//
// 1) Paste this code into a new file (webhook.php)
//
// 2) Install dependencies
// composer require stripe/stripe-php
//
// 3) Run the server on http://localhost:4242
// php -S localhost:4242
// require 'vendor/autoload.php';
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
require_once('vendor/stripe/stripe-php/init.php');
include "fattura.php";
// This is your Stripe CLI webhook secret for testing your endpoint locally.
$endpoint_secret = 'whsec_qA1Nf3KMDvKeSoEgjfcVhRkpKgeQ7ott';//'whsec_2a4c8d022e6cd178163b79d2df22bcac33f16033555264fbf6a1d545b71a294e';
$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
http_response_code(400);
exit();
}
// Handle the event
switch ($event->type) {
case 'payment_intent.succeeded':
$paymentIntent = $event->data->object;
// ... handle other event types
default:
echo 'Received unknown event type ' . $event->type;
}
http_response_code(200);
this is the code, I pasted the code generated from stripe
What's your Stripe account ID?
acct_1LsSUUBWfwutbSUW
I think this is some kind of server/SSL issue
how can I find what's the source of this error?
before it was returning a tls error then I added an intermediate certificate and the webhook started returning the 301 error
I suspect the certificate is the issue
what should I do?
Hello 👋
Taking over as ynnoj needs to step away soon
I ran an SSLLab test on the domain you've provided and that looks fine I think
https://www.ssllabs.com/ssltest/analyze.html?d=albertiservice.it
Can you add some logging to your code to see if the request is hitting your server OR not?