#milan_api
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1258097738332246149
đ Have more to share? Add details, code, screenshots, videos, etc. below.
Hello! To clarify, are you using Connect with a Transfer involved, or is this all happening just on your own Stripe account?
Connect
With a destination charge
And the ACH return happens on a connected account's transaction
Gotcha. So on your platform there's going to be a Transfer object (tr_) that represents the funds moving from your platform to the connected account. The other half of that is the Charge (py_) representing the funds landing on the Connected account. The tricky bit is that the Transfer exists on your platform, and the Charge exists on the connected account. The good news is that they reference each other.
On the Transfer on your platform, look at the destination_payment property to find the ID of the coresponding Charge on the connected account: https://docs.stripe.com/api/transfers/object#transfer_object-destination_payment
That's good. I have a record in my DB with that py. Now I need to figure out how to walk from the po to the py.
Can you explain exactly what you mean when you say "walk from"?
First we get a charge.failed event for py_3PUxzfLXuND1HOuc0e283bEr
A little while later, we get the payout.created event for po_1PW84jQ70JYPU44CbJLXNl3z
Now we need to figure out which transactions in our side are included in po_1PW84jQ70JYPU44CbJLXNl3z. If it's a normal payment, that's easy for us to do and we have that solved and it works great. However, I can't figure out how to determine which ACH returns (py_3PUxzfLXuND1HOuc0e283bEr in this case) are in that po.
So that's what I mean by walk from the po to the py. We have to traverse the Stripe data to know which ACH returns are in the payout.
Oh. I think I accidentally found it.
Get the balance transactions for the payout > if the balance transaction is a refund > use balanceTransaction.SourceId to get the refund > use the refund.ChargeId to get the charge > use the charge.SourceTransferId to get the transfer. The transfer.SourceTransferId is the py I needed.
Is there a shortcut or is that the recommended approach?
That sounds like the correct approach. You can use expansion to do that in fewer API requests: https://docs.stripe.com/api/expanding_objects
Oh right. I forgot about the expansion thing. I do want to go over this to make sure I'm not breaking anything (and assume we'll look into expansions later to tighten this up)...
We'll use the process above to reconcile ACH returns that are a part of a payout.
For payments - the balance transactions that are charges -> get the charge using the balanceTransaction.SourceId > the charge.PaymentIntentId is what we stored when the payment was initiated (this part seems to work just fine
For refunds (not ACH returns) should we use the same process as we are using for ACH returns to walk through the data?
I think so, yeah, unless I'm misunderstanding. Give it a try and see if it works as you expect, and if it doesn't I can help you figure out a path forward.
Thank you for your help
No problem!