#rutvik_gumasana
1 messages ยท Page 1 of 1 (latest)
Hello ๐
What issue are you running into?
Can you help me out to implement payout
i am working on one marketplace
where user will pay to platform
and then platform will pay to the sellers
Sure, Can you provide more information about what you've tried already and where you're stuck?
SHould i share the snippet code of what ive tried?
Sure
Step 1
public function create_account_link(Request $request) {
$secrate_id = config('stripe.secret_key');
$stripe = new \Stripe\StripeClient(
$secrate_id
);
$provider_id = Auth::user()->id;
$return_url = $request->input('return_url');
$account_info = tbl_user_banktoken::select(array('stripe_account_id'))->where('user_id', $provider_id)->first();
$stripe_account_id = $account_info->stripe_account_id;
try {
$account_link = $stripe->accountLinks->create([
'account' => $stripe_account_id,
'refresh_url' => $return_url,
'return_url' => $return_url,
'type' => 'account_onboarding',
]);
return $this->sendResponse(1, 'Account added successfully.', $account_link);
} catch (\Stripe\Exception\ApiErrorException $e) {
$return_array = [
"status" => $e->getHttpStatus(),
"type" => $e->getError()->type,
"code" => $e->getError()->code,
"param" => $e->getError()->param,
"message" => $e->getError()->message,
];
$return_str = json_encode($return_array);
http_response_code($e->getHttpStatus());
return $this->sendResponse(0, 'add account error', $return_array);
}
}
Step 2
public function create_connected_account(Request $request) {
$email = Auth::user()->email;
$secrate_id = config('stripe.secret_key');
$stripe = new \Stripe\StripeClient(
$secrate_id
);
try {
$account_info = $stripe->accounts->create([
'type' => 'standard',
'email' => $email,
]);
$account_id = $account_info->id;
$tbl_user_banktoken = new tbl_user_banktoken();
$tbl_user_banktoken->stripe_account_id = $account_id;
$tbl_user_banktoken->user_id = auth::id();
$tbl_user_banktoken->save();
return $this->sendResponse(1, 'Account added successfully.', $account_id);
} catch (\Stripe\Exception\ApiErrorException $e) {
$return_array = [
"status" => $e->getHttpStatus(),
"type" => $e->getError()->type,
"code" => $e->getError()->code,
"param" => $e->getError()->param,
"message" => $e->getError()->message,
];
$return_str = json_encode($return_array);
http_response_code($e->getHttpStatus());
return $this->sendResponse(0, 'add account error', $return_array);
}
}
Step 3
$td['destination'] = $stripe_account_id;
$payment_info = $stripe->paymentIntents->create([
'amount' => $total_amount,
'currency' => 'usd',
'customer' => $stripe_customer_id,
'payment_method' => $card_id,
'payment_method_types' => ['card'],
'transfer_data' => $td,
'confirm' => True,
'application_fee_amount' => $admin_comission,
'capture_method' => 'manual'
]);
$charge_id = $payment_info->id;
that's a lot of code ๐
When you said snippet, I imagined only the code that handles payouts