more logs
This commit is contained in:
@@ -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)
|
||||||
|
|||||||
@@ -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)
|
||||||
|
|
||||||
|
|||||||
@@ -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
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user