0
$currency = 'cad';
    //$customerId = $request->customerId;
    $intent = \Stripe\PaymentIntent::create([
        'amount' => ($finalAmount *100),
        'currency' => $currency,
        'customer' => $customerId,
        'description' => $description
    ]);

I Have an app where the seller post products and buyer can buy , During checkout I am charging from buyer (Customers) and after the order status is changed to completed I want to payout to seller but deduct 5% commission from the order amount. This is what I am doing but it send the total amount without the deduction of 5% commission on live Mode, ON the test mode the deduction is okay.

    if($commission->commission_type == 'percentage'){
       $amount = $totalAmount - (($commission->commission_amount/100)*$totalAmount);
      }
$finalAmount = (round( $amount,2));
  //Paying to the seller
   $transfer = \Stripe\Transfer::create([
   "amount" => ($finalAmount*100),
    "currency" => "cad",
    "destination" => $seller_account,
   ]);
Nasir
  • 41
  • 6
  • From the code itself, the transfer amount is after deducting the commission. If it works in test mode, then live mode should work as well. Stripe transfer the amount based on the number set in the request. I'd recommend checking what's the amount you set in the live mode request and ensure that you set the `commission_amount` correctly in live mode as well. – yuting Jun 12 '23 at 00:07
  • Thanks @yuting , I will try it again , Sorry I am not an expert but can you confirm that this flow is okay to transfer amount to seller connect account ? – Nasir Jun 12 '23 at 04:28
  • From the code perspective, yours look fine. – yuting Jun 19 '23 at 00:19
  • Thank you so much @yuting , I will post my answer shortly just waiting for the live testing – Nasir Jun 19 '23 at 05:28

1 Answers1

0

The issue fixed by passing the charge id to transfer

 $intentRes = \Stripe\PaymentIntent::retrieve($updateStatus->intent_id);
                                 if(!$intentRes){
                                     return response()->json(["success" => false,"message" => "Buyer Payment Confirmation Is Incomplete"]);
                                 }
                                 $transfer = \Stripe\Transfer::create([
                                     "amount" => ($finalAmount*100),
                                     'source_transaction' => $intentRes->latest_charge, // this did the trick for me and also resolve the Insufficient fund issue
                                     "currency" => $seller_bank_account->currency,
                                     "destination" => $seller_account,
                                 ]);
Nasir
  • 41
  • 6