cart items
All checks were successful
Build and Publish / BuildAndDeployAmd64 (push) Successful in 36s
Build and Publish / BuildAndDeployArm64 (push) Successful in 4m37s

This commit is contained in:
matst80
2025-11-28 17:01:32 +01:00
parent aea2adcf92
commit e1072c5ba1

View File

@@ -756,16 +756,6 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
for _, notificationItem := range *notificationRequest.NotificationItems {
item := notificationItem.NotificationRequestItem
log.Printf("Recieved notification event code: %s, %v", item.EventCode, item)
cartId, ok := cart.ParseCartId(item.MerchantReference)
if !ok {
log.Printf("invalid cart id %s", item.MerchantReference)
http.Error(w, "Invalid cart id", http.StatusBadRequest)
return
}
if host, ok := s.OwnerHost(uint64(cartId)); ok {
cartHostMap[host] = append(cartHostMap[host], notificationItem)
continue
}
isValid := hmacvalidator.ValidateHmac(item, hmacKey)
if !isValid {
@@ -774,8 +764,21 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
return
} else {
switch item.EventCode {
case "CAPTURE":
log.Printf("Capture status: %v", item.Success)
case "AUTHORISATION":
cartId, ok := cart.ParseCartId(item.MerchantReference)
if !ok {
log.Printf("invalid cart id %s", item.MerchantReference)
http.Error(w, "Invalid cart id", http.StatusBadRequest)
return
}
if host, ok := s.OwnerHost(uint64(cartId)); ok {
cartHostMap[host] = append(cartHostMap[host], notificationItem)
continue
}
grain, err := s.Get(r.Context(), uint64(cartId))
if err != nil {
log.Printf("Error getting cart: %v", err)
@@ -804,6 +807,8 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
Status: item.EventCode,
})
}
default:
log.Printf("Unknown event code: %s", item.EventCode)
}
}
}