-
Notifications
You must be signed in to change notification settings - Fork 0
Almost complete project rewrite #44
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
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Added product_variant_id to cart_items for variant support. - Implemented currency support with currencies, product_prices, and product_variant_prices tables. - Updated order schema to include customer details and payment status. - Introduced checkout and checkout_items tables to replace cart functionality. - Enforced product variants requirement and added constraints for unique category names. - Improved product deletion logic and ensured correct has_variants field values. - Added checkout_session_id to orders for linking to checkout sessions. - Fixed currency exchange rates to reflect accurate values. - Added unique constraints to shipping rates to prevent duplicates.
…nts, orders, products, shipping, and users - Implemented Create and Update requests for categories, checkouts, currencies, discounts, orders, products, and shipping methods. - Added response structures for various operations including listing and retrieving entities. - Introduced pagination and response DTOs for consistent API responses. - Updated product handler to utilize new variant attributes structure. - Refactored server initialization to use GORM instead of SQL package. - Enhanced mock currency repository to align with new entity structures.
…tamp management and improve relationships - Updated Currency, Discount, Order, Product, ProductVariant, ShippingMethod, ShippingRate, ShippingZone, User, and Webhook entities to embed gorm.Model for automatic ID and timestamp handling. - Removed manual timestamp management in various methods across entities. - Enhanced relationships between entities, including foreign key constraints and cascading behaviors. - Introduced new methods for updating product variants and added price handling in ProductVariant. - Added new repository methods for fetching products by SKU and ID with currency consideration. - Updated API contracts to include prices in variant requests.
…e management and enhance currency handling
refactor: update config to remove PayPal settings and add DB_DRIVER chore: add local docker-compose for SQLite development chore: update main docker-compose for PostgreSQL configuration docs: create DATABASE_SETUP.md for database configuration instructions chore: update go.mod and go.sum for GORM and database drivers refactor: simplify currency and product price entities refactor: remove product price repository and related methods refactor: enhance GORM initialization for SQLite and PostgreSQL docs: update README for database setup and commands
…response DTOs - Updated shipping_handler.go to replace dto with contracts for shipping options, methods, and rates. - Removed unused shipping methods and routes in server.go. - Refactored user_handler.go to utilize contracts for user registration and login responses. - Simplified response creation in user registration and login by using new response functions. - Cleaned up commented-out code for shipping methods and rates in server routes.
- Refactored PaymentTransactionRepository to TransactionRepository and updated method names. - Added CategoryRepository for managing categories. - Introduced CheckoutRepository for handling checkout operations. - Created CurrencyRepository for currency management. - Added DiscountRepository for managing discounts. - Implemented OrderRepository for order-related operations. - Developed ProductRepository for product management with variants. - Created ProductVariantRepository for handling product variants. - Added UserRepository for user management.
…zones, and webhooks
…-related migrations - Deleted migrations for currency support, order customer details, product active status, default currency, cart tables, and checkout tables. - Removed constraints and indexes related to legacy cart and checkout functionality. - Cleaned up migrations for ensuring product variants and added unique constraints for shipping methods and categories. - Updated migrations for adding currency and payment status to orders, including necessary indexes and data updates. - Improved product deletion logic by removing unnecessary triggers and relying on application-level enforcement.
…ent provider configurations
…n webhook handlers
… transactions for various events
- Added a mock logger implementation to facilitate logging in tests. - Created mock repositories for PaymentProvider, PaymentTransaction, Order, and Product to simulate database interactions. - Developed a mock payment provider service to handle payment provider operations in tests. - Implemented comprehensive test cases for each mock service to ensure expected behavior and error handling.
…ntities - Implement tests for PaymentProvider including validation, methods, and constants. - Add tests for PaymentTransaction covering creation, validation, metadata, and status updates. - Create tests for Product and ProductVariant with focus on creation, validation, and variant management. - Introduce tests for User entity covering creation, password management, and role validation. - Ensure comprehensive coverage for all new functionalities and edge cases.
…Product, Shipping Method, Rate, and Zone
…orders, and discounts - Implemented user seeding with role assignment and existence check. - Added category seeding with hierarchical relationships. - Enhanced product seeding to include variants and category mapping. - Introduced order seeding with user and product variant associations. - Added discount seeding with various types and constraints. - Implemented shipping methods and zones seeding. - Enhanced payment transaction seeding for completed orders. - Improved checkout seeding with session management and item tracking. - Updated clearData function to use DELETE for SQLite compatibility.
… generation for UUID
…, currencies, shipping, and users - Implemented CategoryDTO for category representation. - Created CheckoutDTO and related structures for checkout sessions. - Added OrderDTO and OrderItemDTO for order management. - Introduced ProductDTO and VariantDTO for product details. - Developed DiscountDTO and AppliedDiscountDTO for discount handling. - Established CurrencyDTO for currency representation. - Created Shipping-related DTOs including ShippingMethodDetailDTO, ShippingZoneDTO, and ShippingRateDTO. - Implemented UserDTO for user management. - Generated TypeScript contracts for API interactions.
- Updated import paths for DTOs in various entity files to use the new location under internal/domain/dto. - Removed old DTO files from internal/interfaces/api/contracts/dto as they have been migrated to internal/domain/dto. - Added new DTO definitions for Category, Checkout, Common, Currency, Discount, Order, Product, Shipping, and User in the internal/domain/dto directory. - Updated related contract files to reference the new DTOs. - Cleaned up the readme and removed the todo file.
…cy across entities
…ptions and applied discounts
…scounts - Updated Checkout and Order entities to store shipping and billing addresses as JSON. - Introduced helper methods for setting and getting addresses and discounts in JSON format. - Modified checkout and order processing logic to utilize new JSON methods for address and discount handling. - Adjusted related use cases and repositories to accommodate changes in address storage. - Enhanced webhook handling to allow requests without an Origin header. - Separated webhook routes from main API routes for better organization and security.
… update PaymentTransaction to use it for metadata
…ance checkout currency handling
…iders Migration cleanup payment providers
…est order representation
…for improved performance
…d improved workflow tests
- Updated PaymentTransaction to allow multiple transactions per order type, enhancing support for partial captures and retries.
- Changed Metadata field in PaymentTransaction from common.StringMap to gorm.io/datatypes.JSONMap for better JSON handling.
- Modified Product entity to use gorm.io/datatypes.JSONSlice for Images, replacing common.StringSlice.
- Refactored ProductVariant to utilize gorm.io/datatypes for Attributes and Images, improving JSON storage.
- Implemented CreateOrUpdate method in PaymentTransactionRepository for upsert behavior, ensuring only one transaction per type per order.
- Updated payment provider service to accept map[string]interface{} for configuration, replacing common.JSONB.
- Enhanced repository methods to support JSON queries in a database-agnostic manner.
- Removed unused VariantAttributes struct and its associated methods from ProductVariant.
- Updated tests to reflect changes in transaction handling and repository methods.
…saction repository, and product repository - Deleted the mock PaymentProviderService implementation used for testing payment provider functionalities. - Removed the mock PaymentTransactionRepository implementation that handled payment transaction operations. - Eliminated the mock ProductRepository implementation responsible for product management in tests.
…der methods handling
… tracking - Added idempotency key handling in MobilePay webhook events to prevent duplicate transactions. - Implemented checks for existing transactions before recording new ones for authorization, capture, cancellation, expiration, and refund events. - Introduced new tests for idempotency logic in MobilePay webhook handler. - Enhanced transaction amount tracking in tests, ensuring accurate sums for authorized, captured, and refunded amounts. - Updated Stripe webhook handler to include a placeholder for idempotency key.
Cleanup whole lotta shit
…rove error messages in product handler
Migrations cleanup and payment rewrite
…and error handling
…nd detailed transaction handling
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces significant changes to the database configuration, development environment setup, and codebase structure. The most notable updates include transitioning from PostgreSQL to SQLite for local development, removing migration-related functionality, and simplifying database initialization across the application. Additionally, PayPal support has been removed, and new development commands have been added to the
Makefile.Database Configuration and Environment Updates:
.env.example: Switched local development database configuration from PostgreSQL to SQLite, added debug mode, and clarified production setup instructions. RemovedMOBILEPAY_MARKETsetting. [1] [2]config/config.go: AddedDriverandDebugfields toDatabaseConfig, updatedLoadConfigto support SQLite, and removed PayPal-specific configuration and logic. [1] [2] [3]Development Workflow Enhancements:
Makefile: Added SQLite-specific commands (dev-sqlite,run-docker-sqlite, etc.), removed migration-related commands (migrate-up,migrate-down, etc.), and updateddev-setupto focus on seeding data for PostgreSQL. [1] [2] [3] [4]Codebase Simplification:
cmd/migrate/main.goandcmd/recover/main.go, eliminating migration and checkout recovery functionality. [1] [2]cmd/api/main.goandcmd/expire-checkouts/main.goto use a unifiedInitDBmethod. [1] [2]Dockerfile Adjustments:
Dockerfile: Removed migration-related binaries and files (commercify-migrateand/app/migrations) from the build and final image. [1] [2]Miscellaneous:
cmd/test-db/main.gofor testing database connections and basic operations.