Reputation: 3
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
Upvotes: 0
Views: 452
Reputation: 2184
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:
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.
Upvotes: 1