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

178
Visualizações
stripe.tokens.create returns nothing

I have the following code

import { STRIPE_SK } from '../../constants';
const secretKey = STRIPE_SK 
const stripe = require('stripe')(secretKey);

export async function createToken(){
  try{
    console.log("Start process")
    const token = await stripe.tokens.create({
      card: {
        number: '4242424242424242',
        exp_month: 12,
        exp_year: 2022,
        cvc: '314',
      },
    });
    console.log("Token - ", token)
    return token
  }catch(err){
    console.log(err)
    throw err
  }
}

i want to get a token but i am not getting anything. There is no mistake and no success

the result of the function in the console

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

I just copy-pasted the content of your function and it worked: I saw a card token in my logs. When running this code, you need to make sure that:

  • You are actually calling your function somewhere in your backend code.
  • You are looking at logs in the right place. Your screenshot looks like a browser console where you’ll only see frontend logs. For backend logs, you should be looking at the terminal where you started your node.js server.
  • And that you are using your test API key (and not the live one) since you are currently not processing real cards.

That being said, I would not recommend using this code because sending raw card numbers has PCI compliance issues. Instead you should follow this Stripe guide to accept payments.

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