Company logo
  • Empleos
  • Bootcamp
  • Acerca de nosotros
  • Para profesionales
    • Inicio
    • Empleos
    • Cursos y retos
    • Preguntas
    • Profesores
    • Bootcamp
  • Para empresas
    • Inicio
    • Nuestro proceso
    • Planes
    • Pruebas
    • Nómina
    • Blog
    • Comercial
    • Calculadora

0

66
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

7 months 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.

7 months ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos