Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

226
Views
card-element not working with Stripe.elements() is not a function error

I am trying to make a Stripe payment method on my form in Laravel App but somehow the card-element fails to render with a Stripe.elements() is not a function on browser's console.

I here's my code (cutting irrelevant code):

<head>
    <script src="https://js.stripe.com/v3/"></script>
</head>

<body>
    <form>
        <div class="mb-6 mx-2">
            <div id="card-element"></div>
        </div>
        <div class="mb-2 mx-2">
            @csrf
            <input type="hidden" id="payment_method_id" name="payment_method_id" value="">
            <button type="submit" id="form_submit"> Continue to payment</button>
        </div>
    </form>

    <script>
            const stripe = Stripe("{{ env('STRIPE_KEY') }}");
            const elements = Stripe.elements();
            const cardElement = elements.create('card', {
            });
            cardElement.mount('#card-element');
    </script>
</body>

I have tried solution from this

Tried to do it by adding load event listener as:

<script>
    window.addEventListener('load', function (){
        const stripe = Stripe("{{ env('STRIPE_KEY') }}");
        const elements = Stripe.elements();
        const cardElement = elements.create('card', {
        });
        cardElement.mount('#card-element');
    });
</script>

but still the same error Stripe.elements() is not a function Here's the official Stripe Docs that I am following. Can anybody tell me what am I possibly doing wrong?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

According to the sample from the documentation:

var stripe = Stripe('pk_test_TYooMQauvdEDq54NiTphI7jx'
);
var elements = stripe.elements();

elements() is a function on an instance of Stripe. You have Stripe.elements() in your code capitalized, probably by accident. It should be lowercase.

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!