#nicolas-m_api
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/1333581730610679870
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi there
hello
Not quite sure I follow. So you have a Customer and a Charge, and you want to find Price/Plan details from that Charge? Do you have an example Charge ID?
yes! for example, someone buys something, then there is a plan, which hypothetically is "Premium Plan", I want to find that name in the charge object, in the charges endpoint, and it has that description, which gives me that name, but with what other information I don't need, like (at {somevalue} / every x months)
i have this chargeId: ch_3Qm1FSCncruDcoif0RKTSf8W
"description": "1 Ă Plano Tipster (at R$ 220.00 / every 3 months)", as you can see, there is other information in the description (I assume this information is not in the actual name of the plan)
So neither the Charge nor the PaymentIntent will contain the Price details. You'll need to inspect the relevant Invoice object instead
So you can retrieve the Charge and expand the Invoice: https://docs.stripe.com/api/charges/object#charge_object-invoice
yes, im already doing this, but the price object dont give me this information (the name)
"price": {
"id": "price_1NxeeZCncruDcoifcnxY6djX",
"object": "price",
"active": true,
"billing_scheme": "per_unit",
"created": 1696462735,
"currency": "brl",
"custom_unit_amount": null,
"livemode": true,
"lookup_key": null,
"metadata": {},
"nickname": null,
"product": "prod_O7LoGL8x5NiPws",
"recurring": {
"aggregate_usage": null,
"interval": "month",
"interval_count": 3,
"meter": null,
"trial_period_days": null,
"usage_type": "licensed"
},
"tax_behavior": "unspecified",
"tiers_mode": null,
"transform_quantity": null,
"type": "recurring",
"unit_amount": 22000,
"unit_amount_decimal": "22000"
},
(using this object as example)
&expand[]=data.product like doing this?
If you're using Node, it'd be something like expand: ['lines.data[0].price.product'] if you're retrieving an Invoice but I might have the syntax wrong
this is the url im using rn
https://api.stripe.com/v1/charges?limit=100&expand[]=data.customer&expand[]=data.invoice.subscription&expand: ['lines.data[0].price.product']
but I don't think it works, as the object is not expanded
Expansion isn't a query param but a body param
What server side language are you using?
Ah hmm, looks like I was wrong and Postman sends as query params
so, am i using right?
Not exactly. It'd be something like v1/charges?expand[0]=data.invoice.lines but you're going to run into a different issue
Expansion is only supported four levels deep: https://docs.stripe.com/expand#lists:~:text=Expansions have a maximum depth of four levels.
and you need data.invoice.lines.data.price.product so you'll get an error
Let me take a step back. If your goal is to retrieve Product name information associated with a specific Charge, why are you using the List Charges endpoint instead of retrieving the specific Charge?
because I need this information for my product, I have an analytics that shows metrics like MRR, and I want to see which customers paid in a month, so I need the charges with the customer's name, the amount, due date and the name of the plan
Got it. In that case, you won't be able to do this in one request. That said, I think a better solution to this is to keep some mapping in your database that maps Prices, Products, and Product names. Then, once you get from Charge to Invoice to Prices on that Invoice, you can look up the relevant names