Stripe Payout to a connected user's bank account using laravel

76 Views Asked by At

I'm using stripe connect in my laravel app where merchant account are connected to app's stripe account (Main account) .

Currently i'm using Transfer method from stripe connect to transfer amount from main account to Merchant's stripe account.

    public function payout(Request $request)
    {

        try {
            $data = $request->all();
            $merchant = Merchant::find($data['merchant_id']);

            Transfer::create([ //s 2 s
                  'amount' => 1 * 100,
                  'currency' => 'eur',
                  'destination' => $merchant->asStripeAccount()?->id,
                  'description' => 'Stripe to stripe transfer',
              ]);

            return $this->sendSuccess('success');
        } catch (\Exception $e) {
            \Log::info($e->getMessage());
            return response()->json(['msg' => $e->getMessage()]);
        }

    }

There is a new requirement, that app should send funds from main account to merchant's bank account. Since transfer from Main account -> Merchant stripe -> Merchant bank account takes few days.

        Payout::create([
                'amount' => 100,
                'currency' => 'eur',
                'method' => 'standard',
                'description' => 'payout to merchant',
            ],
            ['stripe_account' => $merchant->asStripeAccount()?->id]
        );

I tried the above method that is given in docs.

With the above code i get the following message as it uses card by default as source_type:

{
    "msg": "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)."
}

When i hit the balance reterive api in stripe i get the following response:

{
    "object": "balance",
    "available": [
        {
            "amount": 6974202,
            "currency": "eur",
            "sourceTypes": {
                "card": 6974202
            }
        }
    ],
    "connectReserved": [
        {
            "amount": 0,
            "currency": "eur"
        }
    ],
    "livemode": false,
    "pending": [
        {
            "amount": -2135283,
            "currency": "eur",
            "sourceTypes": {
                "card": -2135283
            }
        }
    ]
}

Stripe documentation also mentions that:

The Payouts API is only for moving funds from a connected Stripe account’s balance into their external account.

Is it possible to transfer funds from main account to merchant's bank account directly ?

0

There are 0 best solutions below