This project is the backend service for an Image Selling Application, designed to support secure user authentication, optimized image uploads, and seamless payment processing. The application leverages modern technologies and third-party services to handle media, authentication, and transactions efficiently.
-
Node.js & Typescript – Core backend framework for handling routes and API logic.
-
MongoDB with Mongoose – NoSQL database for managing user data, image metadata, and order history.
-
ImageKit.io – For secure image uploads, CDN delivery, and transformation support.
-
Razorpay – Integrated as the payment gateway to manage purchases and webhook validation.
-
NextAuth.js (Credential Flow) – Used for secure session-based authentication
-
crypto – For validating Razorpay webhooks with HMAC signatures.
-
nodemailer – For sending email confirmations and order notifications.
- Supports JWT session management via NextAuth (credentials provider).
- Login & registration logic using email and password (extendable to OAuth).
- Generates secure ImageKit signed upload tokens from backend.
- Stores metadata (filename, URL, uploader, price) in MongoDB.
- Razorpay checkout session creation (amount, currency, user info).
- Webhook handler to validate payments using HMAC and Razorpay signature.
- Order creation and storage after successful payment.
- Sends confirmation emails to buyers with image details.
instance.orders.create({
"amount": 50000,
"currency": "INR",
"receipt": "receipt#1",
"partial_payment": false,
"notes": {
"key1": "value3",
"key2": "value2"
}
})
Parameters:
Name | Type | Description |
---|---|---|
amount* | integer | Amount of the order to be paid |
currency* | string | Currency of the order. Currently only INR is supported. |
receipt | string | Your system order reference id. |
notes | object | A key-value pair |
partial_payment | boolean | Indicates whether customers can make partial payments on the invoice . Possible values: true - Customer can make partial payments. false (default) - Customer cannot make partial payments. |
Response:
{
"id": "order_EKwxwAgItmmXdp",
"entity": "order",
"amount": 50000,
"amount_paid": 0,
"amount_due": 50000,
"currency": "INR",
"receipt": "receipt#1",
"offer_id": null,
"status": "created",
"attempts": 0,
"notes": [],
"created_at": 1582628071
}