#Senthill-webhook-signature

1 messages · Page 1 of 1 (latest)

willow turret
#

Hi there, can you share your webhook code?

rancid talon
#

Stripe::setApiKey(Yii::$app->params['stripe']['secretKey']);
$endpoint_secret = 'whsec_np5....Y4MPgxV7';

    $payload = @file_get_contents('php://input');
    $sig_header = $_SERVER['HTTP_STRIPE_SIGNATURE'];
    $event = null;

    try {
        $event = \Stripe\Event::constructFrom(
            json_decode($payload, true), $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();
    }
#

No matter what incorrect value I supply to $endpoint_secret the exception does not get triggered.

willow turret
#

I think it is supposed to be \Stripe\Event::constructEvent

#

I admit I am not the most familiar with PHP

#

But I'd log out to make sure you are receiving your endpoint secret in the event construction

rancid talon
#

Error: Call to undefined method Stripe\Event::constructEvent()

#

I am just passing the end-point string ...

#

it's hardcoded from the output of the local listner. In fact here I am actually forcing a wrong value - so it should raise an error

willow turret
#

k give me a sec

rancid talon
#

here is the stripe event object ... does not seem to have the endpoint.

willow turret
#

You aren't seeing the event actually send to the webhook?

rancid talon
#

I get the webhook and able to process it fine. That works. Just that even if I validate against an incorrect key it still works!

#

So a malicious user can simply send me webhooks and I would think stripe is confirming payments

#

I suspect this may be a bug

willow turret
#

Give me a second. This may be due to using the CLI

rancid talon
#

oh ok

willow turret
#

You aren't forwarding events to your server, correct? You are just listening via the CLI?

rancid talon
#

I am forwarding to my server

#

and my server gets the request and processes it - all good there

willow turret
#

Okay thanks

#

Still looking to confirm if this is specific to forwarding via CLI

#

Or if something else going on

rancid talon
#

ok thanks

willow turret
#

Okay yes, so with the CLI the signing secret is dictated by the CLI itself.

rancid talon
#

ok will test it out