Skip to content

Commit 2533b2c

Browse files
committed
mongodb + bulma
1 parent 0e63161 commit 2533b2c

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+5748
-2077
lines changed

Dockerfile

+19
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# syntax=docker/dockerfile:1
2+
FROM golang:1.23-alpine AS build
3+
WORKDIR /app
4+
COPY . .
5+
RUN go build -o /app/main .
6+
7+
FROM alpine:latest
8+
WORKDIR /app
9+
COPY --from=build /app/main /app/main
10+
COPY ./static /app/static
11+
COPY ./views /app/views
12+
COPY ./assets /app/assets
13+
14+
# .env
15+
COPY ./.env /app/.env
16+
17+
# expose port
18+
EXPOSE 1212
19+
CMD ["/app/main"]

app.log

+1,014
Large diffs are not rendered by default.

assets/UbuntuMono-R.ttf

201 KB
Binary file not shown.

assets/bulmaswatch.min.css

+6
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

assets/js/checkout.js

+97
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
// This is your test publishable API key.
2+
const stripe = Stripe("pk_test_51Q3BCQC06XYmpb7G4NfpCp7RfBau4A65hH9mPn5FRpBL0aXd2Fx9PggDxE3zBouWte7hyFViwLXMcOzsHOpydKEC00LRpAdUHQ");
3+
4+
// The items the customer wants to buy
5+
const items = [{ id: "xl-tshirt", amount: 1000 }];
6+
7+
let elements;
8+
9+
initialize();
10+
11+
document
12+
.querySelector("#payment-form")
13+
.addEventListener("submit", handleSubmit);
14+
15+
// Fetches a payment intent and captures the client secret
16+
async function initialize() {
17+
const response = await fetch("/create-payment-intent", {
18+
method: "POST",
19+
headers: { "Content-Type": "application/json" },
20+
body: JSON.stringify({ items }),
21+
});
22+
const { clientSecret, dpmCheckerLink } = await response.json();
23+
24+
const appearance = {
25+
theme: 'stripe',
26+
};
27+
elements = stripe.elements({ appearance, clientSecret });
28+
29+
const paymentElementOptions = {
30+
layout: "tabs",
31+
};
32+
33+
const paymentElement = elements.create("payment", paymentElementOptions);
34+
paymentElement.mount("#payment-element");
35+
36+
// [DEV] For demo purposes only
37+
setDpmCheckerLink(dpmCheckerLink);
38+
}
39+
40+
async function handleSubmit(e) {
41+
e.preventDefault();
42+
setLoading(true);
43+
44+
const { error } = await stripe.confirmPayment({
45+
elements,
46+
confirmParams: {
47+
// Make sure to change this to your payment completion page
48+
return_url: "http://localhost:4242/complete.html",
49+
receipt_email: document.getElementById("email").value,
50+
},
51+
});
52+
53+
// This point will only be reached if there is an immediate error when
54+
// confirming the payment. Otherwise, your customer will be redirected to
55+
// your `return_url`. For some payment methods like iDEAL, your customer will
56+
// be redirected to an intermediate site first to authorize the payment, then
57+
// redirected to the `return_url`.
58+
if (error.type === "card_error" || error.type === "validation_error") {
59+
showMessage(error.message);
60+
} else {
61+
showMessage("An unexpected error occurred.");
62+
}
63+
64+
setLoading(false);
65+
}
66+
67+
// ------- UI helpers -------
68+
69+
function showMessage(messageText) {
70+
const messageContainer = document.querySelector("#payment-message");
71+
72+
messageContainer.classList.remove("hidden");
73+
messageContainer.textContent = messageText;
74+
75+
setTimeout(function () {
76+
messageContainer.classList.add("hidden");
77+
messageContainer.textContent = "";
78+
}, 4000);
79+
}
80+
81+
// Show a spinner on payment submission
82+
function setLoading(isLoading) {
83+
if (isLoading) {
84+
// Disable the button and show a spinner
85+
document.querySelector("#submit").disabled = true;
86+
document.querySelector("#spinner").classList.remove("hidden");
87+
document.querySelector("#button-text").classList.add("hidden");
88+
} else {
89+
document.querySelector("#submit").disabled = false;
90+
document.querySelector("#spinner").classList.add("hidden");
91+
document.querySelector("#button-text").classList.remove("hidden");
92+
}
93+
}
94+
95+
function setDpmCheckerLink(url) {
96+
document.querySelector("#dpm-integration-checker").href = url;
97+
}

assets/static.gif

115 KB
Loading

store/store.go assets/styles.css

File renamed without changes.

0 commit comments

Comments
 (0)