#pape221298
1 messages · Page 1 of 1 (latest)
Hi! Let me help you with this.
Could you provide your code that does this, please?
Thank you and yes one second
import { prisma, stripe } from '../utils';
const handler = async (req, res) => {
const { first_name, last_name, email } = req.body.record;
const args = {
name: `${first_name} ${last_name}`,
email
}
try {
const customer = await stripe.customers.create(args);
console.log(customer.id)
} catch (err) {
console.log(err);
}
};
export default handler;
How do you know that a customer is created?
I check the stripe dashboard and the new customer is always there
Can you try printing a console.log before this line:
const customer = await stripe.customers.create(args);
Just did and it gets printed! Customer is created as well
Could you please share the Customer ID please?
I see the creation request was successful. It seems like there's something in your app that fails before the response arrives. I see stripe is coming from ../utils, why is that?
Do you have some sort of wrapper over it? Do other requests to Stripe fail too?
I create a Stripe instance only once and I use it in multiple places
import Stripe from 'stripe';
export const stripe = Stripe(process.env.STRIPE_SECRET_KEY);
Should I just instantiate it everytime?
Other requests don't fail
What stripe-node version are you using?
So it just silently fails?
Yes! no response at all.
Just some background info and not sure it it helps but I am using in vercel's serverless functions
If it's a normal node runtime, it shouldn't be an issue. What if you remove the try catch block?
Does it happen when you're testing locally?
Yes, i have not tested it in production yet
I mean, are you developing on vercel?
No I am testing it locally using vercel cli.
What if you just run the script with node.js?
Interesting
Just tried it and it does work
it does get printed if I just run it with node
I would then suggest to reach out to Vercel.