@mrsandywilly but are you hitting the expected function? Can you dd() and see if you got the details correctly?
And periods are not translated to link as long as it's in a code format :)
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hiya, this is probably a bit of an idiot question, but I'm struggling a bit with stripe.
<form id="payment-form" style="width:25%;">
@csrf
<input id="card-holder-name" type="text">
<!-- Stripe Elements Placeholder -->
<div id="card-element"></div>
<button id="card-button">
Process Payment
</button>
</form>
<script>
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');
cardButton,addEventListener('click', async (e) => {
const { paymentMethod, error } = await stripe,createPaymentMethod(
'card', cardElement, {
billing_details: { name: cardHolderName,value }
}
);
if (error) {
alert(error,message);
} else {
axios,post('/charge', { payment_method: paymentMethod,id })
,then((response) => {
alert('transaction success')
})
,catch((error) => {
alert('transaction failed')
})
}
});
</script>
A post request to /charge routes to a simple controller function as follows:
public function charge(Request $request)
{
$stripeCharge = (new User)->charge(
100, $request->input('payment_method')
);
}
When I hit submit on the form, the page reloads but nothing goes through to stripe, nor do I get either of the alerts. Help much appreciated :)
(I had to replace all of the periods in the code with a comma, otherwise laracasts thinks its a link :) Hope it makes sense)
Please or to participate in this conversation.