diff --git a/main.go b/main.go index 9199667..2b90894 100644 --- a/main.go +++ b/main.go @@ -242,6 +242,27 @@ func main() { log.Printf("Error executing template: %v\n", err) } }) + mux.HandleFunc("/confirmation/{order_id}", func(w http.ResponseWriter, r *http.Request) { + + orderId := r.PathValue("order_id") + order, err := KlarnaInstance.GetOrder(orderId) + + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(err.Error())) + return + } + + t, err := template.New("confirmation").Parse(tpl) + if err != nil { + w.WriteHeader(http.StatusInternalServerError) + w.Write([]byte(err.Error())) + } + err = t.Execute(w, &order) + if err != nil { + log.Printf("Error executing template: %v\n", err) + } + }) mux.HandleFunc("/push", func(w http.ResponseWriter, r *http.Request) { if r.Method != http.MethodPost {