Skip to content
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

Add Payment Schema, Controllers, and Admin-Restricted Management Routes for Backend #954

Merged
merged 1 commit into from
Nov 10, 2024

Conversation

IkkiOcean
Copy link
Contributor

Description:
This PR introduces the schema, controller, and management features for handling payments in the backend. It includes a set of routes allowing the system to store, track, and manage payment-related information. Additionally, certain CRUD operations are restricted to admins, ensuring secure access and control over payment details via the admin dashboard.

Changes Implemented

1. Payment Schema

  • Schema Design: Created a Payment schema to store all relevant information about customer payments.
    • Fields:
      • paymentId, orderId, userId, amount, paymentMethod, paymentStatus, paymentDate, transactionId.
    • Validations & Defaults:
      • paymentStatus defaults to Pending.
      • Required validations on fields like amount, userId, and orderId to ensure data integrity.

2. Payment Controller

  • CRUD Operations:
    • Retrieve All Payments: Allows admins to fetch all payment records for tracking and auditing.
    • Retrieve Payment by ID: Allows access to a specific payment record based on paymentId.
    • Create Payment: Adds a new payment entry with the required details.
    • Update Payment Status: Enables admins to update the paymentStatus field (Pending, Completed, Failed).
    • Update Payment Method: Allows admins to modify the payment method.
    • Delete Payment: Allows admins to remove a specific payment entry based on paymentId.

3. Payment Management API Endpoints

  • Routes:
    • GET /: Retrieve all payments (Admin-only).

    • GET /:id: Retrieve a specific payment by ID.

    • GET /user/:userId: Retrieve all payments made by a specific user.

    • GET /status/:status: Retrieve payments filtered by status.

    • POST /: Create a new payment.

    • PATCH /:id/status: Update the status of a specific payment (Admin-only).

    • PATCH /:id/method: Update the payment method of a specific payment (Admin-only).

    • DELETE /:id: Delete a specific payment (Admin-only).

    • Additional Routes for Edge Cases:

      • GET /date-range: Retrieve payments within a specific date range.
      • GET /amount-range: Retrieve payments within a specific amount range.
      • GET /transaction/:transactionId: Retrieve a payment by transaction ID.
      • GET /count/status: Count payments grouped by their status.
  • fixes Develop Payment and Invoice Management System with Schema, Controller, and Functionality for Admin Dashboard #946

4. Middleware

  • Access Control Middleware:

    • Implemented middleware to verify admin access, restricting certain routes (e.g., GET /, PATCH /:id/status, PATCH /:id/method, DELETE /:id) to admins only.
  • Payment Data Validation Middleware:

    • Ensures that all required fields are valid before creating or updating a payment.

Copy link

vercel bot commented Nov 9, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
agro-tech-ai ✅ Ready (Inspect) Visit Preview 💬 Add feedback Nov 9, 2024 7:24pm

Copy link
Contributor

github-actions bot commented Nov 9, 2024

Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our CONTRIBUTING.md. If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊

@manikumarreddyu manikumarreddyu merged commit f518995 into manikumarreddyu:main Nov 10, 2024
4 checks passed
Copy link
Contributor

🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Develop Payment and Invoice Management System with Schema, Controller, and Functionality for Admin Dashboard
2 participants