#michael_python-json
1 messages ยท Page 1 of 1 (latest)
๐ 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/1225036632529305603
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
michael_python-json
@sturdy yoke I don't really get the code you shared. With stripe-python you get a real Python object that has all the properties of the object. I don't really see what "beautifying" means
For added context of the "What are you working on"... the aim of the python code is a reconciliation from the app db tables for user/club setups, and the completion of stripe payments etc. The display of event information in the app would be for individual customers to see their full payment and event history, possibly clicking to see invoices etc.
Re beatifying objects, it is making it more human readable like a single line on a table or dataframe, where only certain columns would be shown.
yeah I'm sorry this feels super abstract to me ๐
And every query I seem to run shows a single dataframe line returned... yet my events log on the dashboard has many events like invoices drafted, completed, subscription changed etc
You as the developer receive an Event object https://docs.stripe.com/api/events/object and you parse it and extract the relevant information such as the amount and currency of a payment for example
And every query I seem to run shows a single dataframe line returned
I don't know what those could mean. We don't have a concept of a dataframe or a query. I'm sorry I'm really not following yet
Are you maybe using a third-party library or system?
I am using python and the stripe library.
The below code produces just a single row of returned data... yet I have >3 expired session types in my dashboard events log
import pandas
import stripe
#stripe.api_key = "sk_live_xxx"
def deep_flatten_json(data, path=None):
if path is None:
path = []
if isinstance(data, dict):
for key, value in data.items():
yield from deep_flatten_json(value, path + [key])
elif isinstance(data, list):
for index, value in enumerate(data):
yield from deep_flatten_json(value, path + [str(index)])
else:
yield ('_'.join(path), data)
events = stripe.Event.list(type='checkout.session.expired')
flattened_events = dict(deep_flatten_json(events))
df_events = pandas.DataFrame([flattened_events])
df_events.columns = [col.replace("data_", "").replace("0_", "").replace("object_", "") for col in df_events.columns]
df_events
hi! I'm taking over this thread.
are you saying this stripe.Event.list(type='checkout.session.expired') returns a single event, but you were expecting more?
if so, can you share the request ID (req_xxx)? you can find it here https://dashboard.stripe.com/test/logs
This might be it - it is live, not test
req_GpcdhYjvMCITUX
This might be it - it is live, not test
I'm not sure what you mean. did you solve your issue?
actually - that req_id is days old... so not the right one