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

Buyer should be able to checkout #79

Closed
4 tasks
ambroisegithub opened this issue May 21, 2024 · 1 comment · Fixed by #87
Closed
4 tasks

Buyer should be able to checkout #79

ambroisegithub opened this issue May 21, 2024 · 1 comment · Fixed by #87
Assignees
Labels
backend Good for newcomers

Comments

@ambroisegithub
Copy link
Contributor

ambroisegithub commented May 21, 2024

User Story: Buyer should be able to checkout

Description:

As a buyer, I want to seamlessly complete the checkout process, ensuring my order is validated, inventory is updated, and my account is updated accordingly. The process should differentiate between guest users and registered buyers before proceeding to payment. Discounts and coupon codes should be applied at checkout.

Acceptance Criteria:

Checkout Request Processing:

  • GIVEN a POST request for checkout.

Step 1:

  • WHEN the requesting user/token is a buyer and the request body is validated.

THEN:

  • The order should be processed.
  • Delivery and payment information should be saved to the buyer's account.
  • The inventory should be updated.
  • An order confirmation should be sent to the frontend to be displayed to the buyer.

Step 2:

  • WHEN the request body fails any validation checks or the token is not of the role buyer.

THEN:

  • The appropriate 4XX response message should be sent to the frontend describing the validation error.

Step 3:

  • WHEN user/token is not provided.

THEN:

  • Return an error message to the frontend asking the user to login to proceed with checkout.

Developer Notes:

Input Validation:

  • All inputs should be validated for sanity.

Order Management:

  • The order should be saved to the buyer's account for future use.

User Authentication:

  • Ensure that the user is logged in before proceeding with the checkout process.

Inventory Management:

  • Update the inventory to reflect the items ordered.

Related Issues:

#77
#54
#75
#57

@ambroisegithub ambroisegithub self-assigned this May 21, 2024
@ambroisegithub ambroisegithub added the backend Good for newcomers label May 21, 2024
@ambroisegithub
Copy link
Contributor Author

ambroisegithub commented May 21, 2024

Implementation Plan: User Checkout Functionality (2.5 Days)

Deliverables at the end of Task

  • Functional Checkout API Endpoint: A fully functional API endpoint (/api/v1/checkout or similar) that allows buyers to complete the checkout process.

  • Implemented Backend Logic: Code that handles user authentication, input validation, order processing, inventory updates and order confirmation response generation.

  • Unit Tests: A suite of unit tests that cover user authentication, input validation scenarios, core functionalities of order processing, and order confirmation response.

  • API Documentation: Comprehensive documentation for the checkout API endpoint, including details on request and response formats, error handling guidelines, and usage instructions.

Sample Flowchart about checkout Functionality

Screenshot from 2024-05-21 17-09-19

Day 1 (Wednesday, 22/05/2024):

Morning:

  1. Task: Define API endpoint for checkout. (1 hour)

  • Define the endpoint URL (e.g., /api/v1/checkout).
  • Specify the HTTP method (POST).
  • Discuss and document expected request body format (e.g., user ID, delivery information, payment information, cart items).
  1. Task: User Authentication and Error Handling (2 hours)

  • Design the logic to check user token and ensure buyer role.
  • Implement logic to return appropriate error responses (401 Unauthorized, 403 Forbidden) if user is not logged in or not a buyer.
  1. Task: Input Validation (2 hours)

  • Identify all input fields in the request body.
  • Design validation checks for each field (e.g., required fields, data type checks).
  • Implement logic to return a 400 Bad Request response with specific error messages for failing validations.

Afternoon:

  1. Task: Backend Integration and Order Processing (3 hours)

  • Design the flow for processing a valid checkout request.
  • Discuss integration with inventory management system to update stock levels.
  • Plan the logic to save order details to the user's account (consider order history or dedicated table).
  1. Task: Order Confirmation Response (1 hour)

  • Define the format of the response sent to the frontend upon successful checkout (e.g., order confirmation details).

Day 2 (Thursday, 23/05/2024):

Morning:

  1. Task: Implementation and Unit Testing (4 hours)

  • Start coding the backend logic for the checkout endpoint, focusing on authentication, validation, and core order processing flow.

  • Write unit tests to cover user authentication, input validation scenarios, and core functionalities.

Afternoon:

  1. Task: mplementation and Unit Testing (4 hours)

  • Continue coding the backend logic, focusing on order confirmation response and integration with inventory
    management (if applicable).
  • Write unit tests for order confirmation response and mock successful inventory updates.

Evening:

  1. Task: Code Review and Refinement (2 hours)

  • Conduct code review sessions to ensure quality and identify potential improvements.
  • Refine code based on feedback and address any identified issues.

Day 3 (Friday, 24/05/2024):

Morning:

  1. Task: Pushing and Testing (2 hours)

Afternoon:

Task: Documentation and Refinement (2 hours)

  • Document the API endpoint details, including request and response formats, error handling, and usage guidelines.
  • Address any outstanding issues or bugs identified during testing.

Evening:

  1. Task: Review and Handover (1 hour)

  • Conduct a final review of the implemented functionality and documentation.
  • Handover the code and documentation to relevant stakeholders for further integration and testing.

Notes:

  • This plan is an estimate and may require adjustments based on development complexities.
  • Tasks like discount and coupon code application can be addressed in future iterations.
  • Integration with specific payment gateways might require additional planning and development time.
  • Communication and collaboration throughout the process are crucial for successful implementation.

@ambroisegithub ambroisegithub linked a pull request May 22, 2024 that will close this issue
4 tasks
@ambroisegithub ambroisegithub added this to the Order Management milestone May 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant