show klarna body on error
Some checks failed
Build and Publish / BuildAndDeploy (push) Successful in 3m10s
Build and Publish / BuildAndDeployAmd64 (push) Has been cancelled

This commit is contained in:
matst80
2025-05-13 08:41:15 +02:00
parent 0f55b86bfd
commit 954d23df63

View File

@@ -4,6 +4,7 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"log"
"net/http" "net/http"
) )
@@ -48,6 +49,11 @@ func (k *KlarnaClient) GetOrder(orderId string) (*CheckoutOrder, error) {
} }
return &klarnaOrderResponse, nil return &klarnaOrderResponse, nil
} }
body, err := io.ReadAll(res.Body)
if err == nil {
log.Println(string(body))
}
return nil, fmt.Errorf(res.Status) return nil, fmt.Errorf(res.Status)
} }
@@ -71,6 +77,10 @@ func (k *KlarnaClient) CreateOrder(reader io.Reader) (*CheckoutOrder, error) {
err = json.NewDecoder(res.Body).Decode(&klarnaOrderResponse) err = json.NewDecoder(res.Body).Decode(&klarnaOrderResponse)
return &klarnaOrderResponse, err return &klarnaOrderResponse, err
} }
body, err := io.ReadAll(res.Body)
if err == nil {
log.Println(string(body))
}
return nil, fmt.Errorf(res.Status) return nil, fmt.Errorf(res.Status)
} }
@@ -94,6 +104,10 @@ func (k *KlarnaClient) UpdateOrder(orderId string, reader io.Reader) (*CheckoutO
err = json.NewDecoder(res.Body).Decode(&klarnaOrderResponse) err = json.NewDecoder(res.Body).Decode(&klarnaOrderResponse)
return &klarnaOrderResponse, err return &klarnaOrderResponse, err
} }
body, err := io.ReadAll(res.Body)
if err == nil {
log.Println(string(body))
}
return nil, fmt.Errorf(res.Status) return nil, fmt.Errorf(res.Status)
} }