Compare commits
13
Commits
6fe448e3e2
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
7f639bca49 | ||
|
|
483d10799d | ||
|
|
8e3721da89 | ||
|
|
a297b127e1 | ||
|
|
8838103f2d | ||
|
|
0931ecb0f4 | ||
|
|
40134ceba9 | ||
|
|
6364bedb29 | ||
|
|
97d2bb2593 | ||
|
|
570de60338 | ||
|
|
c6f98415e3 | ||
|
|
0520b1eb02 | ||
|
|
1f1e34e213 |
@@ -4,6 +4,8 @@ ADD go.mod .
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN go build
|
RUN go build
|
||||||
FROM alpine
|
FROM alpine
|
||||||
|
RUN apk add --no-cache tzdata
|
||||||
|
ENV TZ=Europe/Zurich
|
||||||
WORKDIR /build
|
WORKDIR /build
|
||||||
RUN apk add --no-cache tzdata
|
RUN apk add --no-cache tzdata
|
||||||
COPY --from=builder /build/wo-bisch-web /build/wo-bisch-web
|
COPY --from=builder /build/wo-bisch-web /build/wo-bisch-web
|
||||||
|
|||||||
@@ -45,3 +45,23 @@ show range of last values:
|
|||||||
Autor: Joerg Lehmann, nbit Informatik GmbH
|
Autor: Joerg Lehmann, nbit Informatik GmbH
|
||||||
|
|
||||||
|
|
||||||
|
### Influxdb Commands
|
||||||
|
|
||||||
|
```
|
||||||
|
Show tokens
|
||||||
|
# influx auth ls
|
||||||
|
|
||||||
|
Clone Admin Token in Webgui if not known anymore and use this to get all tokens:
|
||||||
|
|
||||||
|
Create Default Config:
|
||||||
|
# influx config create --config-name default --token XXXXXXXXXXX --host-url http://127.0.0.1:8086 -a
|
||||||
|
|
||||||
|
Update Token in Default Config:
|
||||||
|
# influx config update --config-name default --token XXXXXXXXXXX
|
||||||
|
|
||||||
|
Backup Influxdb:
|
||||||
|
# influx backup /root/joergs-backup -t XXXXXadmintokenXXXXX
|
||||||
|
|
||||||
|
Restore Influxdb:
|
||||||
|
# influx restore /var/lib/influxdb2/joergs-backup/ --full
|
||||||
|
```
|
||||||
|
|||||||
+3
-1
@@ -12,6 +12,7 @@ func sendEmailAccu(username string, alias string, deveui string, accu_percent st
|
|||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: info@wo-bisch.ch
|
From: info@wo-bisch.ch
|
||||||
Subject: ` + level + ` - wo-bisch.ch: Akku Ladezustand (` + alias + `)
|
Subject: ` + level + ` - wo-bisch.ch: Akku Ladezustand (` + alias + `)
|
||||||
|
Content-Type: text/plain; charset="UTF-8"
|
||||||
|
|
||||||
Lieber Benutzer von wo-bisch.ch
|
Lieber Benutzer von wo-bisch.ch
|
||||||
|
|
||||||
@@ -38,12 +39,13 @@ func sendEmailAbo(username string, alias string, deveui string, days_left int, l
|
|||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: info@wo-bisch.ch
|
From: info@wo-bisch.ch
|
||||||
Subject: ` + level + ` - wo-bisch.ch: Abo verlaengern (` + alias + `)
|
Subject: ` + level + ` - wo-bisch.ch: Abo verlaengern (` + alias + `)
|
||||||
|
Content-Type: text/plain; charset="UTF-8"
|
||||||
|
|
||||||
Lieber Benutzer von wo-bisch.ch
|
Lieber Benutzer von wo-bisch.ch
|
||||||
|
|
||||||
` + ablauftext + `
|
` + ablauftext + `
|
||||||
|
|
||||||
Bitte Abo verlaengern auf https://wo-bisch.ch
|
Bitte Abo verlängern auf https://wo-bisch.ch
|
||||||
|
|
||||||
Mit freundlichen Grüssen
|
Mit freundlichen Grüssen
|
||||||
--
|
--
|
||||||
|
|||||||
@@ -1,11 +1,10 @@
|
|||||||
module nbit.ch/wo-bisch-web/v2
|
module nbit.ch/wo-bisch-web/v2
|
||||||
|
|
||||||
go 1.14
|
go 1.17
|
||||||
|
|
||||||
require (
|
require (
|
||||||
github.com/gomodule/redigo v1.8.4
|
github.com/gomodule/redigo v1.8.4
|
||||||
github.com/gorilla/securecookie v1.1.1
|
github.com/gorilla/securecookie v1.1.1
|
||||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible
|
github.com/stripe/stripe-go/v74 v74.7.0
|
||||||
github.com/stripe/stripe-go/v72 v72.41.0
|
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,29 +1,32 @@
|
|||||||
|
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
|
||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=
|
github.com/gomodule/redigo v1.8.4 h1:Z5JUg94HMTR1XpwBaSH4vq3+PNSIykBLxMdglbw10gg=
|
||||||
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
github.com/gomodule/redigo v1.8.4/go.mod h1:P9dn9mFrCBvWhGE1wpxx6fgq7BAeLBk+UUUzlpkBYO0=
|
||||||
github.com/gomodule/redigo/redis v0.0.0-do-not-use h1:J7XIp6Kau0WoyT4JtXHT3Ei0gA1KkSc6bc87j9v9WIo=
|
|
||||||
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
github.com/gorilla/securecookie v1.1.1 h1:miw7JPhV+b/lAHSXz4qd/nN9jRiAFV5FwjeKyCS8BvQ=
|
||||||
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
github.com/gorilla/securecookie v1.1.1/go.mod h1:ra0sb63/xPlUeL+yeDciTfxMRAA+MP+HVt/4epWDjd4=
|
||||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible h1:jdpOPRN1zP63Td1hDQbZW73xKmzDvZHzVdNYxhnTMDA=
|
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||||
github.com/jordan-wright/email v4.0.1-0.20210109023952-943e75fe5223+incompatible/go.mod h1:1c7szIrayyPPB/987hsnvNzLushdWf4o/79s3P08L8A=
|
|
||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||||
github.com/stripe/stripe-go v1.0.3 h1:RHgK2FUKawVNBPJ15pNM4IWkEVVCg5Ju3xK5QZNhTwY=
|
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||||
github.com/stripe/stripe-go v70.15.0+incompatible h1:hNML7M1zx8RgtepEMlxyu/FpVPrP7KZm1gPFQquJQvM=
|
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||||
github.com/stripe/stripe-go/v72 v72.41.0 h1:HkyJew+GkD/ClBT306+5vKLjBE4PRCJDiZ1enQyxeGQ=
|
github.com/stripe/stripe-go/v74 v74.7.0 h1:KHlyslQj9YOv62b1sycQ31LFj7KlqR+seHsSowAWrjc=
|
||||||
github.com/stripe/stripe-go/v72 v72.41.0/go.mod h1:QwqJQtduHubZht9mek5sds9CtQcKFdsykV9ZepRWwo0=
|
github.com/stripe/stripe-go/v74 v74.7.0/go.mod h1:5PoXNp30AJ3tGq57ZcFuaMylzNi8KpwlrYAFmO1fHZw=
|
||||||
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2 h1:It14KIkyBFYkHkwZ7k45minvA9aorojkyjGk9KJ5B/w=
|
||||||
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
|
||||||
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A=
|
||||||
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw=
|
||||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg=
|
||||||
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
|
||||||
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
|
||||||
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
|
||||||
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
|
||||||
|
golang.org/x/text v0.3.3 h1:cokOdA+Jmi5PJGXLlLllQSgYigAEfHXJAERHVMaCc2k=
|
||||||
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
|
||||||
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
||||||
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c h1:dUUwHk2QECo/6vqA44rthZ8ie2QXMNeKRTHCNY2nXvo=
|
||||||
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -35,10 +35,11 @@ func sendEmailConfirm(username, confirm_id string) {
|
|||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: register@wo-bisch.ch
|
From: register@wo-bisch.ch
|
||||||
Subject: Passwortaenderung auf https://wo-bisch.ch, bitte bestaetigen
|
Subject: Passwortaenderung auf https://wo-bisch.ch, bitte bestaetigen
|
||||||
|
Content-Type: text/plain; charset="UTF-8"
|
||||||
|
|
||||||
Lieber Benutzer von wo-bisch.ch
|
Lieber Benutzer von wo-bisch.ch
|
||||||
|
|
||||||
Sie haben soeben eine Passwortaenderung veranlasst. Bitte klicken Sie folgenden Link,
|
Sie haben soeben eine Passwortänderung veranlasst. Bitte klicken Sie folgenden Link,
|
||||||
um das neue Passwort zu aktivieren:
|
um das neue Passwort zu aktivieren:
|
||||||
|
|
||||||
https://wo-bisch.ch/confirm?id=` + confirm_id + `
|
https://wo-bisch.ch/confirm?id=` + confirm_id + `
|
||||||
@@ -56,7 +57,9 @@ func sendPaymentConfirmationEmail(username, charge_data string, amount int64) {
|
|||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: info@wo-bisch.ch
|
From: info@wo-bisch.ch
|
||||||
Subject: Zahlungsbestaetigung wo-bisch.ch
|
Subject: Zahlungsbestaetigung wo-bisch.ch
|
||||||
|
MIME-version: 1.0;
|
||||||
|
Content-Type: text/html; charset="UTF-8";
|
||||||
|
<pre>
|
||||||
Lieber Benutzer von wo-bisch.ch
|
Lieber Benutzer von wo-bisch.ch
|
||||||
|
|
||||||
Sie haben soeben erfolgreich folgende Abo-Verlaengerungen bezahlt:
|
Sie haben soeben erfolgreich folgende Abo-Verlaengerungen bezahlt:
|
||||||
@@ -65,7 +68,7 @@ Sie haben soeben erfolgreich folgende Abo-Verlaengerungen bezahlt:
|
|||||||
|
|
||||||
Mit freundlichen Grüssen
|
Mit freundlichen Grüssen
|
||||||
--
|
--
|
||||||
wo-bisch.ch`
|
wo-bisch.ch</pre>`
|
||||||
|
|
||||||
sendEmail(username, "mail@wo-bisch.ch", mail_message)
|
sendEmail(username, "mail@wo-bisch.ch", mail_message)
|
||||||
}
|
}
|
||||||
@@ -74,10 +77,11 @@ func sendOrderEmail(username, body string) {
|
|||||||
mail_message := "To: " + username + `
|
mail_message := "To: " + username + `
|
||||||
From: info@wo-bisch.ch
|
From: info@wo-bisch.ch
|
||||||
Subject: Bestelleingang auf https://wo-bisch.ch
|
Subject: Bestelleingang auf https://wo-bisch.ch
|
||||||
|
Content-Type: text/plain; charset="UTF-8"
|
||||||
|
|
||||||
Lieber Administrator
|
Lieber Administrator
|
||||||
|
|
||||||
Soeben ist eine Bestellung eingegangen, bitte pruefen:
|
Soeben ist eine Bestellung eingegangen, bitte prüfen:
|
||||||
|
|
||||||
` + body + `
|
` + body + `
|
||||||
|
|
||||||
|
|||||||
+1
-5
@@ -383,11 +383,7 @@ func prolongActivation(deveui string, years int) (string, error) {
|
|||||||
fmt.Println(t.Unix())
|
fmt.Println(t.Unix())
|
||||||
|
|
||||||
var t_new time.Time
|
var t_new time.Time
|
||||||
if t.Before(time.Now()) {
|
t_new = t.AddDate(years, 0, 0)
|
||||||
t_new = time.Now().AddDate(years, 0, 0)
|
|
||||||
} else {
|
|
||||||
t_new = t.AddDate(years, 0, 0)
|
|
||||||
}
|
|
||||||
active_until_new := t_new.Format(layout)
|
active_until_new := t_new.Format(layout)
|
||||||
|
|
||||||
// SET object
|
// SET object
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
{{define "body_content"}}
|
{{define "body_content"}}
|
||||||
<p class="title is-4">Kontakt</p>
|
<p class="title is-4">Kontakt</p>
|
||||||
<p>nbit Informatik GmbH<br />
|
<p>nbit Informatik GmbH<br />
|
||||||
Kirchweg 2<br />
|
Untere Stockteile 16<br />
|
||||||
3510 Konolfingen<br />
|
3806 Bönigen b. Interlaken<br />
|
||||||
<br />
|
<br />
|
||||||
+41 31 792 00 40<br />
|
+41 31 792 00 40<br />
|
||||||
<a href='mailto:i%6Efo@%6Ebit.%63h'>info@nbit.ch</a>
|
<a href='mailto:i%6Efo@%6Ebit.%63h'>info@nbit.ch</a>
|
||||||
|
|||||||
@@ -16,25 +16,4 @@ Hier sind Sie am richtigen Ort, wenn Sie einen kleinen, sparsamen <a href="/prod
|
|||||||
<p class="pb-4">
|
<p class="pb-4">
|
||||||
Hier geht's zur <a href="/product.html">Produktbeschreibung</a>
|
Hier geht's zur <a href="/product.html">Produktbeschreibung</a>
|
||||||
</p>
|
</p>
|
||||||
{{ if ne .UserName "" }}
|
|
||||||
<p>
|
|
||||||
<strong>Ich will weitere bestellen!</strong>
|
|
||||||
<span class="icon"><i class="fa fa-arrow-right"></i></span>
|
|
||||||
Hier geht's zur <a href="/order.html">Bestellung</a>
|
|
||||||
</p>
|
|
||||||
{{ else }}
|
|
||||||
<div>
|
|
||||||
<p>
|
|
||||||
<strong>Ich will auch einen!</strong>
|
|
||||||
<span class="icon"><i class="fa fa-arrow-right"></i></span>
|
|
||||||
Hier geht's zur <a href="/order.html">Bestellung</a>
|
|
||||||
</p>
|
|
||||||
<p> </p>
|
|
||||||
<p class="pb-4">
|
|
||||||
<strong>Ich habe bereits einen (oder mehrere)</strong>
|
|
||||||
<span class="icon"><i class="fa fa-arrow-right"></i></span>
|
|
||||||
Hier geht's zum <a href="/login.html">Login</a>
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
{{end}}
|
|
||||||
{{end}}
|
{{end}}
|
||||||
|
|||||||
@@ -3,8 +3,9 @@ package main
|
|||||||
import (
|
import (
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/stripe/stripe-go/v72"
|
"github.com/stripe/stripe-go/v74"
|
||||||
"github.com/stripe/stripe-go/v72/paymentintent"
|
"github.com/stripe/stripe-go/v74/customer"
|
||||||
|
"github.com/stripe/stripe-go/v74/paymentintent"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
"log"
|
||||||
"net/http"
|
"net/http"
|
||||||
@@ -21,6 +22,33 @@ func getStripePK() string {
|
|||||||
return os.Getenv("STRIPE_PK")
|
return os.Getenv("STRIPE_PK")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func getCustomerid(name string) string {
|
||||||
|
// if customer does not already exist, create it...
|
||||||
|
var cid = ""
|
||||||
|
params := &stripe.CustomerSearchParams{}
|
||||||
|
params.Query = *stripe.String("name:'" + name + "'")
|
||||||
|
customers := customer.Search(params)
|
||||||
|
for customers.Next() {
|
||||||
|
fmt.Printf("%s\n", customers.Current().(*stripe.Customer).ID)
|
||||||
|
cid = customers.Current().(*stripe.Customer).ID
|
||||||
|
}
|
||||||
|
|
||||||
|
if cid == "" {
|
||||||
|
// create new customer
|
||||||
|
paramsc := &stripe.CustomerParams{
|
||||||
|
Name: stripe.String(name),
|
||||||
|
}
|
||||||
|
|
||||||
|
customer, err := customer.New(paramsc)
|
||||||
|
if err != nil {
|
||||||
|
log.Println("Error Creating Customer: " + name)
|
||||||
|
}
|
||||||
|
cid = customer.ID
|
||||||
|
}
|
||||||
|
|
||||||
|
return cid
|
||||||
|
}
|
||||||
|
|
||||||
func getstripepaymentintentHandler(response http.ResponseWriter, request *http.Request) {
|
func getstripepaymentintentHandler(response http.ResponseWriter, request *http.Request) {
|
||||||
name := getUserName(request)
|
name := getUserName(request)
|
||||||
if name != "" {
|
if name != "" {
|
||||||
@@ -51,10 +79,14 @@ func getstripepaymentintentHandler(response http.ResponseWriter, request *http.R
|
|||||||
|
|
||||||
stripe.Key = getStripeKey()
|
stripe.Key = getStripeKey()
|
||||||
|
|
||||||
|
// if customer does not already exist, create it...
|
||||||
|
customerid := getCustomerid(name)
|
||||||
|
|
||||||
|
// define payment
|
||||||
params := &stripe.PaymentIntentParams{
|
params := &stripe.PaymentIntentParams{
|
||||||
Amount: stripe.Int64(abo_amount),
|
Customer: stripe.String(customerid),
|
||||||
Currency: stripe.String(string(stripe.CurrencyCHF)),
|
Amount: stripe.Int64(abo_amount),
|
||||||
ReceiptEmail: stripe.String(name),
|
Currency: stripe.String(string(stripe.CurrencyCHF)),
|
||||||
}
|
}
|
||||||
params.AddMetadata("charge_data", charge_data[0])
|
params.AddMetadata("charge_data", charge_data[0])
|
||||||
params.AddMetadata("login_user", name)
|
params.AddMetadata("login_user", name)
|
||||||
@@ -121,7 +153,7 @@ func stripeWebhookHandler(w http.ResponseWriter, req *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
fmt.Printf("PaymentIntent was successful (charge_data: %s, amount: %d)!\n", paymentIntent.Metadata["charge_data"], paymentIntent.Amount)
|
fmt.Printf("PaymentIntent was successful (charge_data: %s, amount: %d)!\n", paymentIntent.Metadata["charge_data"], paymentIntent.Amount)
|
||||||
HandlePayment(paymentIntent.ReceiptEmail, paymentIntent.Metadata["charge_data"], paymentIntent.Amount)
|
HandlePayment(paymentIntent.Metadata["login_user"], paymentIntent.Metadata["charge_data"], paymentIntent.Amount)
|
||||||
// ... handle other event types
|
// ... handle other event types
|
||||||
default:
|
default:
|
||||||
fmt.Fprintf(os.Stderr, "Unexpected event type: %s\n", event.Type)
|
fmt.Fprintf(os.Stderr, "Unexpected event type: %s\n", event.Type)
|
||||||
|
|||||||
@@ -46,12 +46,6 @@
|
|||||||
<span>Kontakt</span>
|
<span>Kontakt</span>
|
||||||
</div>
|
</div>
|
||||||
</a>
|
</a>
|
||||||
<a class="navbar-item" href="/order.html">
|
|
||||||
<div style="position:relative">
|
|
||||||
<span class="icon"><i class="fa fa-shopping-cart"></i></span>
|
|
||||||
<span>Bestellen</span>
|
|
||||||
</div>
|
|
||||||
</a>
|
|
||||||
{{ if ne .UserName "" }}
|
{{ if ne .UserName "" }}
|
||||||
<a class="navbar-item" href="/tracker.html">
|
<a class="navbar-item" href="/tracker.html">
|
||||||
<div style="position:relative">
|
<div style="position:relative">
|
||||||
|
|||||||
Reference in New Issue
Block a user