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

216
Views
Stripe Payment element show saved card

I am using laravel with stripe payment element. I am trying to show the saved cards for the customers that we already have. I have followed the stripe docs and found how I can show it on checkout. But the problem is that I am not getting the saved cards for the customer. And instead I am facing an error on my console as:

enter image description here

When authenticating with an ephemeral key, you must set the Stripe-Version header to an explicit API version, such as 2020-08-27

I have checked and changed lot of versions from here:

$ephemeralKey = \Stripe\EphemeralKey::create(
                    ['customer' => "$user->stripe_customer_id"],
                    ['stripe_version' => '2019-11-05']
                );

I changed the version to different version that I can see on my stripe dashboard:

enter image description here

This is my Js Initialize function:

    // Fetches a payment intent and captures the client secret
async function initialize() {
    // Customize the appearance of Elements using the Appearance API.
    const appearance = { /* ... */ };

    // Enable the skeleton loader UI for the optimal loading experience.
    const loader = 'auto';
    const { clientSecret, customerOptions } = await fetch("{{ route("user-create-stripe-element-payment") }}", {
        method: "POST",
        headers: {
            "Content-Type" : "application/json",
            "accept" : "application/json",
            'X-CSRF-TOKEN': "{{ csrf_token() }}",
            'stripe_version':"2019-11-05"
        },
        body: JSON.stringify({ totalCharge:total }),
    }).then((r) => r.json());

    elements = stripe.elements({
        clientSecret,
        appearance,
        loader,
        customerOptions
    });

    const paymentElement = elements.create("payment");
    paymentElement.mount("#payment-element");
}

And I am also using the betas which is given in the documentation:

    const stripe = Stripe("{{env('STRIPE_KEY')}}", {
    betas: ['elements_customers_beta_1'],
});

But this error is not going away. And its not even populating the Payment element.

Please help me debug this or if someone has any suggestion to check what is going on here.

Thanks in advance.

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

0

You are not providing an API version in your JS here

const stripe = Stripe("{{env('STRIPE_KEY')}}", {
    betas: ['elements_customers_beta_1'],
});

change the above code to

const stripe = Stripe("{{env('STRIPE_KEY')}}", {
    betas: ['elements_customers_beta_1'],
    apiVersion: 'Your Version Here'
});

In your case, it should be something like this

const stripe = Stripe("{{env('STRIPE_KEY')}}", {
    betas: ['elements_customers_beta_1'],
    apiVersion: '2019-11-05'
});

You can read more here. https://stripe.com/docs/api/versioning?lang=node It is for nodejs but the API version override will work in the same way.

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!