• Empleos
  • Sobre nosotros
  • profesionales
    • Inicio
    • Empleos
    • Cursos y retos
  • empresas
    • Inicio
    • Publicar vacante
    • Nuestro proceso
    • Precios
    • Evaluaciones
    • Nómina
    • Blog
    • Comercial
    • Calculadora de salario

0

121
Vistas
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

almost 3 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

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.

almost 3 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 Nuestro proceso Comercial
Legal
Términos y condiciones Política de privacidad
© 2025 PeakU Inc. All Rights Reserved.

Andres GPT

Recomiéndame algunas ofertas
Necesito ayuda