This commit is contained in:
parent
fccb941e22
commit
bc5eab4229
|
@ -85,14 +85,16 @@ paymentRouter.post("/create-checkout-session", async (req, res, next) => {
|
|||
billing_address_collection: 'auto',
|
||||
line_items: [
|
||||
{
|
||||
price,
|
||||
quantity: 1,
|
||||
price,
|
||||
quantity: 1,
|
||||
},
|
||||
],
|
||||
subscription_data: {
|
||||
metadata: {
|
||||
userId: req.user.userId,
|
||||
startTime: Date.now(),
|
||||
cycle: price === "price_1Lt0XdJnpCQCjf9pM9qqdyt6"
|
||||
? "monthly" : "yearly",
|
||||
},
|
||||
},
|
||||
mode: 'subscription',
|
||||
|
|
|
@ -65,20 +65,19 @@
|
|||
<div class="d-flex flex-row">
|
||||
<form action="/payment/create-checkout-session" method="POST">
|
||||
<input type="hidden" name="priceId" value="price_1Lt0XdJnpCQCjf9pM9qqdyt6" />
|
||||
<button class="btn btn-sm btn-outline-secondary mr-4" type="submit">$1/month</button>
|
||||
<button class="btn btn-sm btn-outline-secondary mr-3" type="submit">$1/month</button>
|
||||
</form>
|
||||
<form action="/payment/create-checkout-session" method="POST">
|
||||
<input type="hidden" name="priceId" value="price_1Lt0XdJnpCQCjf9pHk1MQqCC" />
|
||||
<button class="btn btn-sm btn-outline-secondary" type="submit">$10/year</button>
|
||||
<button class="btn btn-sm btn-outline-secondary ml-3" type="submit">$10/year</button>
|
||||
</form>
|
||||
</div>
|
||||
<% } %>
|
||||
<% } %>
|
||||
<% if (user.tester && user.level === "student") { %>
|
||||
<% if (user.tester && user.level === "student" && user.subscription) { %>
|
||||
<p>Current subscription: <% if (user.subscription.metadata.cycle === "monthly") { %>$1/month<% } else { %>$10/year<% } %></p>
|
||||
<p>Downgrade your account to cancel your subscription</p>
|
||||
<form action="/downgradeToBasic" method="POST">
|
||||
<button class="btn btn-sm btn-secondary" type="submit">Downgrade Account</button>
|
||||
</form>
|
||||
<button class="btn btn-sm btn-secondary" type="button" onClick="handleDowngrade()"> Account</button>
|
||||
<% } %>
|
||||
<% if (user.email) { %>
|
||||
<h4 class="mt-3 mb-3">Password <i class="fas fa-key ml-2"></i></h4>
|
||||
|
@ -229,6 +228,19 @@
|
|||
});
|
||||
}
|
||||
}
|
||||
function handleDowngrade() {
|
||||
const answer = confirm("Are you sure you want to downgrade your account? Your wordlist will be deleted forever. (Export it to CSV from the dictionary if you want to keep it)");
|
||||
if (answer) {
|
||||
fetch("/downgradeToBasic", { method: "POST" }).then((res) => res.json()).then((res) => {
|
||||
if (res.ok) {
|
||||
window.location = "/";
|
||||
}
|
||||
}).catch((err) => {
|
||||
alert("Error downgrading account - check your connection");
|
||||
console.error(err);
|
||||
});
|
||||
}
|
||||
}
|
||||
window.addEventListener('keydown', (e) => {
|
||||
// prevent an enter from submitting the form
|
||||
if (e.keyCode === 13) {
|
||||
|
|
Loading…
Reference in New Issue