This is the code where i use stripe ```---
import Base from "@/layouts/Base.astro";
import { createRequire } from 'module';
import SigninSlider from "@/layouts/function-components/SigninSlider.jsx";
import { Phone } from "react-feather";
import Notice from "@/layouts/shortcodes/Notice.jsx"
const require = createRequire(import.meta.url);
const stripe = require('stripe')(STRIPE_KEY);
const errors = { username: "", email: "", password: "" };
if (Astro.request.method === 'POST') {
// parse form data
const formData = await Astro.request.formData();
const name = formData.get('name'); // get the name field
const childName = formData.get('childName');
const childAge = formData.get('childAge');
const tel = formData.get('tel');
const email = formData.get('email');
const password = formData.get('password');
const bestTimes = formData.get('bestTimes');
if (typeof name !== "string" || name.length < 1) {
errors.username += "Please enter a Name.";
}
if (typeof password !== "string" || password.length < 6) {
errors.password += "Password must be at least 6 characters. ";
}
const customers = await stripe.customers.search({
query: email:\'${email}\',
});
if (customers["data"].length ==0 ) {
const customer = await stripe.customers.create({
name: name,
email: email,
phone: tel,
metadata: {
childName: childName,
childAge: childAge,
password: password,
bestTimes: bestTimes,
},
});
console.log(customer['id'])
Astro.cookies.set("id",customer['id'])
return Astro.redirect("/signin")
} else{
errors.email += "Email is already registered.";
}
}
---```
How do i get a stackblitz?
My dependencies already include stripe
"stripe": "^15.7.0",
"@stripe/stripe-js": "^3.4.0"