#milan_payout-reconcilliation-connect-refunds
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/1313185240638029855
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
I've tried walking the data via the API but I can't figure this out.
What do you mean by this?
Literally, half the time we are able to reconcile the refunds into payouts, but the other half we aren't able to.
Also what do you mean by this?
When a payout event is triggered, we first get all of the balance transactions that are either "charge" or "refund". If it's a "refund" we use the RefundService with the balanceTransaction.SourceId to get the refund. Then we use the refund.ChargeId to get the charge. Then charge.SourceTransferId to get the transfer.
Let me try asking this way...
Take account acct_1Q2lvVPp8NQLHhg6 and payout po_1QCw5jPp8NQLHhg68mJqfZD1. We have a refund record of pyr_1QCidHLXuND1HOuchmYqDatQ in our database. Somewhere in that payout, there is a reference to pyr_1QCidHLXuND1HOuchmYqDatQ. How do we walk through the payout data to get to that pyr record?
Does that make sense?
What data are you trying to get?
This pyr_XXX is linked to a balance transaction ( txn_1QCidILXuND1HOucq7XG7cVw )
That captures the funds being removed from your Stripe account balance and has a type of payment_refund
When a refund is created from our system, we make an API call to Stripe and we record the refund Id Stripe returns to us. That is the pyr I posted above. So then a payout.created event fires and I need to know which payments and refunds are in that payout. We are good on payments, but I'm having issues knowing which refunds are in the payout.
And you are already filtering Balance Transactions by Payout ID and reviewing all those?
https://docs.stripe.com/api/balance_transactions/list
Hmm...but when I get balance transactions in that payout, I get a balance transaction Id of txn_1QCidHPp8NQLHhg69UDfkkgz
I'm looking at that Balance Transaction and I see a different linked payment refund
pyr_1QCidHPp8NQLHhg6rXqLtt5Q
Right. I'm seeing the same when I walk through that payout via API. However, the Stripe API returned an Id of pyr_1QCidHLXuND1HOuchmYqDatQ when we initiated the refund. And this is what's causing the issue. We can't seem to walk through the balance transactions > refund > charge > transfer > transferReversal to get to the Id we have on our side.
When you look up pyr_1QCidHLXuND1HOuchmYqDatQ what do you see as the linked payout Id?
My comment earlier about this working "half the time" is that the way we are walking the data from payout Id to the refund Id works great for reconciliation, but only half the time. The other half of the time we are in this scenario where the refund Id we have on our side isn't the refund Id that is found in the payout. I can give you an example of this.
This payment isn't directly tied to a payout, only the Balance Transactions are. And unfortuntaley it isn't something I can see on my end either.
Sorry, let me make sure I understand. You don't see pyr_1QCidHLXuND1HOuchmYqDatQ tied to a payout?
I am saying our internal data views do not show direct links between refund payments and payouts. I am not implying this transaction is not associated with a payout
Ok. Do you have a link to the chart (I seem to misplaced it) where you have the data diagram of the Stripe entities and how they are related (balance transfer, charge, transfer, refund, etc)?
I can find it but these details aren't the kind of support this server is designed for and we (I) don't have the tooling to inspect this. I recommend you reach out to our Support team here: https://support.stripe.com/contact
Ok. Can I ask a more general question then?
Sure
I want to understand that I'm doing this right.
We issue a refund and record the Id that is returned.
A payout.created event is triggered and we get all of the balanceTransactions in the payout.
If it's a refund, we use the balanceTransaction.SourceId to get the refund.
We use the refund.ChargeId to get the charge.
We use the charge.SourceTransferId to get the transfer.
If the transfer.Reversed = true, we use the charge.SourceTransferId to ge the transferReversal.
The transferReversal.SourceRefundId should match the refundId we originally received when we initiated the refund.
Hmmm... So Connect charges are involved, right?
I think that causes additional payments to be created to move the funds back and forth but let me see if I can get all the examples I need while focusing on pyr_1QCidHLXuND1HOuchmYqDatQ. However, as I said, I won't be able to see which Payout ID is associated with the Balance Transactions because the admin views I have access to don't capture that.
But let's see what we can figure out
Okay so we start with
- Refund creation request: https://dashboard.stripe.com/logs/req_ccfWseL3mtg7qf
- Generates
pyr_1QCidHLXuND1HOuchmYqDatQand BTtxn_1QCidILXuND1HOucq7XG7cVw - But you don't see
txn_1QCidILXuND1HOucq7XG7cVwassociated with a specific payout?
I'm back. Thanks for the patience.
I think I got this working. I see txn_1QCidHPp8NQLHhg69UDfkkgz with a source of pyr_1QCidHPp8NQLHhg6rXqLtt5Q which has a chargeId of py_1Q9ufvPp8NQLHhg6Z2SfePv8. That charge has a source transfer Id of tr_3Q94rfLXuND1HOuc13loaq7C
If I use that sourceTransferId to look up a transferReversal, that gives me a transferReversal with a SourceRefundId of pyr_1QCidHLXuND1HOuchmYqDatQ
Voila!
But I don't know if that's the right way to do it from an implementation standpoint. It seems like a lot of hoops, but I'm good with it if you are.
I think that still makes sense to me. I realize it's a lot of hoops but that is how Connect funds flows are working internally.
I think your approach is correct but we also have reporting tools available for payout reconciliation that might make this easier. It sounds like you would be able to make use of some of the itemized reports like this one: https://docs.stripe.com/reports/payout-reconciliation#schema-payout-reconciliation-itemized-5
You can trigger report generation and download the data via the API
We originally look at using the reports for reconciliation, but ended up going with the API. I can't remember exactly why. We do use your beta reports to get itemized transaction costs.
Cool. I wanted to make sure it wasn't something you weren't aware of.
Ok. We'll give this a run and see if this works. It seems to work across the test cases I've set up (they are all passing now). Thank you for helping me think this through.
Have a great day.
Happy to be a rubber ๐ฆ any time ๐
Can you point to a specific object so I have more context?
It's in the context of looking a refund. Same one actually.
From the charge.SourceTransferId, I can get a transfer. And that transfer.Reversed == true. But for some refunds, the flag is set to false. I just don't know what that signals from one refund to another.
Or if I just shouldn't even look at that flag when reconciling refunds.
I'm not sure which property you are looking at. https://docs.stripe.com/api/refunds
There is a Reversed property on the transfer object.
Okay so not the refund at all, the transfer
That is explained here: https://docs.stripe.com/api/transfers/object#transfer_object-reversed
Ah ok. I read the docs. I think I'm good on this. Thank you. Enough questions from me today. ๐
I'll leave you alone now. I appreciate the help.
No worries! Answering question is why we're here ๐