Search code examples
laravelstripe-paymentsstriplaravel-cashier

Cashier throws error "A parameter provided in the URL (payment_method) was repeated as a GET or POST parameter." while adding payment method


I am using cashier for stripe in laravel 7, getting this error while adding payment method. A parameter provided in the URL (payment_method) was repeated as a GET or POST parameter. You can only provide this information as a portion of the URL. I am passing payment intent to the blade like this, 'intent' => $user->createSetupIntent() In js,

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

    if (error) {

        // Display "error.message" to the user...
    } else {
        send('save', false, {
            data: {
                payment_method: setupIntent
            }

        });
        // The card has been verified successfully...
    }
});

then adding

 $paymentMethod=$request['payment_method'];
        $user->updateDefaultPaymentMethod($paymentMethod);

Can anyone help me find out what is the issue.


Solution

  • It was a fault from my side,I passed complete setup intent instead of payment method in updateDefaultPaymentMethod. I need to set data as payment_method: setupIntent.payment_method