website stripe updated

This commit is contained in:
rizwanisready
2024-03-07 18:46:30 +05:30
parent 000ecd7cb2
commit 9d58f227ac
4 changed files with 78 additions and 1 deletions

View File

@@ -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

View 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>

View 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>

View 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>