Add product features, Heleket crypto payments and order status icons.

This commit is contained in:
shop
2026-06-27 16:29:33 +03:00
parent 361d35e6b4
commit 98a0bb01e2
31 changed files with 1673 additions and 126 deletions
+24 -3
View File
@@ -13,6 +13,7 @@ import (
"shop/internal/config"
"shop/internal/database"
"shop/internal/handlers"
"shop/internal/heleket"
"shop/internal/middleware"
"shop/internal/repository"
"shop/internal/upload"
@@ -41,6 +42,9 @@ func main() {
cartRepo := repository.NewCartRepository(pool)
orderRepo := repository.NewOrderRepository(pool)
priceHistoryRepo := repository.NewPriceHistoryRepository(pool)
reservationRepo := repository.NewReservationRepository(pool)
storage, err := upload.NewStorage(cfg.UploadDir)
if err != nil {
log.Fatalf("upload storage: %v", err)
@@ -61,12 +65,21 @@ func main() {
adminSession := auth.NewSession(cfg.SessionSecret, "shop_admin_session", "/admin")
userSession := auth.NewSession(cfg.SessionSecret, "shop_user_session", "/")
cartSession := auth.NewSession(cfg.SessionSecret, "shop_cart_key", "/")
compareSession := auth.NewSession(cfg.SessionSecret, "shop_compare", "/")
heleketClient := heleket.NewClient(cfg.HeleketMerchantID, cfg.HeleketPaymentAPIKey)
if heleketClient.Enabled() {
log.Printf("heleket payments enabled (currency: %s)", cfg.HeleketCurrency)
}
customer := handlers.NewCustomerHandler(
productRepo, categoryRepo, userRepo, cartRepo, orderRepo, statsRepo,
userSession, cartSession, tmpl,
productRepo, categoryRepo, userRepo, cartRepo, orderRepo,
priceHistoryRepo, reservationRepo, statsRepo,
userSession, cartSession, compareSession,
heleketClient, cfg.HeleketPaymentAPIKey, cfg.PublicBaseURL, cfg.HeleketCurrency,
tmpl,
)
admin := handlers.NewAdminHandler(adminRepo, productRepo, categoryRepo, orderRepo, statsRepo, storage, adminSession, tmpl)
admin := handlers.NewAdminHandler(adminRepo, productRepo, categoryRepo, orderRepo, priceHistoryRepo, statsRepo, storage, adminSession, tmpl)
mux := http.NewServeMux()
mux.Handle("GET /static/", http.StripPrefix("/static/", handlers.StaticHandler()))
@@ -75,6 +88,11 @@ func main() {
mux.HandleFunc("GET /{$}", customer.Home)
mux.HandleFunc("GET /product/{id}", customer.ProductPage)
mux.HandleFunc("POST /product/{id}/reserve", customer.ProductReserve)
mux.HandleFunc("POST /buy", customer.BuyNow)
mux.HandleFunc("GET /compare", customer.ComparePage)
mux.HandleFunc("POST /compare/add", customer.CompareAdd)
mux.HandleFunc("POST /compare/remove", customer.CompareRemove)
mux.HandleFunc("GET /category/{slug}", customer.CategoryPage)
mux.HandleFunc("GET /register", customer.RegisterPage)
mux.HandleFunc("POST /register", customer.Register)
@@ -87,6 +105,9 @@ func main() {
mux.HandleFunc("POST /cart/remove", customer.CartRemove)
mux.HandleFunc("GET /checkout", customer.CheckoutPage)
mux.HandleFunc("POST /checkout", customer.Checkout)
mux.HandleFunc("GET /order/{id}/success", customer.OrderSuccess)
mux.HandleFunc("GET /order/{id}/pay", customer.OrderPay)
mux.HandleFunc("POST /webhooks/heleket", customer.HeleketWebhook)
mux.HandleFunc("GET /account", customer.Account)
mux.HandleFunc("POST /account", customer.Account)