#hx_code

1 messages ¡ Page 1 of 1 (latest)

rapid burrowBOT
#

👋 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. Thank you for your patience!

⏱️ We automatically close idle threads, which makes them read-only. Make sure you stick around to chat in realtime! If this thread is closed and you have another question you'll need to start a new thread.

🔗 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/1214932992183636008

📝 Have more to share? You can add more detail below, including code, screenshots, videos, etc.

astral spindleBOT
charred halo
#

Depends what you mean by 'works'?

#

What are you expecting, and what is actually happening?

#

If you use the top-level metadata parameter then the fields are only set on the Checkout Session object and related checkout.session.* events
If you use the nested payment_intent_data[metadata] parameter then the fields are only set on the resulting Payment Intent and related payment_intent.* events

#

I suspect that understanding will resolve your issue(s)

astral spindleBOT
charred halo
fierce elk
#

what i'm expecting is to add metadata to a checkout session on payment mode and see that metadata in checkout.session.completed event I receive via webhook, for example

{
  "id": "evt_xxx",
  "object": "event",
  "account": "acct_zzz",
  "api_version": "2022-08-01",
  "created": 1709732410,
  "data": {
    "object": {
      ...
      "metadata": {
        "my_value": "202403060939"
      },
      ...
    }
  },
}

as I mention before, adding the documentation here https://support.stripe.com/questions/using-metadata-with-checkout-sessions, suggest that I can use the payment_intent_data.metadata field to add this metadata, i've done it before and it has worked like this

$checkoutSession = Session::create([
            "line_items" => [
                [
                    "price" => "price_xxx",
                    "quantity" => 1
                ]
            ],
            "allow_promotion_codes" => true,
            "mode" => "payment",
            "payment_intent_data" => ["metadata" => ["key" => "value"]],
            "success_url" => $domain . "/stripe-example/success",
            "cancel_url" => $domain . "/stripe-example/cancel",
        ]);
        return redirect($checkoutSession->url);

but it suddenly stopped working and now I'm using the metadata field directly and it's working , so my question is what is causing this?

$checkoutSession = Session::create([
            "line_items" => [
                [
                    "price" => "price_xxx",
                    "quantity" => 1
                ]
            ],
            "allow_promotion_codes" => true,
            "mode" => "payment",
            "metadata" => ["key" => "value"],
            "success_url" => $domain . "/stripe-example/success",
            "cancel_url" => $domain . "/stripe-example/cancel",
        ]);
charred halo
#

If you're listening to checkout.session.completed events, then you need the top-level metadata parameter

fierce elk
#

ok, I'll check that then