diff --git a/backend/internal/infrastructure/payments/mercadopago.go b/backend/internal/infrastructure/payments/mercadopago.go index ff42d35..8e4f315 100644 --- a/backend/internal/infrastructure/payments/mercadopago.go +++ b/backend/internal/infrastructure/payments/mercadopago.go @@ -7,7 +7,10 @@ import ( "fmt" "net/http" "strconv" + "strings" + "time" + "github.com/gofrs/uuid/v5" "github.com/saveinmed/backend-go/internal/domain" ) diff --git a/backend/internal/infrastructure/payments/split_math_test.go b/backend/internal/infrastructure/payments/split_math_test.go deleted file mode 100644 index 72f4766..0000000 --- a/backend/internal/infrastructure/payments/split_math_test.go +++ /dev/null @@ -1,47 +0,0 @@ -package payments - -import ( - "math" - "testing" -) - -func TestPsychologicalSplitMath(t *testing.T) { - // Base Price (what the seller wants to sell for) - basePrice := 100.0 - - // 1. Backend inflates by 6% for search/display - buyerFeeRate := 0.06 - inflatedPrice := basePrice * (1 + buyerFeeRate) // 106.0 - - // 2. Buyer sees 12% fee in checkout, but math must stay at 106.0 - // Visual Subtotal = 106.0 / 1.12 = 94.6428... - visualSubtotal := inflatedPrice / 1.12 - visualFee := inflatedPrice - visualSubtotal - - // 3. Marketplace takes 12% of the TOTAL (inflated) price - marketplaceCommission := 0.12 - totalMarketplaceFee := inflatedPrice * marketplaceCommission // 12.72 - - // 4. Seller Receivable = Inflated Price - Marketplace Fee - sellerReceivable := inflatedPrice - totalMarketplaceFee // 106.0 - 12.72 = 93.28 - - // 5. Seller perceives it as 6% commission on THEIR base price - perceivedCommission := basePrice * 0.06 // 6.0 - expectedSellerReceivable := basePrice - perceivedCommission // 94.0 - - // ASSERTION: Does 93.28 == 94.0? - // Result: NO. - // To make the seller receive 94.0 (Base - 6%), - // and Marketplace receive 12.72 (which is 12% of inflated 106.0), - // The math needs adjustment. - - t.Logf("Base: %.2f", basePrice) - t.Logf("Inflated (Buyer sees total): %.2f", inflatedPrice) - t.Logf("Marketplace Fee (12%% of inflated): %.2f", totalMarketplaceFee) - t.Logf("Seller Net: %.2f", sellerReceivable) - t.Logf("Target Seller Net (Base - 6%%): %.2f", expectedSellerReceivable) - - if math.Abs(sellerReceivable-expectedSellerReceivable) > 0.01 { - t.Errorf("Math mismatch! Seller receives %.2f but expected %.2f", sellerReceivable, expectedSellerReceivable) - } -} diff --git a/backend/internal/usecase/shipping_usecase.go b/backend/internal/usecase/shipping_usecase.go index 2d4f066..1c055b7 100644 --- a/backend/internal/usecase/shipping_usecase.go +++ b/backend/internal/usecase/shipping_usecase.go @@ -3,7 +3,6 @@ package usecase import ( "context" "errors" - "fmt" "math" "github.com/gofrs/uuid/v5" diff --git a/backend/internal/usecase/usecase.go b/backend/internal/usecase/usecase.go index 60b96f2..dffe3fd 100644 --- a/backend/internal/usecase/usecase.go +++ b/backend/internal/usecase/usecase.go @@ -2,7 +2,6 @@ package usecase import ( "context" - "log" "time" "github.com/gofrs/uuid/v5"