#pedro-mameluque_webhooks

1 messages ยท Page 1 of 1 (latest)

zenith mistBOT
#

๐Ÿ‘‹ 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/1350116930367000606

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

torpid fulcrum
#

Hello ๐Ÿ™‚

twilit junco
#

Hi, did that trigger checkout.session.completed?

#

Oh, are you saying why these events are failing on your end?

torpid fulcrum
#

yes! it triggered but failed with 500

#

and for my paid events it doesn't fail.. it's just for free, so 0 amount transsaction

#

and I notided that the main difference as well is that they don don't generate a payment intent id

#

this is how i create the stripe checjkout session

twilit junco
#

We document this here: https://support.stripe.com/questions/webhooks-what-to-do-when-the-http-status-code-starts-with-a-four-(4xx)-or-five-(5xx)

There is not much we can debug as you're responding with 500 and sending 'Error processing webhook' back to us.

When you encounter this error, check your server's error logs for more information. The location of error logs varies from server to server, based on configuration, operating system, web server, the programming languages being used and other factors, so we can't provide specific instructions.

torpid fulcrum
#


// Create Stripe Checkout Session
  const session = await stripe.checkout.sessions.create(
    {
      payment_method_types: ["card"],
      line_items: [
        {
          price_data: {
            currency: "brl",
            product_data: {
              name: event.name,
              description: event.description,
            },
            unit_amount: Math.round(finalPrice), // Apply discount
          },
          quantity: 1,
        },
      ],
      payment_intent_data: {
        application_fee_amount: Math.round(finalPrice * 0.04), // aqui fica a taxa de servico
      },
      expires_at: Math.floor(Date.now() / 1000) + DURATIONS.TICKET_OFFER / 1000, // 30 minutes (Stripe minimum expiration time)
      mode: "payment",
      success_url: `${baseUrl}/tickets`,
      cancel_url: `${baseUrl}/event/${eventId}`,
      metadata, // Include the metadata with coupon
    },
    {
      stripeAccount: stripeConnectId,
    }
  );

twilit junco
#

There is not an issue on the way you create the Checkout, you'd need to debug this on your end. Especially since your other non-zero checkout.session.completed events work.

torpid fulcrum
#

this is where i receive the webhook and construct the event


export async function POST(req: Request) {
  console.log("Webhook received");

  const body = await req.text();
  const headersList = await headers();
  const signature = headersList.get("stripe-signature") as string;

  console.log("Webhook signature:", signature ? "Present" : "Missing");

  let event: Stripe.Event;

  try {
    console.log("Attempting to construct webhook event");
    event = stripe.webhooks.constructEvent(
      body,
      signature,
      process.env.STRIPE_WEBHOOK_SECRET!
    );
    console.log("Webhook event constructed successfully:", event.type);
  } catch (err) {
    console.error("Webhook construction failed:", err);
    return new Response(`Webhook Error: ${(err as Error).message}`, {
      status: 400,
    });
  }

#

it dosn't seem wrong as well..

twilit junco
#

You're getting checkout.session.completed events from your non-zero transactions right?