#dieselwurks_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/1283891193633046608
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello! If you want to start from the Payment Intent ID, you would need to use this endpoint to get the associated Checkout Session: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-payment_intent
To get the Product and Price information, you need to expand the line_items property when you make that request: https://docs.stripe.com/api/checkout/sessions/object#checkout_session_object-line_items
More info on expansion here: https://docs.stripe.com/api/expanding_objects
data.line_items ?
If you have a Checkout Session ID, you can retrieve the Checkout Session directly while expanding line_items with this endpoint: https://docs.stripe.com/api/checkout/sessions/retrieve
It would be data.line_items for the list call, yep.
In the cli, how do i specify more than one expansion?
this did not work" :stripe payment_intents list --limit=100 --expand=data.latest_charge,data.line_items
nvm, it seems you call --expand twice
Argh. it's not the intent, it's the session that has the line items.
Yes.
Oh, yeah, you're trying to list Payment Intents with that command.
The docs I linked to are for listing Checkout Sessions by Payment Intent ID.
ok, thanks I think I have it now.
No wait.
Am I doing this right?
I take money.
Sometimes it's refunded. I store payment_intents in my DB, along with the checkout session id.
I need to verify that a list of people in my classes have paid. I throw out those who were refunded.
Now I need to sum the prices that were paid.
SO it seems start with intent, go to checkout session, get price. Is this the best flow?
I actually have both CSID and PI .
Well, it sounds like you also have the Checkout Session IDs. If you have those, I recommend starting there and fetching the Checkout Sessions with the other information you need expanded.
Try retrieveing the Checkout Sessions with both line_items and payment_intent.latest_charge expanded. That will include the line items, the full Payment Intent, and the full latest Charge objects.
But the sessions wouldn't know that the money was refunded. So I need both.
Ah. OK.
Actually, you probably want to expand payment_intent.latest_charge.refunds so you get all the Refund objects for the Charge as well.
What's the issue?
Argh it's maddening that you can't search the text of a stripe webpage.
This property cannot be expanded (data.latest_charge).
ha! didn't notice that checkbox.
Can you share the request ID showing that error so I can take a look? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
I'm trying to do what you said:
$sessions = $this->stripe->checkout->sessions->all(['limit' => '100', 'expand' => ['data.latest_charge','data.line_items','data.payment_intent.latest_charge.refunds']]);
I can't quite get the keys right.
For a session.
There's no latest_charge property on Checkout Sessions.
So remove that first one from the array.
This is what I'm trying to do.
Right.
But you can't expand a property that doesn't exist.
Checkout Sessions do not have a latest_charge property, but Payment Intents do. Checkout Sessions do have a payment_intent property, which points to the associated Payment Intent. That's why you need to expand payment_intent.latest_charge when fetching Checkout Sessions.
You're expanding the payment_intent property on the Checkout Sessions, which do exist, and then on that Payment Intent you're expanding you're expanding the latest_charge property there.
Does that make sense?
Happy to explain another way if it would help!
this worked:
'data.payment_intent.latest_charge','data.payment_intent.latest_charge.refunds','data.line_items'
Ah! ok.
You only need 'data.payment_intent.latest_charge.refunds','data.line_items'
OK, This should be good. It's slow though. I understand why but I think I should cli this and freeze/thaw the json or I'll get bored.
Thank you!
It'll be a lot faster if you reduce the limit.
Like if you only grab 5 or 10, for example.
In the end I need them all. Oh hey, can I exclude expired sessions?
If you need more than 20 or so you should use auto-pagination and keep your limit set to 20 or less: https://docs.stripe.com/api/pagination/auto
When using auto-pagination the limit applies to each individual request, but multiple requests will be made until you have all of them.
If I need to get, say, 300 you're saing it would be faster to get 15x20 rather than 3x100?
You can get expired Checkout Sessions, yep: https://docs.stripe.com/api/checkout/sessions/list#list_checkout_sessions-status
It will probably be faster, yeah. You should test both approaches if performance matters. It can vary based on factors unique to your account, integration, etc.
The payment_intent in the session is null.
Can you give me the Checkout Session ID so I can take a look?
Argh this was an early iteration of the software and it's intentionally null. My fault.
Ah. ๐
Choosing a random one elsewhere rather than array_pop
It will be null if the Checkout Session hasn't been paid yet.
It might also be null if the Checkout Session is for a subscription instead of a one-off payment.
Yeah, it's there. Thanks again.