Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

geetpurwar's avatar

Laravel Cashier 13 3D Secure Issue with Subscription

Hi,

I am trying to implement subscription with 3D secure (using Laravel Cashier), but I am missing something which is causing error and I am not able to understand how do I fix it

Screenshot: https://share.getcloudapp.com/7KuooX7K

Following : https://laravel.com/docs/8.x/billing#introduction

Front end code:

const stripe = Stripe("{{ env('STRIPE_KEY') }}");

            const elements = stripe.elements();
            const cardElement = elements.create('card');

            cardElement.mount('#card-element');

            const cardHolderName = document.getElementById('card-holder-name');
            const cardButton = document.getElementById('card-button');
            const clientSecret = cardButton.dataset.secret;

            cardButton.addEventListener('click', async (e) => {
                const { setupIntent, error } = await stripe.confirmCardSetup(
                    clientSecret, {
                        payment_method: {
                            card: cardElement,
                            billing_details: { name: cardHolderName.value }
                        }
                    }
                    );

                if (error) {
                    console.log(error.message);
                } else {
                    console.log('The card has been verified successfully...');
                    console.log(setupIntent);
                    console.log(setupIntent.payment_method);

                    setTimeout(function(){
                        $('form input[type="text"]').val(setupIntent.payment_method);
                        $('form input[type="submit"]').click();
                    }, 3000);
                }
            });

Back end code:

$paymentMethod = $request->paymentMethodId;

	try {
		$subscription = auth()->user()->newSubscription('prod_JgEOcI6QgBR1ZV', 'price_1J2rvKJxyv9NmNzM83FJgSIX')->create($paymentMethod);
	}
	catch (IncompletePayment $exception) {
		// dd($exception);

		return redirect()->route(
			'cashier.payment',
			[$exception->payment->id, 'redirect' => route('home')]
		);
	}
0 likes
1 reply

Please or to participate in this conversation.