$_SERVER['HTTP_STRIPE_SIGNATURE'] Undefined index

3,635 views
Skip to first unread message

Joaquim Tresserra Figueras

unread,
Aug 24, 2020, 12:20:03 PM8/24/20
to Stripe API Discussion
Hello i am new to Stripe I have some code that worked for payments with card but now this line of code is failing,

$sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];

what could be the issue?

Thank you

Karl Reid

unread,
Aug 24, 2020, 1:01:14 PM8/24/20
to Stripe API Discussion
Hi there!

This code looks like it would be run in the context of your webhook handler function and is expecting the signature header that we include in the events to be present. [0] The error looks like the expected header is not present on the incoming request — there's a few reasons I can think of why it might not be present and thus result in this error which you might look into to investigate :
  • you might have a middleware or firewall in place around your server that is somehow removing the header from the incoming request from Stripe's servers.
  • this endpoint might be running in a context where the incoming request is not actually a webhook — note that a webhook endpoint should be be a separate endpoint and route in your system from perhaps the `success_url` of a CheckoutSession or the endpoint for charging a payment token, in case there is any confusion there.
  • although in most cases HTTP headers can be accessed through `$_SERVER` and the `HTTP_` prefix, there might be certain configurations of PHP or the hosting sever where that is not supported. If that's the case, you might try accessing the headers directly with `getallheaders()` instead. [1]
Beyond that, it's a little tricky to debug without more a specific example which can't be shared over a public mailing list — if the above doesn't help I'd encourage you to reach out to https://support.stripe.com/email with the full PHP code you're running and the Event ID `evt_xxx` of a webhook event where you've seen this behaviour and they'd be happy to help you debug this!

All the best,
Karl

Joaquim Tresserra Figueras

unread,
Aug 26, 2020, 3:24:07 PM8/26/20
to api-d...@lists.stripe.com
Hello There!

Thanks for the info I managed to solve the issue but I am getting a new one, when I am applying the function handlePaymentMethodAttached() for a methodAttached Iget the following message:


Uncaught Error: Call to undefined function handlePaymentMethodAttached()

How can this be?

Thanks

--
To unsubscribe from this group and stop receiving emails from it, send an email to api-discuss...@lists.stripe.com.

Remi J.

unread,
Aug 26, 2020, 3:27:43 PM8/26/20
to api-d...@lists.stripe.com
Hello Joaquim,

The `handlePaymentMethodAttached()` is just a placeholder here. You would need to write your own code/logic to handle that event and react accordingly, for example by updating your own database to reflect the change.

I hope this helps! I'd recommend talking to our support team if you have any follow up questions about this and they would be better equipped to help with those questions: https://support.stripe.com/contact

Best,
Remi
Reply all
Reply to author
Forward
0 new messages