#sinotz-charge
1 messages ยท Page 1 of 1 (latest)
hello! so Charges still exist in the API, PaymentIntents create Charges under the hood still but mostly you don't interact with the Charge object yourself
the PaymentIntent is the abstraction you usually need to interact with
with that said, what was your real question?
ok well I am looking to make this sigma query from years ago into a python only script to get new sales https://dpaste.org/LgXN
yeah in that case it would be fine to list Charges, a Charge still represents "a payment".
ok cool thanks. I have a lot of queries I want to translate into python
so how would i get payment intents/charges with a status of succeeded?
๐ I'm taking over since @wild verge has to head out soon
k
You just want to be able to retrieve all the payment intents/charges that are succeeded through the API, right?
yup
So unfortunately you can't pass in status to the List Payment Intents endpoint, so your best option would just be retrieve all the Payment Intents (https://stripe.com/docs/api/payment_intents/list) and then filter based on status yourself.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok should I use auto_paging_iter() right off the bat in the list?
stripe.PaymentIntent.list().auto_paging_iter() ?
Yup, if you want to use auto-pagination you would use that right from the start
ok cool
<generator object ListObject.auto_paging_iter at 0x7f53ed2feb30
if i loop through it, it is fine though
it has been a while since i used stripe code lol
so if i wanted to do in between date x and date y how would i do that?
If you wanted to limit it to between a set of dates you'd set created https://stripe.com/docs/api/payment_intents/list#list_payment_intents-created
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Yeah ending_before is if you want to do the pagination yourself
This does not seem to work stripe.PaymentIntent.list(created.gte="1638815734",created.lte="1638815734")
What about it isn't working?
it thinks i am assigning the epoch numbers to the created variable
Sorry let me be specific - what is the error message you're seeing?
SyntaxError: expression cannot contain assignment, perhaps you meant "=="?
== does not work either
This is with python right?
yes
api says dictionary maybe that is why
{created.gte:"1638815734"},{created.lte="1638815734"}
Yeah it has to be a dictionary, so you'd want something like
created={
"lte": "1638815734",
"gte": "1638815734",
},
cool that worked ty
hmm i see something strange in my dashboard. Any idea why a successful daily subscription sometimes charges twice on the same day?
and at different times too
Do you have a subscription ID I can take a look at?
Gotcha - so what specifically on the customer page is confusing you?
i see 2 december 4 charges and 2 december 1 charges
i didn't make any changes to the account either i just let the subscription ride
perhaps i found a bug or this is just the way stripe handles it where it chooses the best time to add it?
I don't think it's a bug per se - it's just weirdness with timezones. The Payments list on the customer is based on when the Payment Intent is created, while the list on the Subscription page is when the Invoice was created.
oh ok ty
makes me feel better now
because that may mean i have to change this python code to the right timezone
correct me if i am wrong but EST is 4 hours behind UTC?
or GMT?
how would I do that in python created epoch time into EST
Actually, time zone may have been the wrong phrase to use there ๐คฆโโ๏ธ
ok well it would still be nice to get the right amount for my timezone. But otherwise what did you mean instead?
GIve me one minute to type this out
sure
Okay so there's a few things at play here - as I said earlier, the subs page is listed out by Invoice creation (which has the daily cadence you're expecting). The Customer page lists by Payment Intent creation which can vary, since it's happening automatically on our end approximately an hour after the invoice is created. The issue here is that sometimes the Payment Intent creation gets slightly delayed by an additional hour or two.
ok makes sense
Because your Invoices are regularly created later in the day (around 9PM for that timezone), the Payment Intent is usually created around 10PM the same day, but if it's delayed it can sometimes just barely pass into the next day
ok so i am wondering for bookkeeping purposes which object should i track for successful payments between which dates?
successful invoices not payment intents?
Well what specifically are you using these bookkeeping records for? If you want to know what billing period were successfully paid for then you'd want the Invoice since it has details on the billing period
basically i want to get a bunch of metrics - monthly/yearly total successful payment amounts, total cancels, total refunds, total disputes, etc.
but if i want just all brand new sales/charges i would use charges/payment intents?
If you're purely looking at payment behavior then yes, I'd just look at the charges/payment intents
ok but to be safe use the invoice object though?
i might be able to get new sales with that too by doing first time invoice paid for the customer
Really what matters here is the kind of metrics you're looking to display - you know best what kind of information you need, and either will work for signalling payment success so choose whichever works best for you
I need to head out by @ashen axle can help with any follow-up questions!