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

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