Skip to content

Conversation

@gustaavik
Copy link
Member

This pull request introduces several updates across multiple files to improve functionality, simplify code, and remove redundant logic. Key changes include removing the MOBILEPAY_MARKET configuration, refactoring JSON-based methods for setting addresses and discounts, adding support for partial refunds, and introducing error handling for checkout and order creation processes.

Configuration Changes:

  • Removed MOBILEPAY_MARKET from MobilePayConfig and .env.example, simplifying MobilePay settings. [1] [2] [3]

Refactoring JSON-based Methods:

  • Replaced JSON-based methods (SetShippingAddressJSON, SetBillingAddressJSON) with direct methods (SetShippingAddress, SetBillingAddress) in cmd/seed/main.go for orders and checkouts. [1] [2] [3]
  • Updated discount application logic to rely on standard entity methods instead of custom JSON-based calculations.

Payment Processing Enhancements:

  • Added support for partial refunds by introducing checks for captured and refunded amounts and ensuring refunds do not exceed the remaining refundable amount. [1] [2] [3]
  • Added an idempotency key parameter to payment transaction creation methods for better transaction handling. [1] [2] [3] [4] [5]

Error Handling Improvements:

  • Improved error handling in CreateOrderFromCheckout by validating checkout conversion and handling errors during order creation.
  • Added checks to prevent redundant discount removal operations in RemoveDiscountFromOrder.

Dependency Updates:

  • Added new indirect dependencies (filippo.io/edwards25519, gorm.io/datatypes, gorm.io/driver/mysql) to go.mod for enhanced functionality. [1] [2]

gustaavik added 5 commits July 2, 2025 15:55
- 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.
… 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.
@gustaavik gustaavik merged commit 8605935 into migrations-cleanup2 Jul 2, 2025
@gustaavik gustaavik deleted the cleanup-whole-lotta-shit branch July 2, 2025 22:21
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