#pape221298

1 messages · Page 1 of 1 (latest)

next micaBOT
distant kettle
#

Hi! Let me help you with this.

#

Could you provide your code that does this, please?

bitter hemlock
#

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;
distant kettle
#

How do you know that a customer is created?

bitter hemlock
#

I check the stripe dashboard and the new customer is always there

distant kettle
#

Can you try printing a console.log before this line:

const customer = await stripe.customers.create(args);
bitter hemlock
#

Just did and it gets printed! Customer is created as well

distant kettle
#

Could you please share the Customer ID please?

bitter hemlock
#

here: cus_OhLeBtjnjhNGPY

#

The one I just created ( in test mode)

distant kettle
#

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?

bitter hemlock
#

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

distant kettle
#

What stripe-node version are you using?

bitter hemlock
#

I am using stripe 13.7.0

#

My node version is 16.15.0

distant kettle
#

So it just silently fails?

bitter hemlock
#

Yes! no response at all.

#

Just some background info and not sure it it helps but I am using in vercel's serverless functions

distant kettle
#

If it's a normal node runtime, it shouldn't be an issue. What if you remove the try catch block?

bitter hemlock
#

Same issue sadly

#

it gets created but gets stuck (cus_OhdbHshn2a2OcQ)

distant kettle
#

Does it happen when you're testing locally?

bitter hemlock
#

Yes, i have not tested it in production yet

distant kettle
#

I mean, are you developing on vercel?

bitter hemlock
#

No I am testing it locally using vercel cli.

distant kettle
#

What if you just run the script with node.js?

next micaBOT
bitter hemlock
#

Interesting

#

Just tried it and it does work

#

it does get printed if I just run it with node

distant kettle
#

I would then suggest to reach out to Vercel.