#milan_payout-reconcilliation-connect-refunds

1 messages ยท Page 1 of 1 (latest)

marsh treeBOT
#

๐Ÿ‘‹ 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.

meager karma
#

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?

reef raft
#

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?

meager karma
#

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

reef raft
#

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.

meager karma
reef raft
#

Hmm...but when I get balance transactions in that payout, I get a balance transaction Id of txn_1QCidHPp8NQLHhg69UDfkkgz

meager karma
#

I'm looking at that Balance Transaction and I see a different linked payment refund

#

pyr_1QCidHPp8NQLHhg6rXqLtt5Q

reef raft
#

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.

meager karma
#

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.

reef raft
#

Sorry, let me make sure I understand. You don't see pyr_1QCidHLXuND1HOuchmYqDatQ tied to a payout?

meager karma
#

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

reef raft
#

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)?

meager karma
#

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

reef raft
#

Ok. Can I ask a more general question then?

meager karma
#

Sure

reef raft
#

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.

meager karma
#

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

reef raft
#

I have to step away for < 5 minutes.

#

I'll be right back. Sorry.

meager karma
reef raft
#

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.

meager karma
#

You can trigger report generation and download the data via the API

reef raft
#

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.

meager karma
#

Cool. I wanted to make sure it wasn't something you weren't aware of.

reef raft
#

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.

meager karma
#

Happy to be a rubber ๐Ÿฆ† any time ๐Ÿ™‚

reef raft
#

One more question....

#

Sorry.

#

What does transfer.Reversed signal?

meager karma
#

Can you point to a specific object so I have more context?

reef raft
#

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.

meager karma
reef raft
#

There is a Reversed property on the transfer object.

meager karma
#

Okay so not the refund at all, the transfer

reef raft
#

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.

meager karma
#

No worries! Answering question is why we're here ๐Ÿ™‚