update urls
All checks were successful
Build and Publish / Metadata (push) Successful in 12s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 53s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m53s

This commit is contained in:
matst80
2025-11-11 13:32:31 +01:00
parent 756a43b342
commit cc6d48c879
2 changed files with 21 additions and 16 deletions

View File

@@ -140,13 +140,14 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux, invento
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)
return return
} }
if inventoryService != nil {
inventoryRequests := getInventoryRequests(grain.Items) inventoryRequests := getInventoryRequests(grain.Items)
err = inventoryService.ReserveInventory(inventoryRequests...) err = inventoryService.ReserveInventory(inventoryRequests...)
if err != nil { if err != nil {
logger.WarnContext(r.Context(), "placeorder inventory reservation failed") logger.WarnContext(r.Context(), "placeorder inventory reservation failed")
w.WriteHeader(http.StatusNotAcceptable) w.WriteHeader(http.StatusNotAcceptable)
return return
}
} }
w.WriteHeader(http.StatusOK) w.WriteHeader(http.StatusOK)

View File

@@ -323,6 +323,9 @@ func getLocationId(item *cart.CartItem) inventory.LocationID {
func getInventoryRequests(items []*cart.CartItem) []inventory.ReserveRequest { func getInventoryRequests(items []*cart.CartItem) []inventory.ReserveRequest {
var requests []inventory.ReserveRequest var requests []inventory.ReserveRequest
for _, item := range items { for _, item := range items {
if item == nil {
continue
}
requests = append(requests, inventory.ReserveRequest{ requests = append(requests, inventory.ReserveRequest{
SKU: inventory.SKU(item.Sku), SKU: inventory.SKU(item.Sku),
LocationID: getLocationId(item), LocationID: getLocationId(item),
@@ -338,8 +341,8 @@ func (s *PoolServer) CreateOrUpdateCheckout(ctx context.Context, host string, id
Terms: fmt.Sprintf("https://%s/terms", host), Terms: fmt.Sprintf("https://%s/terms", host),
Checkout: fmt.Sprintf("https://%s/checkout?order_id={checkout.order.id}", host), Checkout: fmt.Sprintf("https://%s/checkout?order_id={checkout.order.id}", host),
Confirmation: fmt.Sprintf("https://%s/confirmation/{checkout.order.id}", host), Confirmation: fmt.Sprintf("https://%s/confirmation/{checkout.order.id}", host),
Validation: fmt.Sprintf("https://%s/validate", host), Validation: "https://cart.tornberg.me/validate",
Push: fmt.Sprintf("https://%s/push?order_id={checkout.order.id}", host), Push: "https://cart.tornberg.me/push?order_id={checkout.order.id}",
Country: country, Country: country,
Currency: getCurrency(country), Currency: getCurrency(country),
Locale: getLocale(country), Locale: getLocale(country),
@@ -350,12 +353,13 @@ func (s *PoolServer) CreateOrUpdateCheckout(ctx context.Context, host string, id
if err != nil { if err != nil {
return nil, err return nil, err
} }
if s.inventoryService != nil {
inventoryRequests := getInventoryRequests(grain.Items) inventoryRequests := getInventoryRequests(grain.Items)
failingRequest, err := s.inventoryService.ReservationCheck(inventoryRequests...) failingRequest, err := s.inventoryService.ReservationCheck(inventoryRequests...)
if err != nil { if err != nil {
logger.WarnContext(ctx, "inventory check failed", string(failingRequest.SKU), string(failingRequest.LocationID)) logger.WarnContext(ctx, "inventory check failed", string(failingRequest.SKU), string(failingRequest.LocationID))
return nil, err return nil, err
}
} }
// Build pure checkout payload // Build pure checkout payload
@@ -581,7 +585,7 @@ func (s *PoolServer) CheckoutHandler(fn func(order *CheckoutOrder, w http.Respon
if orderId == "" { if orderId == "" {
order, err := s.CreateOrUpdateCheckout(r.Context(), r.Host, cartId) order, err := s.CreateOrUpdateCheckout(r.Context(), r.Host, cartId)
if err != nil { if err != nil {
logger.Error("unable to create klarna session", err) logger.Error("unable to create klarna session: %v", err)
return err return err
} }
s.ApplyCheckoutStarted(order, cartId) s.ApplyCheckoutStarted(order, cartId)