this is the first time I try to deploy cloud function in Firebase, usually I use Direbase emulator, but in this case , using Stripe, I am having problems with Cors. When I run the command: firebase deploy --only functions , I have no compilation errors, but it tells me that there were errors during the release. Seeing from the Firebase console , I notice that in the logs, it says :
"@type":"type.googleapis.com/google.cloud.audit.AuditLog","status":{"code":3,"message":"Function failed on loading user code.
This is my cloud function, I don't understand the error what is:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
const stripe = require("stripe")(functions.config().stripe.secret_key);
admin.initializeApp(functions.config().firebase);
export const createCheckoutSessionGreen = functions.region("europe-west6")
.https.onCall(
async (data: any, context: any) => {
const session = await stripe.checkout.sessions.create({
payment_method_types: ["card"],
mode: "payment",
success_url: "http://localhost:8100/tabs/types/song",
cancel_url: "http://localhost:8100/tabs/types/song",
line_items: [
{
price_data: {
currency: "eur",
product_data: {
name: data,
},
unit_amount: 1.99 * 100,
},
quantity: 1,
},
],
});
return session.id;
}
);