2024-08-07 12:35:30 +00:00
|
|
|
{{ template "base" . }}
|
2024-08-06 11:29:32 +00:00
|
|
|
{{ define "title" }}
|
|
|
|
Buy one widget
|
|
|
|
{{ end }}
|
|
|
|
{{ define "content" }}
|
2024-08-06 18:49:21 +00:00
|
|
|
{{$widget := index .Data "widget"}}
|
2024-08-06 11:29:32 +00:00
|
|
|
<h2 class="mt-3 text-center">Buy One Widget</h2>
|
|
|
|
<hr>
|
2024-08-06 11:56:39 +00:00
|
|
|
<img src="/static/img/widget.jpeg"
|
2024-08-06 11:29:32 +00:00
|
|
|
alt="widget"
|
|
|
|
class="image-fluid rounded mx-auto d-block">
|
2024-08-06 11:36:49 +00:00
|
|
|
<div class="alert alert-danger text-center d-none" id="card-messages"></div>
|
|
|
|
<form action="/payment-succeeded"
|
|
|
|
method="post"
|
|
|
|
name="charge_form"
|
|
|
|
id="charge_form"
|
|
|
|
class="d-blick needs-validation charge-form"
|
|
|
|
autocomplete="off"
|
|
|
|
novalidate="">
|
2024-08-06 18:49:21 +00:00
|
|
|
<input type="hidden" name="product_id" value="{{$widget.ID}}">
|
2024-08-06 18:52:46 +00:00
|
|
|
<input type="hidden" id="amount" name="amount" value="{{$widget.Price}}">
|
2024-08-07 12:35:30 +00:00
|
|
|
<h3 class="mt-2 mb-3 text-center">{{$widget.Name}}: {{ formatCurrency $widget.Price }}</h3>
|
2024-08-06 18:49:21 +00:00
|
|
|
<p class="mt-2 mb-3 text-center">{{$widget.Description}}</p>
|
|
|
|
<hr>
|
2024-08-06 11:36:49 +00:00
|
|
|
<div class="mb-3">
|
2024-08-10 09:10:27 +00:00
|
|
|
<label for="first-name" class="form-label">First Name</label>
|
2024-08-06 11:36:49 +00:00
|
|
|
<input type="text"
|
2024-08-10 09:10:27 +00:00
|
|
|
id="first-name"
|
|
|
|
name="first_name"
|
|
|
|
autocomplete="first-name-new"
|
|
|
|
required=""
|
|
|
|
class="form-control">
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="last-name" class="form-label">Last Name</label>
|
|
|
|
<input type="text"
|
|
|
|
id="last-name"
|
|
|
|
name="last_name"
|
|
|
|
autocomplete="last-name-new"
|
2024-08-06 11:36:49 +00:00
|
|
|
required=""
|
|
|
|
class="form-control">
|
|
|
|
</div>
|
|
|
|
<div class="mb-3">
|
2024-08-10 09:10:27 +00:00
|
|
|
<label for="cardholder-email" class="form-label">Email</label>
|
2024-08-06 11:36:49 +00:00
|
|
|
<input type="text"
|
|
|
|
id="cardholder-email"
|
|
|
|
name="cardholder_email"
|
|
|
|
autocomplete="cardholder-email-new"
|
|
|
|
required=""
|
|
|
|
class="form-control">
|
2024-08-11 20:08:55 +00:00
|
|
|
<div class="mb-3">
|
|
|
|
<label for="cardholder-name" class="form-label">Name on card</label>
|
|
|
|
<input type="text"
|
|
|
|
id="cardholder-name"
|
|
|
|
name="cardholder_name"
|
|
|
|
autocomplete="cardholder-name-new"
|
|
|
|
required=""
|
|
|
|
class="form-control">
|
|
|
|
</div>
|
2024-08-06 11:36:49 +00:00
|
|
|
</div>
|
|
|
|
<!-- card number will be built by stripe -->
|
|
|
|
<div class="mb-3">
|
|
|
|
<label for="card-element" class="form-label">Credit Card</label>
|
|
|
|
<div class="form-control" id="card-element"></div>
|
|
|
|
<div class="alert-danger text-center" id="card-errors" role="alert"></div>
|
|
|
|
<div class="alert-success text-center" id="card-success" role="alert"></div>
|
|
|
|
</div>
|
|
|
|
<hr>
|
2024-08-11 20:51:34 +00:00
|
|
|
<a href="javascript:void(0)" id="pay-button" class="btn btn-primary">Charge Card</a>
|
2024-08-06 11:36:49 +00:00
|
|
|
<div class="text-center d-none" id="processing-payment">
|
|
|
|
<div class="spinner-border text-primary" role="status">
|
|
|
|
<span class="visually-hidden">Loading...</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<input id="payment_intent"
|
|
|
|
type="hidden"
|
|
|
|
name="payment_intent"
|
|
|
|
value="payment_intent">
|
|
|
|
<input id="payment_method"
|
|
|
|
type="hidden"
|
|
|
|
name="payment_method"
|
|
|
|
value="payment_method">
|
|
|
|
<input id="payment_amount"
|
|
|
|
type="hidden"
|
|
|
|
name="payment_amount"
|
|
|
|
value="payment_amount">
|
|
|
|
<input id="payment_currency"
|
|
|
|
type="hidden"
|
|
|
|
name="payment_currency"
|
|
|
|
value="payment_currency">
|
|
|
|
</form>
|
2024-08-06 11:29:32 +00:00
|
|
|
{{ end }}
|
2024-08-06 11:56:39 +00:00
|
|
|
{{ define "js" }}
|
2024-08-07 12:35:30 +00:00
|
|
|
<script src="https://js.stripe.com/v3/"></script>
|
2024-08-11 20:51:34 +00:00
|
|
|
<script type="module">
|
|
|
|
import {stripeInit} from "/static/js/common.js";
|
|
|
|
import {val} from "/static/js/stripe.js"
|
|
|
|
stripeInit('{{.StripePubKey}}');
|
|
|
|
document.getElementById("pay-button").addEventListener("click", () => {
|
|
|
|
val({{.API}});
|
|
|
|
})
|
|
|
|
</script>
|
2024-08-06 11:56:39 +00:00
|
|
|
{{ end }}
|