cart items
This commit is contained in:
@@ -756,16 +756,6 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
for _, notificationItem := range *notificationRequest.NotificationItems {
|
for _, notificationItem := range *notificationRequest.NotificationItems {
|
||||||
item := notificationItem.NotificationRequestItem
|
item := notificationItem.NotificationRequestItem
|
||||||
log.Printf("Recieved notification event code: %s, %v", item.EventCode, item)
|
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)
|
isValid := hmacvalidator.ValidateHmac(item, hmacKey)
|
||||||
if !isValid {
|
if !isValid {
|
||||||
@@ -774,8 +764,21 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
} else {
|
} else {
|
||||||
switch item.EventCode {
|
switch item.EventCode {
|
||||||
|
case "CAPTURE":
|
||||||
|
log.Printf("Capture status: %v", item.Success)
|
||||||
case "AUTHORISATION":
|
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))
|
grain, err := s.Get(r.Context(), uint64(cartId))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("Error getting cart: %v", err)
|
log.Printf("Error getting cart: %v", err)
|
||||||
@@ -804,6 +807,8 @@ func (s *PoolServer) AdyenHookHandler(w http.ResponseWriter, r *http.Request) {
|
|||||||
Status: item.EventCode,
|
Status: item.EventCode,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
default:
|
||||||
|
log.Printf("Unknown event code: %s", item.EventCode)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user