finetune payment
This commit is contained in:
parent
d7e69f7e38
commit
08e7fa95d3
|
|
@ -23,6 +23,8 @@ func abocostHandler(response http.ResponseWriter, request *http.Request) {
|
|||
}
|
||||
response.Header().Set("Content-Type", "text/json; charset=utf-8")
|
||||
fmt.Fprintf(response, "{\n")
|
||||
fmt.Fprintf(response, " \"stripe_pk\": \"%s\",\n", getStripePK())
|
||||
fmt.Fprintf(response, " \"data\": {\n")
|
||||
first := true
|
||||
for key, value := range data {
|
||||
fmt.Println("Key:", key, "Value:", value)
|
||||
|
|
@ -33,5 +35,6 @@ func abocostHandler(response http.ResponseWriter, request *http.Request) {
|
|||
}
|
||||
fmt.Fprintf(response, " \"%s\": [ %d, %d, \"%s\", \"%s\" ]\n", key, int(value), int(getYearlyAboCost(key)*int(value)), getActiveUntil(key), getDevAlias(key))
|
||||
}
|
||||
fmt.Fprintf(response, " }\n")
|
||||
fmt.Fprintf(response, "}\n")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
// dictionary: deveui as key, count as value
|
||||
var abos_to_buy = {}
|
||||
var stripe_pk = "";
|
||||
|
||||
function validate(what, text) {
|
||||
if (what == 'alias') {
|
||||
|
|
@ -26,7 +27,7 @@ function HandleAbocostResponse(data) {
|
|||
abo_table += '<tr><th class="is-2">Alias</th><th>verlängern bis</th><th class="has-text-right">Betrag</th></tr>';
|
||||
jQuery.each(ordered, function (index, val) {
|
||||
counter += 1;
|
||||
abo_table += '<tr><td>' + val[3] + '</td><td>' + moment(val[2], 'DD.MM.YYYY').add('years', val[0]).format('DD.MM.YYYY') + '</td><td class="has-text-right">' + (val[1] / 100).toFixed(2) + '</td></tr>';
|
||||
abo_table += '<tr><td>' + val[3] + '</td><td>' + moment(val[2], 'DD.MM.YYYY').add(val[0], 'years').format('DD.MM.YYYY') + '</td><td class="has-text-right">' + (val[1] / 100).toFixed(2) + '</td></tr>';
|
||||
total_amount += (val[1] / 100);
|
||||
if (charge_data == '') {
|
||||
charge_data = index + ":" + val[0] + ":" + val[1];
|
||||
|
|
@ -124,8 +125,6 @@ $(document).ready(function () {
|
|||
return;
|
||||
}
|
||||
|
||||
loadStripeLibrary();
|
||||
|
||||
$.ajax({
|
||||
url: "abocost",
|
||||
type: "POST", //send it through post method
|
||||
|
|
@ -133,8 +132,13 @@ $(document).ready(function () {
|
|||
data: JSON.stringify(abos_to_buy),
|
||||
success: function(response) {
|
||||
console.log("SUCCESS");
|
||||
console.log(response);
|
||||
HandleAbocostResponse(response);
|
||||
console.log(response.stripe_pk);
|
||||
console.log(response.data);
|
||||
if (stripe_pk == "") {
|
||||
stripe_pk = response['stripe_pk'];
|
||||
loadStripeLibrary();
|
||||
}
|
||||
HandleAbocostResponse(response['data']);
|
||||
},
|
||||
error: function(xhr) {
|
||||
console.log("ERROR");
|
||||
|
|
@ -207,7 +211,7 @@ function loadStripeLibrary() {
|
|||
function SetupStripe() {
|
||||
// Set your publishable key: remember to change this to your live publishable key in production
|
||||
// See your keys here: https://dashboard.stripe.com/account/apikeys
|
||||
stripe = Stripe('pk_test_51Icq29K2XyHQRTs2DeltUIWrbFb5evfJVGaQzMv4r50g8Q7HAUkSFr7BBGv0aP1damXIhM6fZ4Yf9Wz0qW6TpTVi00dWcW7J1O');
|
||||
stripe = Stripe(stripe_pk);
|
||||
elements = stripe.elements({ locale: "de" });
|
||||
|
||||
// Set up Stripe.js and Elements to use in checkout form
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ func getStripeKey() string {
|
|||
return os.Getenv("STRIPE_KEY")
|
||||
}
|
||||
|
||||
func getStripePK() string {
|
||||
return os.Getenv("STRIPE_PK")
|
||||
}
|
||||
|
||||
func getstripepaymentintentHandler(response http.ResponseWriter, request *http.Request) {
|
||||
name := getUserName(request)
|
||||
if name != "" {
|
||||
|
|
@ -53,6 +57,7 @@ func getstripepaymentintentHandler(response http.ResponseWriter, request *http.R
|
|||
ReceiptEmail: stripe.String(name),
|
||||
}
|
||||
params.AddMetadata("charge_data", charge_data[0])
|
||||
params.AddMetadata("login_user", name)
|
||||
paymentintent, err := paymentintent.New(params)
|
||||
|
||||
if err != nil {
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ After=network.target
|
|||
[Service]
|
||||
Environment="INFLUX_RO_TOKEN=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA=="
|
||||
Environment="STRIPE_KEY=sk_XXXXXXXXXXXXXX"
|
||||
Environment="STRIPE_PK=pk_XXXXXXXXXXXXXX"
|
||||
Type=simple
|
||||
User=appuser
|
||||
Group=appuser
|
||||
|
|
|
|||
Loading…
Reference in New Issue