Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

208
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda