#sergixel04
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- sergixel04, 1 hour ago, 3 messages
I paste the code:
public function storeBusiness(Request $request, BusinessService $businessService)
{
$request->validate([
'subCycle' => 'required',
];
$stripe = new \Stripe\StripeClient(config('app.stripe_secret'));
$user = User::find(auth()->id());
if ($request->subCycle == 'monthly') {
$priceId = config('app.plan_extra_monthly');
} else {
$priceId = config('app.plan_extra_yearly');
}
try {
$createdSubscription = $stripe->subscriptions->create([
'customer' => $user->stripe_id,
'items' => [
['price' => $priceId],
],
'automatic_tax' => ['enabled' => true],
'description' => 'THIS SUBSCRIPTION BELONGS TO: ' . $request->name,
]);
if ($createdSubscription->status !== 'active' && $createdSubscription->status !== 'incomplete') {
return back()->with('message', 'It wasnt possible to charge. Please contact with us.');
}
$createdBusiness = $businessService->onAddBusiness($request);
if ($createdBusiness) {
$user->addSms(40);
$createdBusiness->businesses()->create([
'user_id' => $createdBusiness->id,
'subscription_id' => $createdSubscription->id,
'billing_cycle' => $request->subCycle,
'token' => Str::random(32),
]);
return redirect()->route('activation');
}
} catch (\Exception $e) {
Log::error('Error to charge', [
'error' => $e->getMessage(),
]);
return back()->with('message', 'An error has ocurred. Please contact with us');
}
}
I have that logic to create a subscription and an account in my database. It happened that the payment was incomplete due to 3D Secure payment intent
How could I handle that?
You'd need to retreive the PaymentIntent client-secret associated with the invoice generated by the subscription and use confirmPayment client-side when the customer is on-session
You can get the payment intent by looking at
subscription.latest_invoice.payment_intent
I think I don't get it 😦
How can I use confirmPayment client-side? Is that the popup it has to appear?
Perfect thank you so much hanzo