passing key using form
This commit is contained in:
parent
bfaf8965b3
commit
d3e477eebd
@ -5,7 +5,11 @@ import (
|
||||
)
|
||||
|
||||
func (app *application) VirtualTerminal(w http.ResponseWriter, r *http.Request) {
|
||||
if err := app.renderTemplate(w, r, "terminal", nil); err != nil {
|
||||
stringMap := make(map[string]string)
|
||||
stringMap["publishable_key"] = app.config.stripe.key
|
||||
if err := app.renderTemplate(w, r, "terminal", &templateData{
|
||||
StringMap: stringMap,
|
||||
}); err != nil {
|
||||
app.errorLog.Println(err)
|
||||
}
|
||||
}
|
||||
|
@ -28,6 +28,7 @@ var functions = template.FuncMap{}
|
||||
var templateFS embed.FS
|
||||
|
||||
func (app *application) addDefaultData(td *templateData, r *http.Request) *templateData {
|
||||
td.API = app.config.api
|
||||
return td
|
||||
}
|
||||
|
||||
|
@ -75,7 +75,7 @@ const cardMessages = document.getElementById("card-messages");
|
||||
const payButton = document.getElementById("pay-button");
|
||||
const processing = document.getElementById("processing-payment");
|
||||
|
||||
stripe = Stripe(''); // TODO: Publish key to be added
|
||||
stripe = Stripe('{{index .StringMap "publishable_key"}}');
|
||||
|
||||
function hidePayButton() {
|
||||
payButton.classList.add("d-none");
|
||||
@ -128,7 +128,7 @@ function val() {
|
||||
body: JSON.stringify(payload),
|
||||
};
|
||||
|
||||
fetch("http://localhost:4001/api/payment-intent", requestOptions)
|
||||
fetch("{{index .API}}/api/payment-intent", requestOptions)
|
||||
.then(response => response.text())
|
||||
.then(response => {
|
||||
let data;
|
||||
|
Loading…
Reference in New Issue
Block a user