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

157
Visualizações
how to return Stripe's createToken tokenId and use it in another function in vuex

so I call Stripe.card.createToken in my api.js file and want to return the token this function generates so I can use it in my vuex, how can I do that?

// api.js

export const stripeToken = async ({ cardInfo }) => {
  const { data } = await Stripe.card.createToken({
    cardInfo,
  });
  return data;
};

So I want to use it in my actions in vuex like this. I did this and it doesn't work, it returns undefined:

//vuex

import { stripeToken } from '@src/store/api';
async stripeToken({ dispatch }, { cardInfo }) {
  const { data } = await stripeToken({ cardInfo });
  console.log('tokenId: ', data.tokenId);
},
about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I'm not familiar with vuex, but the Stripe.card.createToken method takes two parameters: a JavaScript object containing credit card data entered by the user, and a callback function to handle the response. You can learn more about it in the Stripe documentation here.

Here's how you could display the ID of a token with Stripe.card.createToken:

Stripe.card.createToken(cardInfo, (status, response) => {
  if (response.error) {
    console.log(response.error);
  } else {
    console.log(response.id);
  }
});

Note that Stripe.card.createToken is an old method from Stripe.js v2 that is now deprecated, so I would recommend upgrading to Stripe.js v3 if possible.

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