#omkar_transfer-balance
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/1303056302024556545
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
@opal holly can you share a real example request id req_123 associated with the failure so I can have a look?
omkar_transfer-balance
I am first charging a connected account
what does that mean exactly? Like you are using Account Debits?
Let me add some more details:
I have two connected accounts A and B, and corresponding customers ACus and BCus.
Let's say the connected Accounts both have balance 0.
My platform has ~$100 balance.
Now my platform first charges ACus $10, then obtains a chargeID using the Charges API as follows:
params := &stripe.ChargeParams{
Amount: stripe.Int64((int64)(share.Amount * 100)),
Currency: stripe.String(string(stripe.CurrencyUSD)),
Customer: stripe.String(bankAccountToDebit.StripeCustomer),
Source: &stripe.PaymentSourceSourceParams{
Token: stripe.String(bankAccountToDebit.PaymentSource),
},
}
Then I use the transfer API to use the chargeID from the charge above to initiate a transfer from my Platform account -> connected Account B
A Customer and an Account are completely different objects in our API.
So seeing you say ACus is throwing me off ๐
So to be clear you have no Customer object at all?
No I do have customer accounts
I know that accounts and customers are different. For each user on my platform I have one customer and one connected account
So if you see my example above, lets say I have the following setup for 2 users:
User A:
Customer : cus_A
ConnectedAccount: acct_A
User B:
Customer : cus_B
ConnectedAccount: acct_B
Flow of funds is as follows:
Platform charges cus_A to get a charge_ID
Then I create a transfer from platform -> acct_B using chargeID as sourceTransaction to fund the transfer
Let me know if that is more clear
It is clearer yes but it does not match at all the example you gave me
That example create a Charge on acct_A using Account Debits
Sorry I take that back - sorry if it wasnt clear.
I am not creating account Debits, but rather charging a customer
Does that make sense?
is this example clear?
What you say makes sense yes. But this is not what you are doing with the exact example you gave me earlier.
When you say "exact example" are you taking about code?
Can you please tell me what example you are referring to?
this example
Oh does sourceType: "bankAccount" cause a problem?
๐
Okay sorry we are talking a bit past each other and the server is quite busy which doesn't help
Let me take a step back and maybe explain my usecase a little first and maybe you can advise me on the best way I could do that
You opened the thread, gave a concrete example and that example was not charging a Customer, and instead charging an Account with what we call Account Debits: https://docs.stripe.com/connect/account-debits
Was this a weird/bad one-off example or are you misunderstnading what your code is really doing?
yeah it was a bad example and yes I am misunderstanding what my code is doing, which is why I need help
I am building an expense sharing app between friends, groups and family. They can connect their bank accounts to my app and then start splitting costs.
I am creating a customer and a connected account per user.
And I want to be able to do transfers from user A to user B.
I want the funds to stay in their connected account if they dont wish to pay out so that they can transfer to another user on the platform from their connected account if needed
How do I acheive this flow?
Gotcha, so if I ignore what you said early on and focus on this clear explanation then it works fine
And yes your intuition that this is due to ACH is correct. Partly because you are using our Charges API which we deprecated back in 2018
You should be using our PaymentIntents API which works a bit differently (better) and will solve your problem with the "insufficient balance".
Aaah that makes sense
I want to understand first if what I am building is even possible, do you mind if I ask a few clarifying questions first before I use PaymentIntents?
sure
When I charge a customer, the transaction shows as "Pending" but when I use the chargeID as a sourceTransaction it lets me successfully transfer to a connected account.
this is pretty valuable to what I am building since I can fund the transfer from an incoming charge and not my platform balance
Is this possible with PaymentIntents?
yes
Now lets say the transfer is successful to user B's connected Accont. Can user B now use this balance instantly to pay another user? Kind of like a waller?
wallet*
I see something like this :
"Available balance"
"Available soon"
"Available to payout"
Whats the difference?
Building a "wallet" comes with really strict restrictions and compliance rules. This isn't really something I can discuss here and you'll have to talk to our support team about this: https://support.stripe.com/contact
Usually a connected account represents someone or a company offering a service/product and being paid for it and so they receive their balance paid out of Stripe based on the cycle of payments coming in
I see, its not really a wallet, its just the balance in the user's connected account. Let me not call it wallet. Its more like balance.
I mean you can call it something else, but you're holding a balance for them to do something with like paying other users of your platform. That is what is regulated I think. I'm a developer and focus on developers questions so I can't really speak to this
Here is the code behavior I am seeing:
Case 1: When I charge user A, and obtain a chargeID to fund a transfer to a user B it works perfectly if user A's payment method is a bank account.
Case 2: But, when I charge user A's connected account balance, the charge itself is successful but when I use it to fund a transfer the transfer fails.
Case 2: Is where I get the insufficient balance error
Afaik, if the money is being held in a stripe account that belongs to the user's its not the platform holding a balance on their behalf since the platform does not have control of the funds - but you are right that is besides the point and I am trying to solve the issue I am encountering while developing
for the first part: that's expected
Switch your own Stripe account to "manual Payouts" so that you build a balance over time. That way the funds from the account debit will be available for transfer. It's a bit clumsy but it will work
Afaik, if the money is being held in a stripe account that belongs to the user's its not the platform holding a balance on their behalf since the platform does not have control of the funds -
you have control of it since you can do whatever you want with it
My Stripe account is already on manual payouts
But I am seeing that I have two balances when I call the balance API:
{
"object": "balance",
"available": [
{
"amount": 10280,
"currency": "usd",
"source_types": {
"bank_account": 11567,
"card": -1287
}
}
],
"connect_reserved": [
{
"amount": 500,
"currency": "usd"
}
],
I am not sure where the negative card balance is from
That's also what I see it complain in the error from the request I shared before :
You have insufficient funds in your Stripe account for this transfer. Your card balance is too low. You can use the /v1/balance endpoint to view your Stripe balance (for more details, see stripe.com/docs/api#balance).
yeah sorry it;s hard to answer many different vague questions ๐
You can use https://docs.stripe.com/testing#available-balance to bring your card balance back up
Haha, I get it sorry, it really feels good talking to a dev after wading through hours of customer support until I found you guys have Discord! so I have just come out of a cave
I dont mean to bombard you with Qs
all good to ask multiple questions but more sequentially
And part of the problem is that you use that Charges API where historically funds from ACH Debit were separate from other payment methods. That's also not true on the PaymentIntents API
Aah I see, the issue I saw with PaymentIntents was I was not able to fund transfer with a source transaction from the intent because sometimes it would fail with "No charge found" error
I was able to do that very reliably with the Charges API
likely because you did source_transaction: 'pi_123' instead of source_transaction: 'ch_123'
No actually I did the later,
unlikely
I know exactly what you are saying though
there's a lot to learn and grasp with our APIs and so when going way too fast you misunderstand a lot. But if you have a clear and concrete example I'm happy to check
because I did pi_** first
Yeah let me give you a request id
And you are right - I am too eager so might be neglecting something
I won't fault you here.
I always say that most of our API is amazing and simple, as long as someone like me teaches you all the concept before you learn them incorrectly ๐
Error is actually different : Cannot use a source_transaction that has a null balance_transaction (you might want to check py_3QFqugGa8Tfgfn4e1bItAd8T to see if it failed.
ah see the error is completely different from what you said
Sorry I am an idiot, yes its a different error
But this is the request:
{
"amount": "100",
"currency": "usd",
"destination": "acct_1QFqohGhIF719X10",
"source_transaction": "py_3QFqugGa8Tfgfn4e1bItAd8T"
}
as you can see source transaction is py___
And yeah the problem with bank debits such as ACH Debit is that the BalanceTransaction is not created immediately. Some require sending an email and waiting a few days, and so you have to keep track of that and wait for the BalanceTransaction txn_12345 to be made available
it does make the integration a bit harder for sure
Ohhhh
Hmm, but what is interesting is, this "never" was an issue with Charges API
I was using the same payment method/bank when I was comparing
so not sure why it would differ with PaymentIntents
Hello ๐ koopajah has to step out soon but I am catching up
No worries
I will let you go through the thread and we can chat once you are up to speed
I'll summarize since the thread is more than messy ๐
Summary: They are a Connect platform and use SC&T as a flow. They use source_transaction for availability of funds and the Charges API (and tried PI before) and have different issues
- Account Debits are available immediately so you can't use
source_transactionfor those (which they don't yet understand) - They have a negative card balance which causes #1 to fail right now despite being on manual payouts and require the balance to go back up)
- ACH debits have their own source type which requires being understood (though
source_transactionabstracts over that). Also PI will not create the BT instantly so switching to PIs requires waiting for thecharge.updatedEvent which needs to be explained
very well summarized!
Yes definitely a good summary. Can you tell me more about what you are still trying to understand with points 1 and 3? Happy to help expound on the questions mentioned there
Our core issue right now is we are unable to charge balances in connected accounts to then use that charge as a source for transfer to a different connected account.
However, we are able to charge external bank accounts for a customer and then use those as a source transaction for transfers.
Actually, the charge itself on the connected account is successful:
Charge: req_BJSkEQzwSLoXrM (succeeds)
Transfer: req_MmUpp2krtNrjzu (fails)
Oh hold on, ....... I think i see where my misunderstanding might be.....
We are charging the connected account's external bank account and not the balance in the connected account?
Maybe that is what @distant dust was referring to as ACH Debit?
ACH Debit is a payment method for charging customers
https://docs.stripe.com/payments/ach-direct-debit
Connect account debits should try to charge the balance first as far as I am aware.
Oh I see, connect account debits is where we are having issues right now.
So from what you just mentioned, it is possible for a platform to charge a connected account's balance even if its "available soon" ?
Yes, I am still trying to understand the exact error that you are running in to myself right now.
Okay gotcha
So from what you just mentioned, it is possible for a platform to charge a connected account's balance even if its "available soon" ?
Unfortunately not, you can only transfer funds that are available. Pending funds that have not landed in Stripe yet can't be transferred between accounts.
Ah okay I think I get it
One sec double checking myself on some of this
Sure take your time
Okay, so the source_transaction parameter is intended to help with situations where the balance from some charge is still pending and has not landed on Stripe yet. So with a card or ACH payment, when they succeed the balance will still be pending for a couple of days. While the balance is still pending, you can create a transfer using source_transaction which tells Stripe to send the balance to another account as soon as they land. After the funds land, you source_transaction field and the only checks that 1) the transfer amount isn't higher than the charge amount and 2) your platform account has enough available balance to cover the transfer.
With account debits, the balance is already available. There is no time when the funds are pending, they are already available on one account and debiting them instantly transfers them to the other account. So your error is happening because the funds have already landed, but your platform account still doesn't have enough available balance to cover the transfer that you are trying to make. Once your platform has enough balance available you will be able to make that transfer.
I checked the balance though we should have enough
Which is why I am very confused
{
"object": "balance",
"available": [
{
"amount": 10280,
"currency": "usd",
"source_types": {
"bank_account": 11567,
"card": -1287
}
}
],
"connect_reserved": [
{
"amount": 500,
"currency": "usd"
}
],
Here is a call to our balance endpoint
Also when you say "funds have already landed":
Are you referring to :
(a) funds have landed in connected account after the transfer
(b) funds have landed in Platform's account after the connected account debit
In the specific call where you error out, it looks like you don't specify source_type so we default to card which is negative in that API response https://docs.stripe.com/api/transfers/create#create_transfer-source_type
Do you mind if I try again with the above?
This looks correct to you right?
On a side note, would you know how we ended up with a negative card balance? We never added a card to our Stripe account. I want to pay that if that is pending somehow .....
I can try to take a look in a moment. I have to hop to some other threads really quick and am trying to wrap my head around your problems holistically. I know we still need to touch on the charge.updated part of this flow for payment intents as well.
I think that that call would successfully create a transfer, but let's hold off on that for a moment. I think koopajah may have suggested not doing that until your card balance specifically was high enough but am still figuring out if that is the suggestion and why if so.
Okay sounds good to me
Can I just summarize my understanding with you for our business needs though in the meantime?
Here is what I understand now-
- User A pays platform (us) using ACH Debit - "Charge_xyz"
- Platform transfers to User B's connected account using source transaction as "Charge_xyz"
--- All good still step 2-----
Now,
- Platform can charge User B's connected account balance (connected account debit) - we were assuming that since the transfer is successful funds would be available in User B's connected account to be charged.
But looks like there will be a delay here correct?
Since the connected account balance is not yet up for User B's connected account the charge will then happen on their external accounts?
Yeah the balance may not be available yet. Assuming step 2 happens right after step 1 succeeds, the balance from that transfer will still be pending. So when you create the transfer in step 2, Stripe doesn't immediately move any balance, we note that once the balance actually become available we should transfer the balance to account B.
So account B won't have any balance until Stripe actually receives money from the bank from the charge from step 1
That makes a lot of sense thanks
So we need to listen to a "balance_available" webhook too before initiating any payouts, otherwise they might fail
For payment intents you will want to listen to charge.updated, that is the event where the balance transaction is created for ACH debit payments with payment intents. And as koopajah mentioned we don't separate balances by card and bank account with PIs, so that does simplify that part of this flow for you.
Looks like ACH Debit takes a long time to process. I have some from Nov 30 that are still pending.....sigh
understood!
Is there any way to speed up the ACH flow of funds?
Indeed there is though I am not familiar with the signup process. More on that here https://support.stripe.com/questions/two-day-settlement-for-ach-direct-debit
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
@opal holly apologies for the delay, the server got busy. Looking in to why card balance went negative and whether it is fine to specify bank_account as the source of your transfer when trying again.
sure no worries
It looks like the card balance being negative is mostly a matter of connect reserves, it looks like there isn't one thing that made it negative but I see a lot of times where $0.98 went in to that balance and then later $1 was taken out for connect reserves. So it has slowly been ticking down in increments of a couple cents. I hate to pass you along one more time but I think that talking to our support team would be the best way to figure out exactly what is happening there
And as far as I can tell specifying that different source type should be fine for this one transfer. As mentioned before, when using payment intents, these balances won't be differentiated at all beyond what is available and pending. So using different available funds should work here