diff --git a/manage_subscriptions/views.py b/manage_subscriptions/views.py
index 55fac46..6bcecde 100644
--- a/manage_subscriptions/views.py
+++ b/manage_subscriptions/views.py
@@ -827,6 +827,7 @@ def create_checkout_session(request):
subscription_id = data.get("subscriptionId")
coupon_code = data.get("couponCode")
transaction_amount = data.get("discountAmount")
+ is_recurring = data.get("isRecurring")
principal_id = request.user.id
try:
@@ -867,7 +868,7 @@ def create_checkout_session(request):
# Creating the Stripe Checkout Session
try:
- if subscription.price_id:
+ if is_recurring and subscription.price_id:
session_data["line_items"] = [
{
"price": subscription.price_id,
diff --git a/templates/stripe_html/index.html b/templates/stripe_html/index.html
index 06b75db..1a35145 100644
--- a/templates/stripe_html/index.html
+++ b/templates/stripe_html/index.html
@@ -129,6 +129,13 @@
+
+
+
+
+
@@ -536,11 +543,13 @@
button.addEventListener("click", () => {
const subscriptionId = button.getAttribute("data-subscription-id");
const priceId = button.getAttribute("data-price-id");
+ const recurringCheckbox = button.closest('.feat-card').querySelector(".recurring-checkbox");
const couponCode = button.previousElementSibling.value;
const errorMessageContainer = button.nextElementSibling;
console.log("subscriptionId: ", subscriptionId);
console.log("couponCode: ", couponCode);
console.log("priceId: ", priceId);
+ console.log("recurring: ", recurringCheckbox.checked); // Checking if the checkbox is checked
button.disabled = true;
button.previousElementSibling.value = "";
@@ -552,7 +561,8 @@
},
body: JSON.stringify({
subscriptionId: subscriptionId,
- couponCode: couponCode
+ couponCode: couponCode,
+ isRecurring: recurringCheckbox.checked
}),
})
.then(response => {