notification url
This commit is contained in:
@@ -14,6 +14,7 @@ type CheckoutMeta struct {
|
|||||||
Terms string
|
Terms string
|
||||||
Checkout string
|
Checkout string
|
||||||
Confirmation string
|
Confirmation string
|
||||||
|
Notification string
|
||||||
Validation string
|
Validation string
|
||||||
Push string
|
Push string
|
||||||
Country string
|
Country string
|
||||||
@@ -107,6 +108,7 @@ func BuildCheckoutOrderPayload(grain *cart.CartGrain, meta *CheckoutMeta) ([]byt
|
|||||||
Terms: meta.Terms,
|
Terms: meta.Terms,
|
||||||
Checkout: meta.Checkout,
|
Checkout: meta.Checkout,
|
||||||
Confirmation: meta.Confirmation,
|
Confirmation: meta.Confirmation,
|
||||||
|
Notification: meta.Notification,
|
||||||
Validation: meta.Validation,
|
Validation: meta.Validation,
|
||||||
Push: meta.Push,
|
Push: meta.Push,
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -102,6 +102,21 @@ func (a *App) HandleCheckoutRequests(amqpUrl string, mux *http.ServeMux) {
|
|||||||
w.WriteHeader(http.StatusOK)
|
w.WriteHeader(http.StatusOK)
|
||||||
fmt.Fprintf(w, tpl, order.HTMLSnippet)
|
fmt.Fprintf(w, tpl, order.HTMLSnippet)
|
||||||
})
|
})
|
||||||
|
mux.HandleFunc("/notification", func(w http.ResponseWriter, r *http.Request) {
|
||||||
|
log.Printf("Klarna order notification, method: %s", r.Method)
|
||||||
|
if r.Method != "POST" {
|
||||||
|
w.WriteHeader(http.StatusMethodNotAllowed)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
order := &CheckoutOrder{}
|
||||||
|
err := json.NewDecoder(r.Body).Decode(order)
|
||||||
|
if err != nil {
|
||||||
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
|
}
|
||||||
|
log.Printf("Klarna order notification: %s", order.ID)
|
||||||
|
|
||||||
|
w.WriteHeader(http.StatusOK)
|
||||||
|
})
|
||||||
mux.HandleFunc("POST /validate", func(w http.ResponseWriter, r *http.Request) {
|
mux.HandleFunc("POST /validate", func(w http.ResponseWriter, r *http.Request) {
|
||||||
log.Printf("Klarna order validation, method: %s", r.Method)
|
log.Printf("Klarna order validation, method: %s", r.Method)
|
||||||
if r.Method != "POST" {
|
if r.Method != "POST" {
|
||||||
|
|||||||
@@ -318,6 +318,7 @@ func (s *PoolServer) CreateOrUpdateCheckout(ctx context.Context, host string, id
|
|||||||
Confirmation: fmt.Sprintf("https://%s/confirmation/{checkout.order.id}", host),
|
Confirmation: fmt.Sprintf("https://%s/confirmation/{checkout.order.id}", host),
|
||||||
Validation: fmt.Sprintf("https://%s/validate", host),
|
Validation: fmt.Sprintf("https://%s/validate", host),
|
||||||
Push: fmt.Sprintf("https://%s/push?order_id={checkout.order.id}", host),
|
Push: fmt.Sprintf("https://%s/push?order_id={checkout.order.id}", host),
|
||||||
|
Notification: "https://cart.tornberg.me/notification",
|
||||||
Country: country,
|
Country: country,
|
||||||
Currency: getCurrency(country),
|
Currency: getCurrency(country),
|
||||||
Locale: getLocale(country),
|
Locale: getLocale(country),
|
||||||
|
|||||||
Reference in New Issue
Block a user