Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

217
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda