Compare commits

..

No commits in common. "f398af39eb15f8fc15e5a0bfec5e1b119d81653c" and "42b8708243d56eb5a80e3b606aa611966611cf99" have entirely different histories.

5 changed files with 1 additions and 132 deletions

View File

@ -43,10 +43,3 @@ func (app *application) PaymentSucceeded(w http.ResponseWriter, r *http.Request)
app.errorLog.Println(err)
}
}
// ChargeOnce displays the page to buy one widget
func (app *application) ChargeOnce(w http.ResponseWriter, r *http.Request) {
if err := app.renderTemplate(w, r, "buy-once", nil); err != nil {
app.errorLog.Println(err)
}
}

View File

@ -11,10 +11,6 @@ func (app *application) routes() http.Handler {
mux.Get("/virtual-terminal", app.VirtualTerminal)
mux.Post("/payment-succeeded", app.PaymentSucceeded)
mux.Get("/charge-once", app.ChargeOnce)
fileServer := http.FileServer(http.Dir("./static"))
mux.Handle("/static/*", http.StripPrefix("/static", fileServer))
return mux
}

View File

@ -4,7 +4,7 @@
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Buy Widgets</title>
<title>Bootstrap demo</title>
<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css"
rel="stylesheet"
integrity="sha384-QWTKZyjpPEjISv5WaRU9OFeRpok6YctnYmDr5pNlyT2bRjXh0JMhjY6hW+ALEwIH"
@ -15,45 +15,6 @@
</title>
</head>
<body>
<nav class="navbar navbar-expand-lg bg-body-tertiary">
<div class="container-fluid">
<a class="navbar-brand" href="#">&nbsp;</a>
<button class="navbar-toggler"
type="button"
data-bs-toggle="collapse"
data-bs-target="#navbarSupportedContent"
aria-controls="navbarSupportedContent"
aria-expanded="false"
aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav me-auto mb-2 mb-lg-0">
<li class="nav-item">
<a class="nav-link active" aria-current="page" href="/">Home</a>
</li>
<li class="nav-item">
<a class="nav-link" href="/virtual-terminal">Virtual Terminal</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle"
href="#"
role="button"
data-bs-toggle="dropdown"
aria-expanded="false">Products</a>
<ul class="dropdown-menu">
<li>
<a class="dropdown-item" href="/charge-once">Buy one widget</a>
</li>
<li>
<a class="dropdown-item" href="#">Subscription</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</nav>
<div class="container">
<div class="row">
<div class="col">{{ block "content" . }} {{ end }}</div>

View File

@ -1,81 +0,0 @@
{{ template "base" }}
{{ define "title" }}
Buy one widget
{{ end }}
{{ define "content" }}
<h2 class="mt-3 text-center">Buy One Widget</h2>
<hr>
<img src="/static/widget.jpeg"
alt="widget"
class="image-fluid rounded mx-auto d-block">
<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="">
<div class="mb-3">
<label for="amount" class="form-label">Amount</label>
<input type="text"
id="amount"
name="amount"
autocomplete="amount-new"
required=""
class="form-control">
</div>
<div class="mb-3">
<label for="cardholder-name" class="form-label">Cardholder Name</label>
<input type="text"
id="cardholder-name"
name="cardholder_name"
autocomplete="cardholder-name-new"
required=""
class="form-control">
</div>
<div class="mb-3">
<label for="cardholder-email" class="form-label">Cardholder Email</label>
<input type="text"
id="cardholder-email"
name="cardholder_email"
autocomplete="cardholder-email-new"
required=""
class="form-control">
</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>
<a href="javascript:void(0)"
id="pay-button"
class="btn btn-primary"
onclick="val()">Charge Card</a>
<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>
{{ end }}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 67 KiB