#mehroo
1 messages · Page 1 of 1 (latest)
Hi there!
Can you share the request ID (req_xxx)? Here's how you can find it: https://support.stripe.com/questions/finding-the-id-for-an-api-request
But based on the error message I'm guessing you forgot to set the apiVersion in your request.
@grave frost can I share my code here?
const functions = require("firebase-functions");
const stripe = require('stripe')("my-secret-key", {
apiVersion: '2020-08-27',
});
Sure, feel free to share your code that generated this error.
exports.stripePaymentIntentRequest = functions.https.onRequest(async (req, res) => {
try {
let customerId;
//Gets the customer who's email id matches the one sent by the client
const customerList = await stripe.customers.list({
email: req.body.email,
limit: 1
});
//Checks the if the customer exists, if not creates a new customer
if (customerList.data.length !== 0) {
customerId = customerList.data[0].id;
}
else {
const customer = await stripe.customers.create({
email: req.body.email
});
customerId = customer.data.id;
}
//Creates a temporary secret key linked with the customer
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customerId },
{ apiVersion: '2020-08-27' }
);
//Creates a new payment intent with amount passed in from the client
const paymentIntent = await stripe.paymentIntents.create({
amount: parseInt(req.body.amount),
currency: 'usd',
customer: customerId,
})
res.status(200).send({
paymentIntent: paymentIntent.client_secret,
ephemeralKey: ephemeralKey.secret,
customer: customerId,
success: true,
})
} catch (error) {
functions.logger.info(error.message, { structuredData: true });
console.log(error);
res.status(404).send({ success: false, error: error.message })
}
});
here is my code, I'm using firebase functions
Which part is generating the error? I'm guessing this function?
const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customerId },
{ apiVersion: '2020-08-27' }
);
yeah I think this part is generating error, I think It is not creating ephemeralKey
And can you share the request ID with the error?
Actually I checked my logs in my stripe account, there is not logs of today.
Can you share your account ID (acct_xxx)? It's at the top of this page: https://dashboard.stripe.com/settings/account
Hi there 👋 I'm jumping in as my teammate needed to step away, please bear with me a moment while I pull up your account.
Hi @neon turret I really appreciate your help! I can wait ofcourse
I'm not readily finding any request logs that align with the error message that you shared. I do see some failed requests that returned an error when trying to create a Payment Intent. Could you try adding some logging between each of the requests in your code to determine exactly which one is surfacing that error?
I shared my code above In that code: before creating an intent request, I create ephemeralKey. I thought this code is giving error: const ephemeralKey = await stripe.ephemeralKeys.create(
{ customer: customerId },
{ apiVersion: '2020-08-27' }
);
All of the ephemeral key requests that I'm seeing succeeded, such as this one:
https://dashboard.stripe.com/test/logs/req_72xHP30ZJnKfKM
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I just noticed the timestamp on that request is from several days ago though, and am not seeing any recent (made within the last couple of days) requests logged for your account. Have you tried testing this flow recently?
I tried this half hour ago
Ah, I see, I switched to seeing all requests (rather than just POSTS) and I'm seeing evidence of your GET requests (listing customers).
Nothing is readily jumping out at me as being wrong with your code, and when I mimc your request structure in my node shell, I'm not encountering an error.
Have you confirmed that customerId is getting populated the way you expect?