#Bassil-metadata

1 messages ยท Page 1 of 1 (latest)

buoyant ivy
granite rampart
#

Hi there

buoyant ivy
#

Hi @granite rampart! Can you clarify your question? What exactly is the issue?

granite rampart
#

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

buoyant ivy
#

Could you share the event ID (evt_xxx) where the metadata is mssing?

granite rampart
#

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

buoyant ivy
#

Thanks, I'll have a look, give me a few minutes.

granite rampart
#

Response sorry

#

Okay

buoyant ivy
#

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:

  1. Do the update call earlier in your flow, so that when confirming the payment intent you are sure the metadata is there
  2. 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.
granite rampart
#

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 ๐Ÿ™‚

granite rampart
#
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 ๐Ÿ™‚

buoyant ivy
#

Yes exactly! Happy to hear that you solved the issue ๐Ÿ™‚

granite rampart
#

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?

buoyant ivy
#

Sorry I'm not sure I understood the question, could you try to clarify?

granite rampart
#

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

#

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

buoyant ivy
#

Yes, you need the secret key to retrieve a Payment Intent

granite rampart
#

Ok testing now

#

fingers crossed!

#

IT WORKED

#

WOOOHOOOOOOOOOOOOOO

#

I had a test transaction yesterday I did for 3 AED

buoyant ivy
#

๐Ÿฅณ

granite rampart
#

same issue, just resent the webhook

#

it created the order

#

I love you Soma

#

thank you so much

#

โค๏ธ

#

Stripe if you hear this GIVE THIS PERSON A PROMOTION