#Shivam Kumar
1 messages · Page 1 of 1 (latest)
and this is my backend code
public function stripeConnectBank(Request $request){
$stripe_secret_key = PaymentGateway::value('stripe_secret_key');
$stripe = new \Stripe\StripeClient($stripe_secret_key);
if(auth()->user()->stripe_customer_id){
$setupIntent = $stripe->setupIntents->create(
[
'customer' => auth()->user()->stripe_customer_id,
'payment_method_types' => ['us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method', 'balances']],
],
],
],
['stripe_account' => auth()->user()->stripe_connect_account_id]
);
}
if($request->setup_intent_id){
$stripe->setupIntents->confirm(
$request->setup_intent_id
);
}
return response()->json(['paymentIntent' => $setupIntent]);
}
that likely means that when you created the SetupIntent, you didn't create it on the same account(you didn't pass stripeAccount correctly on the backend)
if(!auth()->user()->stripe_customer_id){
$customer = $stripe->customers->create(
['email' => auth()->user()->email],
['stripe_account' => auth()->user()->stripe_connect_account_id]
);
$user->stripe_customer_id = $customer->id;
$user->save();
}
$setup_intent = $stripe->setupIntents->create(
[
'customer' => auth()->user()->stripe_customer_id,
'payment_method_types' => ['us_bank_account', 'card'],
'payment_method_options' => [
'us_bank_account' => [
'verification_method' => 'microdeposits',
],
],
],
['stripe_account' => auth()->user()->stripe_connect_account_id]
);
$clientSecret = $setup_intent->client_secret;
I am passing client_secret like this, Is my approach is right?
$("#add-bank") when user click on this button i am hiiting ajax this ajax request calling this function
public function stripeConnectBank(Request $request){
$stripe_secret_key = PaymentGateway::value('stripe_secret_key');
$stripe = new \Stripe\StripeClient($stripe_secret_key);
if(auth()->user()->stripe_customer_id){
$setupIntent = $stripe->setupIntents->create(
[
'customer' => auth()->user()->stripe_customer_id,
'payment_method_types' => ['us_bank_account'],
'payment_method_options' => [
'us_bank_account' => [
'financial_connections' => ['permissions' => ['payment_method', 'balances']],
],
],
],
['stripe_account' => auth()->user()->stripe_connect_account_id]
);
}
if($request->setup_intent_id){
$stripe->setupIntents->confirm(
$request->setup_intent_id
);
}
return response()->json(['setupIntent' => $setupIntent]);
}
but i got No such setupintent: 'seti_1NIsDKR7SbLLaYoVNlOOL0Gl' error
it seems correct but add logs to see what value auth()->user()->stripe_connect_account_id has and let me know what it is is if it's not null
stripeAccount: 'acct_1NCe8xR7SbLLaYoV', i am getting this value.
on the frontend, you're sure?
yes I am sure
ah right
is the error coming from here?
$stripe->setupIntents->confirm(
$request->setup_intent_id
);
because that is wrong , you need to pass the Stripe-Account option there too.
like ->confirm($id, [], ['stripe_account' => auth()->user()->stripe_connect_account_id]) for example
I think we don't need to confirm setup intent?
first we need to add bank then confirm?
usually you confirm the frontend and would not do anything in PHP for confirming the SetupIntent , yep!