It seems like the issue is related to the fact that the payment is marked as incomplete even though the payment intent has succeeded. This could be due to the fact that the payment requires additional authentication, which is not yet completed.
One solution could be to listen for the payment_intent.succeeded webhook event and update the payment status accordingly. This way, you can be sure that the payment is complete before processing the order.
Here's an example of how you can handle the webhook event in Laravel:
use Illuminate\Http\Request;
use Laravel\Cashier\Http\Controllers\WebhookController;
class StripeWebhookController extends WebhookController
{
public function handlePaymentIntentSucceeded(Request $request)
{
$payload = $request->all();
$paymentIntent = $payload['data']['object'];
// Update the payment status in your database
// ...
return response('Webhook Handled', 200);
}
}
Make sure to register the webhook route in your routes/web.php file:
Route::post('/stripe/webhook', 'StripeWebhookController@handleWebhook');
Also, make sure to configure the webhook in your Stripe dashboard to point to the correct URL.
Once you have set up the webhook, you can ignore the IncompletePayment exception and process the order. The webhook will update the payment status once the additional authentication is completed.
Note: This solution assumes that you have set up the webhook correctly and that it is working as expected.