website stripe updated
This commit is contained in:
@@ -342,7 +342,7 @@ class PrincipalSubscriptionDeleteView(LoginRequiredMixin, generic.View):
|
||||
|
||||
|
||||
class SubscriptionPageView(TemplateView):
|
||||
template_name = "stripe/subscribe.html"
|
||||
template_name = "stripe_html/subscribe.html"
|
||||
|
||||
def get(self, request, *args, **kwargs):
|
||||
# Example of extracting the token from a query parameter or cookie
|
||||
|
||||
13
templates/stripe_html/fail.html
Normal file
13
templates/stripe_html/fail.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Goodtimes</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>
|
||||
Payment Failed
|
||||
</h3>
|
||||
</body>
|
||||
</html>
|
||||
51
templates/stripe_html/subscribe.html
Normal file
51
templates/stripe_html/subscribe.html
Normal file
@@ -0,0 +1,51 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<title>Goodtimes</title>
|
||||
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bulma@0.9.4/css/bulma.min.css">
|
||||
<script defer src="https://use.fontawesome.com/releases/v6.4.0/js/all.js"></script>
|
||||
<script src="https://js.stripe.com/v3/"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<button class="button is-primary" id="submitBtn">Subscribe!</button>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
||||
<script>
|
||||
console.log("Sanity check!");
|
||||
|
||||
// Get Stripe publishable key
|
||||
fetch("https://goodtimes.betadelivery.com/subscriptions/stripe-subscription/")
|
||||
.then((result) => { return result.json(); })
|
||||
.then((data) => {
|
||||
// Initialize Stripe.js
|
||||
const stripe = Stripe(data.publicKey);
|
||||
|
||||
// new
|
||||
// Event handler
|
||||
document.querySelector("#submitBtn").addEventListener("click", () => {
|
||||
// Get Checkout Session ID
|
||||
fetch("https://goodtimes.betadelivery.com/subscriptions/create-checkout-session/")
|
||||
.then((result) => { return result.json(); })
|
||||
.then((data) => {
|
||||
console.log(data);
|
||||
// Redirect to Stripe Checkout
|
||||
return stripe.redirectToCheckout({ sessionId: data.sessionId })
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
});
|
||||
});
|
||||
});
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
||||
13
templates/stripe_html/success.html
Normal file
13
templates/stripe_html/success.html
Normal file
@@ -0,0 +1,13 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Goodtimes</title>
|
||||
</head>
|
||||
<body>
|
||||
<h3>
|
||||
Payment Successful
|
||||
</h3>
|
||||
</body>
|
||||
</html>
|
||||
Reference in New Issue
Block a user