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

[OrderRefactor][Order][Checkout] Proceed to Checkout - Create Checkout from Shopping Cart #1105

Open
nashtech-vietvuhoang1 opened this issue Sep 30, 2024 · 1 comment
Assignees
Labels

Comments

@nashtech-vietvuhoang1
Copy link

nashtech-vietvuhoang1 commented Sep 30, 2024

When customer presses Proceed to Checkout button:

  • Create Checkout object from current Shopping Cart

Acceptance criteria

AC1: Implement API GET /product/products?ids={product_ids} on Product Service

openapi: 3.0.0
info:
  title: Product API
  description: API for managing Product Information
  version: 1.0.0
servers:
  - url: http://localhost:8080
    description: Local server
paths:
  /products:
    get:
      summary: Get all products
      operationId: getProducts
      parameters:
        - name: ids
          in: query
          description: The product ids
          required: false
          schema:
            type: array
            items:
              type: integer
              format: int64
        - name: page
          in: query
          description: The page number
          required: false
          schema:
            type: integer
            format: int64
            default: 0
        - name: size
          in: query
          description: The size of page
          required: false
          schema:
            type: integer
            format: int64
            default: 20
      responses:
        '200':
          description: A list of products
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/ProductPage'                  
components:
  securitySchemes:
    cookieAuth:
      type: apiKey
      in: cookie
      name: SESSION
  schemas:
    ProductPage:
      type: object
      properties:
        products:
          type: array
          items:
            $ref: '#/components/schemas/Product'
        page:
          type: integer
          format: int64
          default: 0
        size:
          type: integer
          format: int64
          default: 20
    Product:
      type: object
      properties:
        id:
          type: string
          format: uuid
        name:
          type: string
        description:
          type: string
        shortDescription:
          type: string
        sku:
          type: string
          format: int64
        parrent_id:
          type: integer
          format: int64
        brandId:
          type: integer
          format: int64
        price:
          type: number
          format: float
        tax:
          type: integer
          format: float
        createAt: 
          type: string
          format: date-time
        createBy:
          type: string
          format: uuid
        lastUpdateAt:
          type: string
          format: date-time
        lastUpdateBy:
          type: string
          format: uuid
security:
  - cookieAuth: []

AC2: Create Checkout object from current Shopping Cart

  • From **Order Service **, implement API POST /order/checkouts to create Checkout object

    • Create call API GET /product/products?ids={product_ids} of Product Service to get Product Information (include price and tax)
    • Create and save Checkout object to Database
      checkout erd
  • API POST /order/checkouts:

openapi: 3.0.0
info:
 title: Orders API
 description: API for managing Checkout adn Orders
 version: 1.0.0
servers:
 - url: http://localhost:8080
   description: Local server
paths:
 /checkouts:
   post: 
     summary: Create a new checkout
     operationId: createCheckout
     requestBody:
       required: true
       content:
         application/json:
           schema:
             $ref: '#/components/schemas/Checkout'
     responses:
       '201':
         description: Checkout created successfully
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'

 /checkouts/{id}:
   get: 
     summary: get Checkout By Id
     operationId: getCheckoutById
     parameters:
       - name: id
         in: path
         description: The checkout id
         required: true
         schema:
           type: string
           format: uuid
     requestBody:
       required: true
       content:
         application/json:
           schema:
             $ref: '#/components/schemas/Checkout'
     responses:
       '200':
         description: Checkout Information
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'
 /checkouts/{id}/payment:
   put:
     summary: Update Payment Method
     operationId: updatePaymentMethod
     parameters:
       - name: id
         in: path
         description: The checkout id
         required: true
         schema:
           type: string
           format: uuid
     requestBody:
       required: true
       content:
         application/json:
           schema:
             type: object
             properties:
               paymentMethodId:
                 type: string
                 format: uuid
     responses:
       '200':
         description: Checkout Information
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'
 /checkouts/{id}/promocode:
   put:
     summary: Update Promotion Code
     operationId: updatePromotionCode
     parameters:
       - name: id
         in: path
         description: The checkout id
         required: true
         schema:
           type: string
           format: uuid
     requestBody:
       required: true
       content:
         application/json:
           schema:
             type: object
             properties:
               promocode:
                 type: string
     responses:
       '200':
         description: Checkout Information
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'
 /checkouts/{id}/shipment:
   put:
     summary: Update Shipment Provider
     operationId: updateShipmentProvider
     parameters:
       - name: id
         in: path
         description: The checkout id
         required: true
         schema:
           type: string
           format: uuid
     requestBody:
       required: true
       content:
         application/json:
           schema:
             type: object
             properties:
               providerId:
                 type: string
                 format: uuid
     responses:
       '200':
         description: Checkout Information
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'
 /checkouts/{id}/address:
   put:
     summary: Update Shipment Address
     operationId: updateShipmentAddress
     parameters:
       - name: id
         in: path
         description: The checkout id
         required: true
         schema:
           type: string
           format: uuid
     requestBody:
       required: true
       content:
         application/json:
           schema:
             type: object
             properties:
               addressId:
                 type: string
                 format: uuid
     responses:
       '200':
         description: Checkout Information
         content:
           application/json:
             schema:
               $ref: '#/components/schemas/Checkout'

components:
 securitySchemes:
   cookieAuth:
     type: apiKey
     in: cookie
     name: SESSION
 schemas:
   Checkout:
     type: object
     properties:
       id:
         type: string
         format: uuid
       customerId:
         type: string
         format: uuid
       promotionCode: 
         type: string
       shipmentMethodId:
         type: string
         format: uuid
       paymentMethodId:
         type: string
         format: uuid
       shipmentAddressId:
         type: string
         format: uuid
       last_error: 
         type: object
       status:
         type: string
         enum: [CHECKED_OUT, PAYMENT_PROCESSING, PAYMENT_CONFIRMED, FULFILLED]
       totalAmount:
         type: number
         format: numeric(12, 4)
       totalTax:
         type: number
         format: numeric(12, 4)
       totalShipmentFee:
         type: number
         format: numeric(12, 4)
       totalShipmentTax:
         type: number
         format: numeric(12, 4)
       totalDiscountAmount:
         type: number
         format: numeric(12, 4)
       items:
         type: array
         items:
           $ref: '#/components/schemas/Item'
       createAt: 
         type: string
         format: date-time
       createBy:
         type: string
         format: uuid
       lastUpdateAt:
         type: string
         format: date-time
       lastUpdateBy:
         type: string
         format: uuid  
   Item:
     type: object
     required:
       - checkoutId
       - productId
       - quantity
     properties:
       checkoutId:
         type: string
         format: uuid
       productId:
         type: string
         format: uuid
       name: 
         type: string
       description:
         type: string
       shortDescription:
         type: string
       quantity:
         type: integer
         format: int64
       price:
         type: number
         format: float
       tax:
         type: number
         format: float
       shipment_fee:
         type: number
         format: numeric(12, 4)
       shipment_tax:
         type: number
         format: numeric(12, 4)
       discount_amount:
         type: number
         format: numeric(12, 4)
       status:
         type: string
       createAt: 
         type: string
         format: date-time
       createBy:
         type: string
         format: uuid
       lastUpdateAt:
         type: string
         format: date-time
       lastUpdateBy:
         type: string
         format: uuid 
security:
 - cookieAuth: []

Checkout State Diagram

Checkout Lifecycle

The Checkout Flow

Checkout Flow

@nashtech-vietvuhoang1 nashtech-vietvuhoang1 changed the title [OrderRefactor][Order][Checkout] Proceed to Checkout [OrderRefactor][Order][Checkout] Proceed to Checkout - Create Checkout from Shopping Cart Sep 30, 2024
@nashtech-vietvuhoang1 nashtech-vietvuhoang1 added refactor Code Refactor checkout good first issue Good for newcomers orders and removed good first issue Good for newcomers labels Sep 30, 2024
@NhatTranMinh15 NhatTranMinh15 self-assigned this Oct 10, 2024
@khanhduzz khanhduzz self-assigned this Oct 14, 2024
khanhduzz added a commit that referenced this issue Oct 17, 2024
#1188)

* add API GET product checkout list

* add test for new method

* add image to response

* fix checkstyle in old code

* config API url

* remove duplicate init product data in test
@khanhduzz
Copy link
Contributor

khanhduzz commented Oct 22, 2024

Updated to get tax percent when calculate order amount:

image

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

No branches or pull requests

3 participants