added stripeCheckoutUrl 2
This commit is contained in:
@@ -55,3 +55,4 @@ STATIC_URL = "/static/"
|
||||
STATICFILES_DIRS = [BASE_DIR.joinpath("static")]
|
||||
|
||||
STRIPE_CHECKOUT_URL = "http://localhost:8000/subscriptions/stripe-subscription/"
|
||||
STRIPE_FINAL_URL = "http://localhost:8000/subscriptions/create-checkout-session/"
|
||||
|
||||
@@ -46,7 +46,7 @@ LOGGING = {
|
||||
"level": LOGGING_LEVEL,
|
||||
"class": "logging.handlers.RotatingFileHandler",
|
||||
"filename": os.path.join(LOGGING_DIR, "godtimes_pro_error.log"),
|
||||
'maxBytes': 5242880, # 5*1024*1024 bytes (5MB)
|
||||
"maxBytes": 5242880, # 5*1024*1024 bytes (5MB)
|
||||
"backupCount": 10, # Number of log files to keep (15 days' worth of logs)
|
||||
"formatter": "verbose",
|
||||
},
|
||||
@@ -76,4 +76,9 @@ STATIC_URL = "/static/"
|
||||
|
||||
STATICFILES_DIRS = [BASE_DIR.joinpath("static")]
|
||||
|
||||
STRIPE_CHECKOUT_URL = "https://staging.goodtimesltd.co.uk/subscriptions/stripe-subscription/"
|
||||
STRIPE_CHECKOUT_URL = (
|
||||
"https://staging.goodtimesltd.co.uk/subscriptions/stripe-subscription/"
|
||||
)
|
||||
STRIPE_FINAL_URL = (
|
||||
"https://staging.goodtimesltd.co.uk/subscriptions/create-checkout-session/"
|
||||
)
|
||||
|
||||
@@ -75,4 +75,9 @@ STATIC_URL = "/static/"
|
||||
|
||||
STATICFILES_DIRS = [BASE_DIR.joinpath("static")]
|
||||
|
||||
STRIPE_CHECKOUT_URL = "https://staging.goodtimesltd.co.uk/subscriptions/stripe-subscription/"
|
||||
STRIPE_CHECKOUT_URL = (
|
||||
"https://staging.goodtimesltd.co.uk/subscriptions/stripe-subscription/"
|
||||
)
|
||||
STRIPE_FINAL_URL = (
|
||||
"https://staging.goodtimesltd.co.uk/subscriptions/create-checkout-session/"
|
||||
)
|
||||
|
||||
@@ -75,4 +75,9 @@ STATIC_URL = "/static/"
|
||||
|
||||
STATICFILES_DIRS = [BASE_DIR.joinpath("static")]
|
||||
|
||||
STRIPE_CHECKOUT_URL = "https://goodtimes.betadelivery.com/subscriptions/stripe-subscription/"
|
||||
STRIPE_CHECKOUT_URL = (
|
||||
"https://goodtimes.betadelivery.com/subscriptions/stripe-subscription/"
|
||||
)
|
||||
STRIPE_FINAL_URL = (
|
||||
"https://goodtimes.betadelivery.com/subscriptions/create-checkout-session/"
|
||||
)
|
||||
|
||||
@@ -391,6 +391,7 @@ class SubscriptionPageView(TemplateView):
|
||||
if subscriptions.exists():
|
||||
context["subscriptions"] = subscriptions
|
||||
context["stripeCheckoutUrl"] = settings.STRIPE_CHECKOUT_URL
|
||||
context["stripeFinalUrl"] = settings.STRIPE_FINAL_URL
|
||||
else:
|
||||
# Handle the case where no subscriptions are found for the principal type.
|
||||
context["error"] = "No subscriptions found for your user type."
|
||||
|
||||
@@ -443,7 +443,9 @@
|
||||
<script>
|
||||
console.log("Sanity check!");
|
||||
var stripeCheckoutUrl = "{{ stripeCheckoutUrl }}";
|
||||
var stripeFinalUrl = "{{ stripeFinalUrl }}";
|
||||
console.log("stripeCheckoutUrl: ", stripeCheckoutUrl);
|
||||
console.log("stripeFinalUrl: ", stripeFinalUrl);
|
||||
// Get Stripe publishable key
|
||||
fetch(stripeCheckoutUrl)
|
||||
.then((result) => { return result.json(); })
|
||||
@@ -451,23 +453,6 @@
|
||||
// Initialize Stripe.js
|
||||
const stripe = Stripe(data.publicKey);
|
||||
console.log("loaded stripe public key");
|
||||
// new
|
||||
// Event handler
|
||||
// document.querySelector("#submitBtn").addEventListener("click", () => {
|
||||
// button.disabled = true;
|
||||
// // 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);
|
||||
// });
|
||||
// });
|
||||
|
||||
document.querySelectorAll(".subscribe-btn").forEach(button => {
|
||||
button.addEventListener("click", () => {
|
||||
const subscriptionId = button.getAttribute("data-subscription-id");
|
||||
@@ -475,8 +460,7 @@
|
||||
console.log("subscriptionId: ", subscriptionId);
|
||||
button.disabled = true;
|
||||
// Create checkout session for the selected subscription
|
||||
fetch("https://goodtimes.betadelivery.com/subscriptions/create-checkout-session/", {
|
||||
// fetch("http://192.168.0.101:8000/subscriptions/create-checkout-session/", {
|
||||
fetch(stripeFinalUrl, {
|
||||
method: "POST",
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
|
||||
Reference in New Issue
Block a user