From 79fc990a98b05b3c3f58a21eb06faa5ffb4aeb6a Mon Sep 17 00:00:00 2001 From: matst80 Date: Tue, 13 May 2025 18:08:00 +0200 Subject: [PATCH] test checkout and confirmation as webpages --- main.go | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) 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 {