#sebastian_api

1 messages ¡ Page 1 of 1 (latest)

sharp galleonBOT
#

👋 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/1293194276200644630

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

pearl fiber
#

hi there!

#

what exactly do you want to track? the status of a payout?

dusky pecan
#

The status of a payout but also of the transfer leading to the payout. So my company will have all the money on my Stripe account. I will then conduct transfer actions programmatically to each vendor's connect account. Once the money is in their account, I would like to monitor the payout. If the process to do this requires manual payouts, then Im game.

pearl fiber
#

you could also check the BalanceTransaction of the Transfer to get more information

dusky pecan
#

So if I were to listen to the balance.available event I would get a payload similar to this:

pearl fiber
#

you would get a Balance object, yes

dusky pecan
#

If I inspect the source_types, I get this:

sharp galleonBOT
dusky pecan
#

Is there some unique identifier I can use from the availibility of a balance so I can always go back and reference it.

#

Because the idea is to have this action saved on my DB to keep track on what part of the journey the payment is on

velvet creek
#

Hey there, just stepping in as my colleague needs to head out

dusky pecan
#

youre good bud

velvet creek
#

There's no unique identifier for the balance available events, no. However, if you're making manual transfers from your available platform balance there's really no need ot track anything, that happens immediately.

#

the availability i only delayed where the source funds are still pending (not available)

dusky pecan
#

Ok so my final thing here is that the balance object when it shows all available balances, it doesnt show a unique ID about it.

#

Just the presence of the amount and how it was paid really.

#

Not even a timestamp to set it apart from other txs

velvet creek
#

the timestamp is the event timestamp

dusky pecan
#

yes yourre right

velvet creek
#

but taking a step back, you're trying to follow these transfers/payments through payout lifecycle, right?

dusky pecan
#

Correct. If you could just steer me on the best approach here, I would appreciate.

#

Just basically giving the user 3 steps

#

Funds awaiting payout, payout in process, and paid

velvet creek
#

You're going to want ot focus on the payouts, listening for payout creation each day

#

Using BalanceTransactions, you list by payout and use expansion to load reference objects to get back to the transfer

#
curl https://api.stripe.com/v1/balance_transactions \
  -u sk_test_123: \
  -d payout=po_456 \
  -d type=payment \
  -d "expand[]"="data.source.source_transfer" \
  -H "Stripe-Account: acct_789" \
  -G
#

Then you can record those transfer<>payout mappings in your own system

#

and focus on the payout state

dusky pecan
#

So I can query per stripe account here.

#

I dont understand what po_456 means

velvet creek
#

the payout object, after its created

#

You'd listen for payout.created after some un-reconciled transfers and work backwards to see what that payout includes

dusky pecan
#

Not going to lie. I think I am batting above my average here.

Basically Im lost. I do the transfers. What command do I use to query the list of balances per account to see what money is sitting there?

Bc I dont see how I can use the cmd above if I dont know anything about the payout yet. I still have to query the balance.

#

Theres nothing in the SDK that with a few calls I can retrieve it?

#

I think Im better just using the webhook

#

Do the transfer --> if successful, register as payout pending creation.

Then just let the webhooks do the rest. That to me seems the most straightforward.

#

And least amount of code needed to do checks.

#

But I wonder if its out of the question, to then do the transfer, and once the funds are available, manually commence the payout so I can store that payout ID starting with "po_"

velvet creek
#

You can look at balance transactions before the payout creation too, but its getting really nitty gritty at that point

dusky pecan
#

I wonder if I can put some metadata into the transfer object to give it a trace-ability with the payouts and do the same with the payouts.

#

Like a personalized ID or hash in metadata

velvet creek
#

None of that will propagate to the received payments/balance/payouts on the connected account

#

After you do the backtracing, you could add metadata to the transfers to mark the payout they landed in

dusky pecan
#

So what do you recommend as the path with least friction? Bc I want to do avoid a cron job if the webhook puts the burden on Stripe to just notify my server when a change has happened.

velvet creek
#

What i described above: listen for payout creation events, then use the method of balance transactions + expansion to reconcile with your transfers

dusky pecan
#

Reconcile with your transfers just means itll show which transfer ID the money came from?

velvet creek
#

after you create transfers and before you find it associated with the payout its some waiting state like "waiting for next automatic payout" etc

velvet creek
dusky pecan
#

Honestly, I think the easiest way for me to handle this is to do the transfer, put a lock on the account id that way no more transfers can happen until I initiate the payout. Once the payout has been initiated, then I lift the lock.

#

Because I assume available balances are just money that is sitting there and havent been subjected to a payout yet.

#

Lmk if this approach makes sense. Its quick and brute in nature but it lets me initiate the payout so I can get the payout id that I then can save to my DB, and then let the webhook monitor for changes when they do come.

#

The only fallacy is assuming the time for the transfer to settle and the time for the payout to start are not nearly immediate causing the lock to hang for longer than usual

velvet creek
#

You can do that if that's your preferred approach and work for your business model, sure

#

But then you can only have one transfer/payout in flight at a time, be aware

dusky pecan
#

Right but the "flight time" would only be the duration of time for the transfer to be successful and for the payout to be initiated which I assume is seconds.

velvet creek
#

That's not necessarily correct, though if you're using manual payouts i suppose it could be true

#

Automatic payouts can involve waiting until that happens some time later in the day (or whatever your schedule is)

dusky pecan
#

Not automatic.

#

My understanding is thats daily or it depends on nationality of connect account.

#

But for manual payouts.

#

I would do the transfer asynchronously, and once its successful, do the manual payout.

#

But question. Since transfer is synchronous, once it returns successful, then that means the funds are in the connect account

velvet creek
#

Sure, that's fine then

velvet creek
dusky pecan
#

Awesome. Then I am going to do that approach. My final question is that the po_ id given when I manually start a payout, will be the same for when the webhook catches it on paid, fail, updated etc.

velvet creek
#

yep!

dusky pecan
#

Nice thanks for helping me brainstorm. My team tech team is still pretty nascent and isnt as advanced as a stripe engineer so a more dumbed down solution was what would work for us. Thanks bud.

velvet creek
#

NP happy to help

dusky pecan
#

Darn, available on a balance means money not subject to payout right?

#

Just so we know how much to payout

velvet creek
#

With manual payouts, yes that should be the case

#

with automatic payouts its a bit more complicated, because "available" funds get earmarked for future payouts

dusky pecan
#

So I should disable automatic payouts on my dashboard so no earmarking happens.

#

then I can query the funds available on the connect account and thats how I know how much to payout .

velvet creek
#

Are you talking about the transfers part for sending funds?

dusky pecan
#

So I would transfer from the company's account to the connect account.

#

there would ofc be fees so the transfer amount wont be the same as the landed amount

velvet creek
#

Because your platform payout settings are separate fromthe conencted accounts. if you're going to manage manual payouts you need to set that on the connected accounts.

dusky pecan
#

I cant just set a default on some settings somewhere? So everytime someone creates a connect account, I have to manually set it to manual payouts?

#

Like is there a way around this.

velvet creek
#

So you can set that for all connected accounts when you create them

dusky pecan
#

I assume

#

set it to manual and you are done.

velvet creek
#

yep

sharp galleonBOT