my subscriptions page 18
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -129,6 +129,13 @@
|
||||
</div>
|
||||
<div class="Adventure-btn text-center">
|
||||
<input type="text" placeholder="Enter Coupon Code" class="form-control coupon-code-input" size="20">
|
||||
<!-- Checkbox to select recurring or one-time payment -->
|
||||
<div class="form-check">
|
||||
<input class="form-check-input recurring-checkbox" type="checkbox" id="recurringCheck">
|
||||
<label class="form-check-label gold-text" for="recurringCheck">
|
||||
Recurring Subscription
|
||||
</label>
|
||||
</div>
|
||||
<!-- Add a data attribute to store subscription ID -->
|
||||
<button class="common-btn subscribe-btn" data-subscription-id="{{ subscription.id }}" data-price-id="{{ subscription.price_id }}">Join now</button>
|
||||
<!-- Error message container -->
|
||||
@@ -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 => {
|
||||
|
||||
Reference in New Issue
Block a user