#Bassil-metadata
1 messages ยท Page 1 of 1 (latest)
Hi there
Hi @granite rampart! Can you clarify your question? What exactly is the issue?
My webhook should return meta data that contains info to update the order based on the payment intent ID...
Some of my webhooks return metadata and some dont
Could you share the event ID (evt_xxx) where the metadata is mssing?
Hmm okay one second please
"id": "pi_3K9kj7BStawTvwlL2ERo80YF",
This recent order the meta data is empty but the meta data for the order is there when i click the payment
so when the webhook hits my system and it tries to access the meta data in the return request, its empty and thus no order is created
"confirmation_method": "automatic",
"created": 1640254406,
"currency": "aed",
"customer": null,
"description": null,
"invoice": null,
"last_payment_error": null,
"livemode": true,
"metadata": {
},
That is from the webhook return request
Thanks, I'll have a look, give me a few minutes.
You are correct, this Payment Intent has some metadata, but in the webhook the metadata is null.
In this specific case, you updated the Payment intent with the metadata at the exact same time you confirmed it. So it's possible that the webhook doesn't contain the metadata yet.
You have two main options to solve this:
- Do the update call earlier in your flow, so that when confirming the payment intent you are sure the metadata is there
- Or in the webhook, take the Payement Intent ID and call the API to retrieve Payement Intent. This way you are sure to have the latest version with the metadata.
I like option 2, much safer to ensure nothing is missed due to front-end errors that cause the flow of updating/confirming to clash
I will try this approach thank you so much ๐
payment_intent_id = payment_intent['id']
payment_intent_obj = stripe.PaymentIntent.retrieve(payment_intent_id,)
metadata = payment_intent_obj['metadata']
I think it worked thank you so much. Used the Python SDK to retrieve stripe payment ID
from there accessed the metadata object instead of accessing the metadata from the webhook response
all i need from the webhook response as payment ID and then retrieve the Payment id as you mentioned
thank you ๐
Yes exactly! Happy to hear that you solved the issue ๐
If i delete a customer's order from my website and re send the webhook
in theory it should work right?
auto add the order?
Sorry I'm not sure I understood the question, could you try to clarify?
One second will test and then explain xD let me try
hmm
When i resent webhook request from stripe dashboard
No API key provided. (HINT: set your API key using "stripe.api_key = <API-KEY>"). You can generate API keys from the Stripe web interface. See https://stripe.com/api for details, or email support@stripe.com if you have any questions. lol
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
This was in my error logs in apache
looks like got this error after adding the retrieve payment from the stripe sdk for python
which api key do they want?
secret key or publishable key
oh forgot to add stripe.api_key lol
woops
looks like secret key
Yes, you need the secret key to retrieve a Payment Intent
Ok testing now
fingers crossed!
IT WORKED
WOOOHOOOOOOOOOOOOOO
I had a test transaction yesterday I did for 3 AED
๐ฅณ