Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces a variety of changes, including updates to configuration management, Docker setup, payment processing, and order handling. It also simplifies the handling of product weights and adds new middleware functionality. Below is a categorized summary of the most significant changes:

Configuration and Environment Updates:

  • Added STRIPE_WEBHOOK_SECRET and STRIPE_PAYMENT_DESCRIPTION to .env.example for Stripe integration. Consolidated RETURN_URL for Stripe, PayPal, and MobilePay into a single environment variable. [1] [2]
  • Introduced a new CORSConfig structure to manage CORS settings, with defaults allowing all origins. Updated LoadConfig to include this configuration. [1] [2] [3] [4]

Docker and Deployment Enhancements:

  • Added a Dockerfile with a multi-stage build process for API, migration, and seeding binaries.
  • Created docker-compose.yml to define services for PostgreSQL, the API, and database tools (migrate and seed).

Payment and Order Processing Improvements:

  • Upgraded stripe-go library from v72 to v82, enabling support for new Stripe features. [1] [2]
  • Added GetOrderByPaymentID and RecordPaymentTransaction methods to the OrderUseCase to enhance payment handling. [1] [2]

Product Weight Simplification:

  • Removed weight handling for product variants, standardizing weight at the product level. This change simplifies calculation logic across multiple use cases. [1] [2] [3] [4] [5] [6] [7]

Middleware Enhancements:

  • Added a CorsMiddleware to handle Cross-Origin Resource Sharing (CORS) requests. Integrated it into the middleware provider. [1] [2] [3]

These changes collectively improve the application's configuration flexibility, deployment options, payment processing capabilities, and code maintainability.

gustaavik added 10 commits May 3, 2025 21:44
- Added ProductDetail component for displaying product information, variants, and images.
- Integrated add to cart functionality with quantity selection and variant handling.
- Created ProductsHome component to list products with filtering and sorting options.
- Established CartContext for managing cart state, including adding, updating, and removing items.
- Defined TypeScript types for products, variants, categories, and cart items.
- Implemented CORS middleware for API to handle cross-origin requests.
@gustaavik gustaavik requested a review from Copilot May 5, 2025 13:56
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This pull request introduces several changes aimed at improving configuration management and deployment, updating payment processing for Stripe and MobilePay, standardizing product weight handling, and enhancing middleware functionality (including the addition of a CORS middleware).

  • Updates to the configuration (added new environment variables, CORSConfig, and consolidated return URLs)
  • Enhancements in Docker setup and payment processing (upgrade to stripe-go v82, new payment-related methods, and order use case updates)
  • Simplification of weight handling by centralizing it at the product level, and additions to payment and webhook handling in various modules

Reviewed Changes

Copilot reviewed 19 out of 22 changed files in this pull request and generated 1 comment.

Show a summary per file
File Description
readme.md Updated instructions for Docker setup and payment integrations (switching PayPal references to MobilePay)
internal/interfaces/api/server.go Added stripe webhook setup with conditional logging and new middleware integration (commented CORS code)
internal/interfaces/api/middleware/cors_middleware.go Introduced a CORS middleware implementation using configurable allowed origins
internal/interfaces/api/handler/webhook_handler.go Extended Stripe webhook event handling to include additional event types and record transactions
internal/interfaces/api/handler/product_handler.go Removed references to per-variant weight to enforce product-level weight usage
internal/interfaces/api/handler/order_handler.go Updated payment processing to use the guest email instead of the provided customer email for orders
internal/infrastructure/repository/* Modified queries and JSON unmarshaling logic to remove weight column from product variants
internal/infrastructure/payment/stripe_payment_service.go Upgraded Stripe library usage and refactored amount conversion, customer creation, and refund/capture logic
internal/infrastructure/container/middleware_provider.go Added provision for the new CORS middleware
config/config.go Extended configuration to support CORS settings and unified return URL handling
docker-compose.yml Added services and configuration for deploying the API, migration, and seeding tools in Docker
Files not reviewed (3)
  • .env.example: Language not supported
  • Dockerfile: Language not supported
  • go.mod: Language not supported
Comments suppressed due to low confidence (1)

internal/infrastructure/payment/stripe_payment_service.go:167

  • Ensure that 'request.Amount' is expressed in the smallest currency unit (e.g., cents) to align with Stripe's requirements, or add documentation to clarify the expected unit.
Amount: stripe.Int64(request.Amount),

@gustaavik gustaavik merged commit 3113358 into main May 5, 2025
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants