polish
This commit is contained in:
parent
6963a88602
commit
e7570a4c20
11 changed files with 138 additions and 5 deletions
|
|
@ -97,6 +97,9 @@ func startCheckout(w http.ResponseWriter, r *http.Request, o order) {
|
|||
id := newOrderID()
|
||||
log.Println("ORDER_PENDING", id, o)
|
||||
|
||||
url := r.URL.RequestURI()
|
||||
log.Println(url)
|
||||
|
||||
s, err := session.New(&stripe.CheckoutSessionParams{
|
||||
Mode: stripe.String("payment"),
|
||||
ClientReferenceID: stripe.String(id),
|
||||
|
|
@ -111,12 +114,12 @@ func startCheckout(w http.ResponseWriter, r *http.Request, o order) {
|
|||
},
|
||||
},
|
||||
}},
|
||||
SuccessURL: stripe.String("https://piekarnikgosi.pl/dziekujemy"),
|
||||
SuccessURL: stripe.String("https://piekarnikgosi.pl/dziekujemy?order=" + id),
|
||||
CancelURL: stripe.String("https://piekarnikgosi.pl/"),
|
||||
})
|
||||
if err != nil {
|
||||
log.Println("ORDER_STRIPE_ERROR", id, err)
|
||||
http.Error(w, "payment error", http.StatusInternalServerError)
|
||||
writeErrors(w, r, http.StatusInternalServerError, "Nie udało się przejść do płatności. Spróbuj ponownie lub zadzwoń: 690 214 515.")
|
||||
return
|
||||
}
|
||||
if r.Header.Get("HX-Request") == "true" {
|
||||
|
|
@ -128,10 +131,15 @@ func startCheckout(w http.ResponseWriter, r *http.Request, o order) {
|
|||
}
|
||||
|
||||
func OrderHandler(w http.ResponseWriter, r *http.Request) {
|
||||
r.Body = http.MaxBytesReader(w, r.Body, 16<<10)
|
||||
if err := r.ParseForm(); err != nil {
|
||||
writeErrors(w, r, http.StatusRequestEntityTooLarge, "Formularz jest nieprawidłowy.")
|
||||
return
|
||||
}
|
||||
o, err := parseOrder(r)
|
||||
if err != nil {
|
||||
log.Println("ORDER_INVALID", o, err)
|
||||
http.Error(w, err.Error(), http.StatusBadRequest)
|
||||
writeErrors(w, r, http.StatusUnprocessableEntity, errorMessages(err)...)
|
||||
return
|
||||
}
|
||||
startCheckout(w, r, o)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue