#Edem-payouts

1 messages · Page 1 of 1 (latest)

mortal lance
#

Hi there!

#

A manual payout allows you to send an arbitrary amount of your current balance to your bank, so this amount isn’t tied to the specific charges included in that payout.

naive jetty
#

thank you for your reply

From docs:
List all balance transactions

Returns a list of transactions that have contributed to the Stripe account balance (e.g., charges, transfers, and so forth). The transactions are returned in sorted order, with the most recent transactions appearing first

Appearing first means "created" field, so... transactions sorted by created time in UTC?

mortal lance
#

Yes, the latest balance transaction will appear at the top.

naive jetty
#

Can I say that when I go through the balance transactions in reverse order, if I find a payout, then the previous transactions before this payout relate to this payout?

mortal lance
#

I don't think so. Like if you have 10 balance transactions of $1 each, and then do a manual payout for $5, then not all balance transactions belong to that payout.

naive jetty
#

if we are aware that there is no manual payout?

mortal lance
naive jetty
#

You're right. Anyway, I'm sorry...Let me explain. We don't know anything about payouts (we only know that they are automatic), and we have time constraints on code execution, so we want to iterate through the list of balance transactions (using the range date and reverse sorting) and group these transactions by payout when we receive it at a certain iteration step, knowing that the previous transactions relate to this payout

mortal lance
naive jetty
#

we have to make a lot of requests for different stripe accounts, as a minimum

#

it will be good for us if we can iterate through the list of balance transactions using only range date

crude fjord
#

i.e. pass created.gte & created.lte to create your date range

naive jetty
#

Yes, I meant it when said "date range"

crude fjord
#

Does that help?

naive jetty
#

I am trying to use the above algorithm: get the balance of transactions sorted by create date in a certain date range, then iterate over them and check if the transaction is a payment, then I get previous transactions created before this one that are not a payment, thus grouping them by payments

But it is no correct, if I use https://stripe.com/docs/api/balance_transactions/list to get all balance transaction for a given payout. 😦

crude fjord
#

What is not correct?

#

Is the request failing? The data not what you're expecting?

#

Can you share the req_xxx ID?

#

What is it that you're actually trying to do?

naive jetty
#

I get unexptected data
Sorry, I have no req_xxx Id

crude fjord
#

Or can you share the code you're using

naive jetty
#

I will share the code)

naive jetty
#

var balanceTransactionListOptions = new BalanceTransactionListOptions()
{
Created = new DateRangeOptions { GreaterThanOrEqual = from, LessThanOrEqual = to },
Expand = new List<string>
{
"data.source.source_transfer",
"data.source.transfer_reversal.transfer",
"data.source.source_transfer_reversal.transfer",
"data.source.metadata"
},

        };

        var requestOptions = CreateRequestOptions(stripeData);
        var balanceTransactionsEnum = _stripeBalanceTransactionService
            .ListAutoPagingAsync(balanceTransactionListOptions, requestOptions, cancellationToken)
            .GetAsyncEnumerator(cancellationToken);


        var balanceTransactions = new List<BalanceTransaction>();

        // iterate through all balance transactions
        while (await balanceTransactionsEnum.MoveNextAsync().ConfigureAwait(false))
        {
            balanceTransactions.Add(balanceTransactionsEnum.Current);
        }

        var payoutTransactions = new Dictionary<Payout, List<BalanceTransaction>>();

        balanceTransactions = balanceTransactions
            .OrderBy(x => x.Created)
            .ToList();
        
        var lastPos = 0;

        for (int i = 0; i < balanceTransactions.Count; i++)
        {
            if (balanceTransactions[i].Source is Payout payout)
            {
                payoutTransactions.Add(payout, new List<BalanceTransaction>());
                for (int j = lastPos; j < i - 1; j++)
                {
                    payoutTransactions[payout].Add(balanceTransactions[j]);
                }

                lastPos = i + 1;
            }
        }
#

maybe screenshot is better

azure quarry
#

cool

#

so you said

I get unexptected data
what's unexpected exactly?

#

the code seems fine and very sensible overall but I'm not really following what you're asking, you just said "But it is no correct" and you get something unexpected so it's hard to understand.

naive jetty
#

I checked this algorithm.
Using payouts' ids and make requests to get list of balance_transactions by payout_id, saw that grouped transactions by payout (in screenshot) have the differend data

#

I hope I was able to convey the idea)

azure quarry
#

not really I'm afraid.

#

what screenshot? I just see a screenshot of code, not data

naive jetty
#

grouped_balance_Transactions file shows what transactions belong to payout

what_expected file is expected result, when I can check what real transactions belong to payout

azure quarry
#

sorry, this is beyond what we can help with here

naive jetty
#

Oh,... ok! Thank you for your time!

#

One question

#

Maybe it is confident
Can you describe some steps of what how do you define which balance_transactions belong to a payout'id ?

azure quarry
#

the ones whose funds were paid out in that pay out

naive jetty
#

in our dashboard I can generate payout excel for the whole period, but how it works....

azure quarry
#

don't really follow you sorry

#

I'd suggest writing in with a detailed email describing exactly what the problem is and what you see versus what you want to see instead