-
Notifications
You must be signed in to change notification settings - Fork 456
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat/add razorpay #323
Closed
Closed
feat/add razorpay #323
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
5c16513
feat/add razorpay
Suryansh777777 241ecc2
merged main into feat/razorpay
Suryansh777777 c861ae7
merged main into feat/razorpay
Suryansh777777 bc83a22
Add payment CTA
Suryansh777777 e6d5b9d
merged main into feat/razorpay
Suryansh777777 30bd5fd
Merge branch 'main' into feat/razorpay
Suryansh777777 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
# Project Name: Job Board | ||
|
||
[All about job board](https://marmalade-height-05f.notion.site/100xDevs-Job-board-ab8ca399180d49e4bc0c2ff5c81dfb08?pvs=25) <br/> | ||
[Project Status](https://marmalade-height-05f.notion.site/Job-board-10315651c69c80b581b5f7b64667341c) | ||
|
||
## Table of Contents | ||
|
||
- [Description](#description) | ||
|
@@ -38,25 +40,41 @@ Follow these steps to set up the repository locally and run it. | |
|
||
```bash | ||
# | ||
# Database | ||
<<<<<<< HEAD | ||
# Database | ||
======= | ||
# Database | ||
>>>>>>> main | ||
# | ||
DATABASE_URL="postgres://postgres:password@localhost:5432/postgres" | ||
|
||
# | ||
# AUTH | ||
<<<<<<< HEAD | ||
# AUTH | ||
======= | ||
# AUTH | ||
>>>>>>> main | ||
# | ||
NEXTAUTH_SECRET="koXrQGB5TFD4KALDX4kAvnQ5RHHvAOIzB" | ||
NEXTAUTH_URL="http://localhost:3000" | ||
|
||
# | ||
# Bunny CDN | ||
# | ||
<<<<<<< HEAD | ||
CDN_API_KEY=api-key | ||
CDN_BASE_UPLOAD_URL=https://sg.storage.bunnycdn.com/job-board/assets | ||
CDN_BASE_ACCESS_URL=https://job-board.b-cdn.net/assets | ||
======= | ||
CDN_SZ_NAME= | ||
CDN_BASE_PATH= | ||
CDN_API_KEY= | ||
>>>>>>> main | ||
``` | ||
|
||
2. To generate AUTH_SECRET, | ||
2. Change the hostname in `next.config.js` with your CDN access hostname by Ref of provided example. | ||
|
||
3. To generate AUTH_SECRET, | ||
|
||
Run this command in your terminal: | ||
|
||
|
@@ -68,7 +86,6 @@ Follow these steps to set up the repository locally and run it. | |
|
||
[Run in browser](https://www.cryptool.org/en/cto/openssl/) | ||
|
||
|
||
### Running the Project with Docker | ||
|
||
```bash | ||
|
@@ -104,43 +121,44 @@ Emails: '[email protected], [email protected]'; | |
Password: '123456'; | ||
``` | ||
|
||
|
||
## Steps to create a BunnyCDN storage for this repo: | ||
|
||
1. **Create a storage zone:** | ||
|
||
<img src="https://utfs.io/f/CUistsOk9f0Iocrllmq4RQuXkCx9NthDrTEw6dFy1Z3KfIPc" alt="Create a storage zone" width="150" /> | ||
<img src="https://utfs.io/f/CUistsOk9f0Iocrllmq4RQuXkCx9NthDrTEw6dFy1Z3KfIPc" alt="Create a storage zone" width="150" /> | ||
|
||
2. **Connect the storage zone to a pull zone:** | ||
|
||
<img src="https://utfs.io/f/CUistsOk9f0ImevkKUyo3QdPNXDuFbcZEagW0AUej1tzvmMw" alt="Connect the storage zone to a pull zone" width="250" /> | ||
<img src="https://utfs.io/f/CUistsOk9f0ImevkKUyo3QdPNXDuFbcZEagW0AUej1tzvmMw" alt="Connect the storage zone to a pull zone" width="250" /> | ||
|
||
4. **Set environment variables:** | ||
3. **Set environment variables:** | ||
|
||
Go to the FTP & API Access section in the storage zone and add the following environment variables: | ||
|
||
```bash | ||
CDN_API_KEY=<your-api-key> | ||
``` | ||
|
||
Which you can find in the storage -> [storage name] -> FTP & API Access section | ||
|
||
<img src="https://utfs.io/f/CUistsOk9f0Imf5c1ZUyo3QdPNXDuFbcZEagW0AUej1tzvmM" alt="CDN_API_KEY" width="500" /> | ||
|
||
--- | ||
|
||
```bash | ||
CDN_BASE_UPLOAD_URL=<your-cdn-base-upload-url> | ||
``` | ||
Which is https://[your-hostname]/[storage-name]/[any folder name you might have added otherwise empty] | ||
|
||
```bash | ||
CDN_BASE_UPLOAD_URL=<your-cdn-base-upload-url> | ||
``` | ||
|
||
Which is https://[your-hostname]/[storage-name]/[any folder name you might have added otherwise empty] | ||
|
||
<img src="https://utfs.io/f/CUistsOk9f0Imf5c1ZUyo3QdPNXDuFbcZEagW0AUej1tzvmM" alt="CDN_BASE_UPLOAD_URL" width="500" /> | ||
|
||
--- | ||
|
||
```bash | ||
CDN_BASE_ACCESS_URL=<your-cdn-base-access-url> | ||
``` | ||
Which is https://[your-pull-zone-hostname]/[any folder name you might have added otherwise empty] or get link from the dashboard as mentioned below | ||
|
||
|
||
```bash | ||
CDN_BASE_ACCESS_URL=<your-cdn-base-access-url> | ||
``` | ||
|
||
Which is https://[your-pull-zone-hostname]/[any folder name you might have added otherwise empty] or get link from the dashboard as mentioned below | ||
|
||
<img src="https://utfs.io/f/CUistsOk9f0IyM9047Pa7YvK8qbtnUAPO9jwxdskhzc2JNoR" alt=" CDN_BASE_ACCESS_URL" width="600" /> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
prisma/migrations/20240916193844_add_razorpay_schema/migration.sql
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
-- AlterTable | ||
ALTER TABLE "Job" ADD COLUMN "transactionId" TEXT; | ||
|
||
-- CreateTable | ||
CREATE TABLE "RazorpayTransactions" ( | ||
"id" TEXT NOT NULL, | ||
"createdAt" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP, | ||
"updatedAt" TIMESTAMP(3) NOT NULL, | ||
"razorpayPaymentId" TEXT NOT NULL, | ||
"razorpayOrderId" TEXT NOT NULL, | ||
"razorpaySignature" TEXT NOT NULL, | ||
"status" TEXT NOT NULL, | ||
"jobId" TEXT, | ||
|
||
CONSTRAINT "RazorpayTransactions_pkey" PRIMARY KEY ("id") | ||
); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "RazorpayTransactions_razorpayPaymentId_key" ON "RazorpayTransactions"("razorpayPaymentId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "RazorpayTransactions_razorpayOrderId_key" ON "RazorpayTransactions"("razorpayOrderId"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "RazorpayTransactions_razorpaySignature_key" ON "RazorpayTransactions"("razorpaySignature"); | ||
|
||
-- CreateIndex | ||
CREATE UNIQUE INDEX "RazorpayTransactions_jobId_key" ON "RazorpayTransactions"("jobId"); | ||
|
||
-- AddForeignKey | ||
ALTER TABLE "RazorpayTransactions" ADD CONSTRAINT "RazorpayTransactions_jobId_fkey" FOREIGN KEY ("jobId") REFERENCES "Job"("id") ON DELETE SET NULL ON UPDATE CASCADE; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import Razorpay from 'razorpay'; | ||
import { NextRequest, NextResponse } from 'next/server'; | ||
|
||
import { z } from 'zod'; | ||
|
||
const razorpayInstance = new Razorpay({ | ||
key_id: process.env.RAZORPAY_ID || '', | ||
key_secret: process.env.RAZORPAY_SECRET || '', | ||
}); | ||
|
||
const payloadSchema = z.object({ | ||
amount: z.string(), | ||
currency: z.string(), | ||
}); | ||
|
||
export async function POST(request: NextRequest) { | ||
try { | ||
const payload = await request.json(); | ||
|
||
const { amount, currency } = payloadSchema.parse(payload); | ||
const options = { | ||
amount, | ||
currency, | ||
receipt: 'rcp1', | ||
}; | ||
const order = await razorpayInstance.orders.create(options); | ||
|
||
return NextResponse.json( | ||
{ | ||
id: order.id, | ||
currency: order.currency, | ||
amount: order.amount, | ||
}, | ||
{ status: 200 } | ||
); | ||
} catch (error) { | ||
return NextResponse.json({ error }, { status: 500 }); | ||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we're serializing each api reponse to a certain shape , refer jobs/actions.ts