diff --git a/main.go b/main.go
index 5447be8..b6d07f6 100644
--- a/main.go
+++ b/main.go
@@ -89,6 +89,7 @@ func main() {
http.HandleFunc("/lastmetrics", lastmetricsHandler)
http.HandleFunc("/save_scale_settings", save_scale_settingsHandler)
http.HandleFunc("/getstripesession", getstripesessionHandler)
+ http.HandleFunc("/getstripepaymentintent", getstripepaymentintentHandler)
http.HandleFunc("/stripewebhook", stripeWebhookHandler)
logit("Starting Web Application...")
diff --git a/snippets/checkout.html b/snippets/checkout.html
new file mode 100644
index 0000000..c71ab06
--- /dev/null
+++ b/snippets/checkout.html
@@ -0,0 +1,102 @@
+{{define "header_additions"}}
+
+{{end}}
+{{define "body_content"}}
+
Checkout
+
+0002CC01000003F7:2
+
+
+
+
+
+
+
+
+
+
+
+{{end}}
diff --git a/snippets/scales.html b/snippets/scales.html
index d149bf0..ab0376e 100644
--- a/snippets/scales.html
+++ b/snippets/scales.html
@@ -1,3 +1,6 @@
+{{define "header_additions"}}
+
+{{end}}
{{define "body_content"}}
{{ if ne .UserName "" }}
@@ -56,10 +59,21 @@ Device ID:
Abo verlängern
0
-
-
+
@@ -185,7 +199,6 @@ $(".show-modal").click(function() {
});
$("#cart-close").click(function() {
- console.log("blabla");
$("#cart").removeClass("is-active");
});
@@ -334,20 +347,37 @@ $("#modal-save").click(function() {
});
-
-
-
-
-
diff --git a/static/css/mini-beieli-web-custom.css b/static/css/mini-beieli-web-custom.css
index 85831a8..0efc1ea 100644
--- a/static/css/mini-beieli-web-custom.css
+++ b/static/css/mini-beieli-web-custom.css
@@ -41,3 +41,35 @@ hr {
.apexcharts-legend {
font-family: "Rubik", sans-serif;
}
+
+/**
+ * * The CSS shown here will not be introduced in the Quickstart guide, but
+ * * shows how you can use CSS to style your Element's container.
+ * */
+input,
+.StripeElement {
+ height: 40px;
+ padding: 10px 12px;
+
+ color: #32325d;
+ background-color: white;
+ border: 1px solid transparent;
+ border-radius: 4px;
+
+ box-shadow: 0 1px 3px 0 #e6ebf1;
+ -webkit-transition: box-shadow 150ms ease;
+ transition: box-shadow 150ms ease;
+}
+
+input:focus,
+.StripeElement--focus {
+ box-shadow: 0 1px 3px 0 #cfd7df;
+}
+
+.StripeElement--invalid {
+ border-color: #fa755a;
+}
+
+.StripeElement--webkit-autofill {
+ background-color: #fefde5 !important;
+}
diff --git a/stripe.go b/stripe.go
index 8619d82..ea81f46 100644
--- a/stripe.go
+++ b/stripe.go
@@ -11,6 +11,7 @@ import (
"strconv"
"github.com/stripe/stripe-go"
"github.com/stripe/stripe-go/checkout/session"
+ "github.com/stripe/stripe-go/paymentintent"
"github.com/stripe/stripe-go/webhook"
)
@@ -18,6 +19,52 @@ func getStripeKey() string {
return "sk_test_GJbXPD0IAFNvvGpNEpaeDfhl"
}
+func getstripepaymentintentHandler(response http.ResponseWriter, request *http.Request) {
+ name := getUserName(request)
+ if name != "" {
+
+ charge_data, ok := request.URL.Query()["charge_data"]
+ if !ok || len(charge_data[0]) < 1 {
+ log.Println("Url Param 'charge_data' is missing")
+ fmt.Fprintf(response, "{ \"rc\": 1, \"msg\": \"charge_data must be specified in URL\" }")
+ return
+ }
+
+ scales := strings.Split(charge_data[0],",")
+
+ var abo_years = 0
+ var items []string
+ for _,scale := range scales {
+ items = strings.Split(scale,":")
+ if (len(items) == 2) {
+ abo_count, err := strconv.Atoi(items[1])
+ if err == nil {
+ abo_years += abo_count
+ }
+ }
+ }
+ abo_amount := int64(abo_years * 2400)
+
+ stripe.Key = getStripeKey()
+
+ params := &stripe.PaymentIntentParams{
+ Amount: stripe.Int64(abo_amount),
+ Currency: stripe.String(string(stripe.CurrencyCHF)),
+ ReceiptEmail: stripe.String(name),
+ }
+ paymentintent, err := paymentintent.New(params)
+
+ if err != nil {
+ fmt.Fprintf(response,"{ \"rc\": 5, \"stripeclientsecret\": \"%s\" }\n",err)
+ } else {
+ fmt.Fprintf(response,"{ \"rc\": 0, \"stripeclientsecret\": \"%s\" }\n",paymentintent.ClientSecret)
+ }
+
+ } else {
+ fmt.Fprintf(response, "{ \"rc\": 6, \"msg\": \"Only available for logged in users\" }")
+ }
+}
+
func getstripesessionHandler(response http.ResponseWriter, request *http.Request) {
name := getUserName(request)
if name != "" {