soat-fiap / FIAP.TechChallenge.ByteMeBurger

Repository for FIAP SOAT post degree Tech Challenge
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Implement Check Order Payment Status API #73

Open italopessoa opened 1 month ago

italopessoa commented 1 month ago

Create an endpoint that returns Order Payment status based on Order Id

it doesn't need to call MercadoPago gateway

italopessoa commented 2 weeks ago
graph LR
  subgraph Presentation Layer
    A[API Controller]
  end
  subgraph Application Layer
    B[Payment Status Use Case]
  end
  subgraph Domain Layer
    C[Payment Repository]
    D[Payment Entity]
  end
  subgraph Infrastructure Layer
    E[Payment Gateway]
  end

  A --> B
  B --> C
  C --> D
  C --> E
  D -.-> C
  E -.-> C

Explanation:

Flow:

  1. The API Controller receives a request with a payment ID.
  2. The API Controller calls the Payment Status Use Case, passing the payment ID.
  3. The Payment Status Use Case uses the Payment Repository to fetch the payment details.
  4. The Payment Repository interacts with the Payment Gateway to retrieve the latest payment status.
  5. The Payment Gateway returns the payment status to the Payment Repository.
  6. The Payment Repository returns the payment status to the Payment Status Use Case.
  7. The Payment Status Use Case returns the payment status to the API Controller.
  8. The API Controller returns the payment status to the client.

Benefits of Clean Architecture:

This is a basic example, and you can adapt it to your specific needs by adding more layers or components. The key is to follow the principles of clean architecture to create a maintainable and scalable system.

italopessoa commented 2 weeks ago

@coderabbitai create mermaid sequenceDiagram graph

coderabbitai[bot] commented 2 weeks ago

[!TIP] For best results, initiate chat on the files or code changes.

@italopessoa Here's the Mermaid sequence diagram based on the architecture and flow you described:

sequenceDiagram
    participant AC as API Controller
    participant PSC as Payment Status Use Case
    participant PR as Payment Repository
    participant PE as Payment Entity
    participant PG as Payment Gateway
    participant Client

    AC->>PSC: Receives request with payment ID
    PSC->>PR: Calls with payment ID
    PR->>PE: Fetches payment details
    PR->>PG: Requests payment status
    PG-->>PR: Returns payment status
    PR-->>PSC: Returns payment details and status
    PSC-->>AC: Returns payment status
    AC-->>Client: Returns payment status

This diagram illustrates the sequence of interactions between the different components in your system, following the principles of clean architecture. You can adjust or expand this diagram to include more details or additional components as needed.