more logs
Some checks failed
Build and Publish / Metadata (push) Successful in 13s
Build and Publish / BuildAndDeployAmd64 (push) Successful in 52s
Build and Publish / BuildAndDeployArm64 (push) Has been cancelled

This commit is contained in:
2025-11-13 18:34:25 +01:00
parent 67c9b2a7df
commit a0f5ae0c61
3 changed files with 7 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux, invento
orderId := r.URL.Query().Get("order_id") orderId := r.URL.Query().Get("order_id")
log.Printf("Order confirmation push: %s", orderId) log.Printf("Order confirmation push: %s", orderId)
order, err := a.klarnaClient.GetOrder(orderId) order, err := a.klarnaClient.GetOrder(r.Context(), orderId)
if err != nil { if err != nil {
log.Printf("Error creating request: %v\n", err) log.Printf("Error creating request: %v\n", err)
@@ -105,7 +105,7 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux, invento
mux.HandleFunc("GET /confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) { mux.HandleFunc("GET /confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) {
orderId := r.PathValue("order_id") orderId := r.PathValue("order_id")
order, err := a.klarnaClient.GetOrder(orderId) order, err := a.klarnaClient.GetOrder(r.Context(), orderId)
if err != nil { if err != nil {
w.WriteHeader(http.StatusInternalServerError) w.WriteHeader(http.StatusInternalServerError)

View File

@@ -31,11 +31,14 @@ const (
KlarnaPlaygroundUrl = "https://api.playground.klarna.com" KlarnaPlaygroundUrl = "https://api.playground.klarna.com"
) )
func (k *KlarnaClient) GetOrder(orderId string) (*CheckoutOrder, error) { func (k *KlarnaClient) GetOrder(ctx context.Context, orderId string) (*CheckoutOrder, error) {
req, err := http.NewRequest("GET", k.Url+"/checkout/v3/orders/"+orderId, nil) req, err := http.NewRequest("GET", k.Url+"/checkout/v3/orders/"+orderId, nil)
if err != nil { if err != nil {
return nil, err return nil, err
} }
spanCtx, span := tracer.Start(ctx, "Get klarna order")
defer span.End()
req = req.WithContext(spanCtx)
req.Header.Add("Content-Type", "application/json") req.Header.Add("Content-Type", "application/json")
req.SetBasicAuth(k.UserName, k.Password) req.SetBasicAuth(k.UserName, k.Password)

View File

@@ -592,7 +592,7 @@ func (s *PoolServer) CheckoutHandler(fn func(order *CheckoutOrder, w http.Respon
s.ApplyCheckoutStarted(order, cartId) s.ApplyCheckoutStarted(order, cartId)
return fn(order, w) return fn(order, w)
} }
order, err := s.klarnaClient.GetOrder(orderId) order, err := s.klarnaClient.GetOrder(r.Context(), orderId)
if err != nil { if err != nil {
return err return err
} }