stripe transfer method in django

35 views Asked by At

i am working on project where i want to transfer amount to multiple stripe customers i have used the stripe transfer method but i am getting the following error

Error: Request req_FlLAHrjOxkd4IO: You have insufficient available funds in your Stripe account. Try adding funds directly to your available balance by creating Charges using the 4000000000000077 test card. See: https://stripe.com/docs/testing#available-balance

here is my code

            charge = stripe.Charge.create(
                amount=5000,
                currency="usd",
                source='tok_visa',
                description="Adding funds to test account"
            )
            charge_id = charge.id

            # Assuming you have defined 'total_charges', 'user.id', 'seller_amount', and 'referral_amount' earlier in your code

            session = stripe.PaymentIntent.create(
                amount=total_charges,
                currency="usd",
                transfer_group=f"ORDER10_{user.id}",
            )

            stripe.Transfer.create(
                amount=seller_amount,
                currency='usd',
                destination='acct_1OrzGLI3hFSHp0X5',
                transfer_group=f"ORDER10_{user.id}",
            )

            stripe.Transfer.create(
                amount=referral_amount,
                currency='usd',
                destination="acct_1OrzPRI5g3KKKWKv",
                transfer_group=f"ORDER10_{user.id}",
            )
1

There are 1 answers

0
Lucky2501 On

Not sure why you're creating a Charge, then a Payment Intent. The Payment Intent would generate the Charge when you confirm it - but that's another issue.

You don't have enough funds because the transfer you're creating needs the funds available to work - which takes days after the charge.
To bypass this, pass this argument in your transfer.create:
source_transaction=charge_id