#energetic_chipmunk_58090

1 messages · Page 1 of 1 (latest)

vivid yachtBOT
vast cave
#

hello

quaint loom
#

Hi
In general webhook signature fails for two main reasons:

  • Using wrong webhook secret
  • Changing the body request of the event
vast cave
#

i also tried the quickstart which generated me the webhook code

#

exactly the one you sent me

#

webhook secreet is the one that starts with we_

quaint loom
#

yes from the stripe cli if you are using one

#

What is the error you are getting ?

vast cave
#

public function stripe_webhook() {
$endpoint_secret = 'we_1NlUSqGgbXKwgAV1TxypMJx7';

$payload = @file_get_contents('php://input');
$event = null;

try {
  $event = \Stripe\Event::constructFrom(
    json_decode($payload, true)
  );
} catch(\UnexpectedValueException $e) {
  // Invalid payload
  echo '⚠️  Webhook error while parsing basic request.';
  http_response_code(400);
  exit();
}
if ($endpoint_secret) {
  // Only verify the event if there is an endpoint secret defined
  // Otherwise use the basic decoded event
  $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
  try {
    $event = \Stripe\Webhook::constructEvent(
      $payload, $sig_header, $endpoint_secret
    );
  } catch(\Stripe\Exception\SignatureVerificationException $e) {
    // Invalid signature
    echo '⚠️  Webhook error while validating signature.';
    http_response_code(400);
    exit();
  }
}

// Handle the event
switch ($event->type) {
  case 'payment_intent.succeeded':
    $paymentIntent = $event->data->object; // contains a \Stripe\PaymentIntent
    // Then define and call a method to handle the successful payment intent.
    // handlePaymentIntentSucceeded($paymentIntent);
    break;
  case 'payment_method.attached':
    $paymentMethod = $event->data->object; // contains a \Stripe\PaymentMethod
    // Then define and call a method to handle the successful attachment of a PaymentMethod.
    // handlePaymentMethodAttached($paymentMethod);
    break;
  default:
    // Unexpected event type
    error_log('Received unknown event type');
}

http_response_code(200);

}

#

Webhook error while validating signature.';

#

this is my webhook function

#

i tried multiple times from scratch but no luck

quaint loom
#
$endpoint_secret = 'we_1NlUSqGgbXKwgAV1TxypMJx7';

This isn't the webhook secret, this is the webhook Id

vast cave
#

:/

#

this have been the issue

#

all the time

#

oh god

#

whsec_

#

this is the secret

#

life saver...