Skip to content

Commit

Permalink
Add razorpayCustomerID to user model, listen to webhook
Browse files Browse the repository at this point in the history
  • Loading branch information
yash22arora committed May 28, 2024
1 parent 3501319 commit 11b6253
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
3 changes: 2 additions & 1 deletion server/src/api/models/record.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import mongoose, { Document, Schema } from "mongoose";
import { TRecordType } from "../../utils/types";

interface IRecord extends Document {
cloudflareID: string;
Expand All @@ -8,7 +9,7 @@ interface IRecord extends Document {
ownerID: string;
name: string;
content: string;
type: string;
type: TRecordType;
created_at: Date;
updated_at: Date;
}
Expand Down
6 changes: 4 additions & 2 deletions server/src/api/models/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ interface IUser extends Document {
phoneNumber: string;
firebaseUID: string;
email: string;
stripeCustomerId: string;
stripeCustomerID: string;
razorpayCustomerID: string;
onWaitlist: boolean;
}

Expand All @@ -19,7 +20,8 @@ const userScheme: Schema<IUser> = new mongoose.Schema({
},
firebaseUID: { type: String, required: true, unique: true },
email: { type: String, required: false },
stripeCustomerId: { type: String, required: false },
stripeCustomerID: { type: String, required: false },
razorpayCustomerID: { type: String, required: false },
onWaitlist: { type: Boolean, required: true, default: false },
});

Expand Down
5 changes: 4 additions & 1 deletion server/src/api/routes/plan.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ router.get(
);

router.post("/webhook", (req: Request, res: Response) => {
console.log(req.body);
if (req.body.event === "subscription.charged") {
const subscriptionEntity = req.body.payload.subscription.entity;
console.log({ ...subscriptionEntity });
}
res.status(200).send("ok");
});

Expand Down

0 comments on commit 11b6253

Please sign in to comment.