#Asdrubale

1 messages · Page 1 of 1 (latest)

dim talonBOT
sage bane
#

Sounds like your webhook endpoint is redirecting, which is that the 301 status denotes

plush gulch
#

yep, how can I fix that?

#

I can't find where the event request has been redirected

sage bane
#

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?

plush gulch
sage bane
#

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?

plush gulch
#

yep the 400 response returned the 301

sage bane
#

Reading that error, sounds like there's an error in your code. Can you share your webhook code here?

plush gulch
#

<?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

sage bane
#

What's your Stripe account ID?

plush gulch
#

acct_1LsSUUBWfwutbSUW

sage bane
#

I think this is some kind of server/SSL issue

plush gulch
#

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

sage bane
#

I suspect the certificate is the issue

plush gulch
#

what should I do?

alpine ice
#

Hello 👋
Taking over as ynnoj needs to step away soon

#

Can you add some logging to your code to see if the request is hitting your server OR not?