Skip to content

UI Library for Design Engineers. Animated components and effects you can copy and paste into your apps. Free. Open Source.

πŸ› fix: add payment script

Dillion Vermacef62c536516
diff --git a/scripts/create-payment.ts b/scripts/create-payment.ts
new file mode 100644
index 00000000..38f1da28
--- /dev/null
+++ b/scripts/create-payment.ts
@@ -0,0 +1,54 @@
+import { PrismaClient } from "@prisma/client";
+import Stripe from "stripe";
+
+const db = new PrismaClient();
+
+export const stripe = new Stripe(process.env.STRIPE_API_KEY!, {
+ apiVersion: "2022-11-15",
+ typescript: true,
+});
+
+async function seed() {
+ const user = await db.user.findFirst({
+ where: {
+ email: "[email protected]",
+ },
+ include: {
+ customer: true,
+ },
+ });
+
+ if (!user) {
+ throw new Error("User not found");
+ }
+
+ if (!user.customer) {
+ throw new Error("Customer not found");
+ }
+
+ try {
+ await db.payment.create({
+ data: {
+ stripeId: user.customer.stripeId,
+ amount: 0,
+ currency: "USD",
+ status: "succeeded",
+ customer: { connect: { id: user.customer.id } },
+ },
+ });
+
+ console.log("βœ… ");
+ } catch (e) {
+ console.log("❌ ");
+ console.error(e);
+ }
+}
+
+seed()
+ .catch((e) => {
+ console.error(e);
+ process.exit(1);
+ })
+ .finally(async () => {
+ await db.$disconnect();
+ });