Create a handler for the POST request after a user is subscribed

This commit is contained in:
2024-08-12 13:49:50 +02:00
parent 01690d0236
commit 0b35136d3f
3 changed files with 40 additions and 8 deletions

View File

@ -4,7 +4,7 @@ Bronze Plan
{{ end }}
{{ define "content" }}
{{$widget := index .Data "widget"}}
<h2 class="mt-3 text-center">Bronze Plan: {{formatCurrency $widget.Price}}</h2>
<h2 class="mt-3 text-center">Bronze Plan: {{ formatCurrency $widget.Price }}</h2>
<hr>
<div class="alert alert-danger text-center d-none" id="card-messages"></div>
<form action="/payment-succeeded-temp"
@ -62,10 +62,7 @@ Bronze Plan
<div class="alert-success text-center" id="card-success" role="alert"></div>
</div>
<hr>
<a href="javascript:void(0)"
id="pay-button"
class="btn btn-primary"
onclick="val({{.API}})">Pay {{formatCurrency $widget.Price}}/month</a>
<a href="javascript:void(0)" id="pay-button" class="btn btn-primary">Pay {{ formatCurrency $widget.Price }}/month</a>
<div class="text-center d-none" id="processing-payment">
<div class="spinner-border text-primary" role="status">
<span class="visually-hidden">Loading...</span>
@ -90,13 +87,14 @@ Bronze Plan
</form>
{{ end }}
{{ define "js" }}
{{$widget := index .Data "widget"}}
<script src="https://js.stripe.com/v3/"></script>
<script type="module">
import {stripeInit} from "/static/js/common.js";
import {val} from "/static/js/stripe-plan.js"
stripeInit('{{.StripePubKey}}');
document.getElementById("pay-button").addEventListener("click", () => {
val({{.API}});
val({{$widget.PlanID}}, {{.API}});
})
</script>
{{ end }}