#jazp_webhooks

1 messages ¡ Page 1 of 1 (latest)

stone belfryBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1270636718168735754

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

visual onyx
#

That's a common error and there could be various reason for it. Have you tried download the example code from our Doc?

#

And compare with your code

silver talon
#

yeah i'm using the exact example code

#

for your refernces
\Stripe\Stripe::setApiKey('secret key');

    $endpoint_secret = 'endpoint_Secret';

    $payload = @file_get_contents('php://input');
    $signatureHeader = $this->input->server('HTTP_STRIPE_SIGNATURE');
    $event = null;

    // Log the received payload and signature for debugging
    error_log("Received payload: " . $payload);
    error_log("Received signature: " . $signatureHeader);

    try {
        $event = \Stripe\Webhook::constructEvent(
            $payload,
            $signatureHeader,
            $endpoint_secret
        );
    } catch (\UnexpectedValueException $e) {
        // Invalid payload
        http_response_code(400);
        error_log("Invalid payload: " . $e->getMessage());
        exit();
    } catch (\Stripe\Exception\SignatureVerificationException $e) {
        // Invalid signature
        http_response_code(400);
        error_log("Invalid signature: " . $e->getMessage());
        exit();
    }

    // Handle the event
    switch ($event->type) {
        case 'payment_intent.succeeded':
            $paymentIntent = $event->data->object; // contains a \Stripe\PaymentIntent
            error_log("Handled event type: payment_intent.succeeded");
            break;
        case 'payment_method.attached':
            $paymentMethod = $event->data->object; // contains a \Stripe\PaymentMethod
            error_log("Handled event type: payment_method.attached");
            break;
            // ... handle other event types
        default:
            error_log('Received unknown event type ' . $event->type);
            echo 'Received unknown event type ' . $event->type;
    }

    http_response_code(200);
#

always get 400 status code

visual onyx
#

Did you download the example code and host it?

silver talon
#

i was checking on local mechine !!

#

smee.io is using connet the webhook in local

silver talon
#

waiting for your reply !

visual onyx
#

Sorry not sure what does that mean

visual onyx
#

Please try the example code here (don't touch the payload) and see if that works on your local server

stone belfryBOT