Skip to content

Commit

Permalink
Merge branch 'tarun/feature/stripe-express' of https://github.com/Uoa…
Browse files Browse the repository at this point in the history
…WDCC/auis-portal into tarun/feature/stripe-express
  • Loading branch information
Ratchet7x5 committed Jul 3, 2024
2 parents 56e3bd5 + 7740739 commit 24625b2
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 10 deletions.
20 changes: 20 additions & 0 deletions api/db/User.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { Schema, model } from "mongoose";

const userSchema = new Schema({
firstName: {
type: String,
required: true,
},
lastName: String,
email: {
type: String,
required: true,
unique: true,
maxLength: 40,
minLength: 1,
},
});

const User = model("User", userSchema);

export default User;
4 changes: 2 additions & 2 deletions api/db/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ dotenv.config();
if (!process.env.STRIPE_SECRET_TEST) {
throw new Error(
`.env: Stripe Secret (Test mode) is required. Received: "${process.env.STRIPE_SECRET_TEST}"`
)
);
}
})();

Expand All @@ -34,5 +34,5 @@ export const {
DATABASE_PORT,
DATABASE_USERNAME,
DATABASE_PASSWORD,
STRIPE_SECRET_TEST
STRIPE_SECRET_TEST,
} = process.env;
4 changes: 2 additions & 2 deletions api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import authRoutes from "./routes/authRoutes";
import creditRoutes from "./routes/creditRoutes";
import adminRoutes from "./routes/adminRoutes";
import photoRoutes from "./routes/photoRoutes";
import stripeRoutes from "./routes/stripeRoutes"
import stripeRoutes from "./routes/stripeRoutes";

import { errorHandler, notFound } from "./middleware/errorMiddleware";
import userRoutes from "./routes/userRoutes";
Expand All @@ -32,7 +32,7 @@ app.use("/api/photos", photoRoutes);
app.use("/api", userRoutes); //Demo Route on how to work with Drizzle

//StripeJS
app.use("/api/stripe", stripeRoutes)
app.use("/api/stripe", stripeRoutes);

// The custom handlers in /middleware need to be below Routes
app.use(notFound);
Expand Down
4 changes: 2 additions & 2 deletions api/middleware/errorMiddleware.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Request, Response, NextFunction } from 'express';
import dotenv from 'dotenv';
import { Request, Response, NextFunction } from "express";
import dotenv from "dotenv";

dotenv.config();

Expand Down
2 changes: 1 addition & 1 deletion web/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import CheckoutScreen from "./screens/CheckoutScreen.tsx";
import ReturnScreen from "./screens/ReturnScreen.tsx";
import EventScreen from "./screens/EventScreen.tsx";

// @Ratchet7x5: keys etc need to be parsed before route creation.
// @Ratchet7x5: keys etc need to be parsed before route creation.
const CLERK_PUBLISHABLE_KEY = import.meta.env.VITE_CLERK_PUBLISHABLE_KEY;

if (!CLERK_PUBLISHABLE_KEY) {
Expand Down
4 changes: 2 additions & 2 deletions web/src/screens/CheckoutScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
} from "@stripe/react-stripe-js";

const STRIPE_PUBLISHABLE_KEY = import.meta.env.VITE_STRIPE_PUBLISH_KEY_DEV;
console.log(STRIPE_PUBLISHABLE_KEY)
console.log(STRIPE_PUBLISHABLE_KEY);

// Make sure to call `loadStripe` outside of a component’s render to avoid
// recreating the `Stripe` object on every render.
Expand All @@ -20,7 +20,7 @@ function CheckoutScreen() {
"http://localhost:3000/api/stripe/create-checkout-session",
{
method: "POST",
headers: { 'Content-Type': 'application/json' },
headers: { "Content-Type": "application/json" },
// add our own priceId here later for different products
body: JSON.stringify(bodyData),
}
Expand Down
4 changes: 3 additions & 1 deletion web/src/screens/ReturnScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,9 @@ const ReturnScreen = () => {
const urlParams = new URLSearchParams(queryString);
const sessionId = urlParams.get("session_id");

fetch(`http://localhost:3000/api/stripe/session-status?session_id=${sessionId}`)
fetch(
`http://localhost:3000/api/stripe/session-status?session_id=${sessionId}`
)
.then((res) => res.json())
.then((data) => {
setStatus(data.status);
Expand Down

0 comments on commit 24625b2

Please sign in to comment.