#0_jennifer_0
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- 0_jennifer_0, 3 days ago, 37 messages
What's the issue
I am trying to add information related to EasyPost to my pay intents metadata, I can successfully do this for the client but the updated metadata doesnt display on the server
Can you share a request id where you set the metadata? https://support.stripe.com/questions/finding-the-id-for-an-api-request
would it be an id like this one? id": "pi_3OB1rqGqqYFSl2qM1KKIAAyk" this is my most recent event
"id": "pi_3OB1qPGqqYFSl2qM0w9G9A8Z" this one shows the metadata in the stripe dashboard
Sorry I thought you said metadata doesn't show?
Where are you not seeing metadata where you expect it to show? Because it is indeed set properly there
it isnt showing anywhere in my nextjs server
Ok but I need specifics. What do you mean it isn't showing in your server? It isn't showing the response object you get back upon updating metadata on the payment intent?
when I trigger a pay intent success using the CLI it successfully runs the code in my webhook but when I log out the event I do not see any metadata in the event object
Can you share the event id you're referring to?
"id": "evt_3OB2DnGqqYFSl2qM1nAKgOnr",
Ah that's because that's the payment intent.created event. You didn't set metadata on creation. You set it in a separate api call to update the payment intent, so you won't get metadata in that event
You set it later here: https://dashboard.stripe.com/test/logs/req_99JMjMcoO0mIpO
ah, so how do I resolve this?
What's your goal
If you want it in the payment_intent.created event just set metadata on creation of the payment intent instead
I would like to send the updated pay intent info to the webhook and then upon a successful pay intent, use the webhook to buy a shipment from EasyPost, unfortunately the shipping id and rate id arent known until a user fills out the address form and then selects a shipping rate.
I tried doing this manually using state variables but it looks like the webhook makes a separate http request so the variables I was sending to the API were not persisting or available for the webhook so I am hoping that sending them through the pay intents meta data will resolve the issue
So you don't need the metadata until successful payment?
You'll have the metadata in the payment_intent.succeeded event
It just isn't in the created event because that event occurred before you even set the metadata
ah, but when I log out the pay intent succeeded event the metadata isnt showing up there either
Can you share the event id
Because the payment intent from the above event never succeeded
It's still in requires_payment_method state
okay so if I fill out the form in test mode and hit submit on the pay button, the metadata appears as it should but running the cli isnt showing the updated metadata.
"id": "evt_3OB2fHGqqYFSl2qM0nEb9bMe" this event is from when I hit the submit button and this event was triggered from the cli "id": "evt_3OB2foGqqYFSl2qM0nN2q9ga",
That's because you add metadata after the payment is successful, so the state of the object hasn't been updated with metadata when you get it from the event.
can I still access the metadata in the pay intent success webhook?
Only if you added metadata during the creation of the Checkout Session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-payment_intent_data-metadata
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Im using a custom payment flow in my nextjs app is the checkout session created when I initially create my payment intent?
Ah, apologies. I thought you said you were using Checkout. What are you using on the front-end? Payment Element?
Also, can you just add the metadata to the Payment Intent when it's created?
I cannot because we dont know what the shipping rate or id will be until the user fills out their address and selects a rate option. I am using the Pay Element and Address Element and sending the information from the Address Element to the EasyPost api to get the shipping information.
Gotcha, okay. Can you listen for the on.change() event on the Address Element, then update the Payment Intent to have the metadata before the payment even goes through?
https://stripe.com/docs/js/element/events/on_change?type=addressElement
That would ensure that metadata is present in your payment_intent.succeeded event
that could work
Right on!
my api works! I didnt need to use the on.change() event, if I fill out all of the form info and press submit, the process works and buys a shipment from EasyPost. It just doesnt work with the CLI but when we're in production that wont be an issue
Ah! Good to hear it's working where it counts
thanks for your help! now to set EasyPosts webhook so I can fetch the tracking info ๐ the life of a developer