Implement handling callbacks
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
{% load static %}
|
||||
{% load has_plan %}
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en-GB">
|
||||
<head>
|
||||
@@ -32,7 +34,7 @@
|
||||
{% if user.is_authenticated %}
|
||||
<li><a href="{% url 'billing' %}">Billing</a></li>
|
||||
{% endif %}
|
||||
{% if user.paid %}
|
||||
{% if user|has_plan:'drilldown' %}
|
||||
<li><a href="{% url 'drilldown' %}">Drilldown</a></li>
|
||||
{% endif %}
|
||||
{% if not user.is_authenticated %}
|
||||
|
||||
@@ -53,32 +53,5 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<script type="text/javascript">
|
||||
// Create an instance of the Stripe object with your publishable API key
|
||||
var stripe = Stripe("pk_test_51HbqYzAKLUD9ELc0KSyiQ9YohsfiUCeBpAfpflAIg2Uu2RFecx3sfWYXzM1xDtI5XlQihqHMnaPKd45JzDuqXdGP00pYWvRvRe");
|
||||
var setupButton = document.getElementById('setup-button');
|
||||
setupButton.addEventListener("click", function () {
|
||||
fetch("/setup-bacs", {
|
||||
method: "POST",
|
||||
})
|
||||
.then(function (response) {
|
||||
return response.json();
|
||||
})
|
||||
.then(function (session) {
|
||||
return stripe.redirectToCheckout({ sessionId: session.id });
|
||||
})
|
||||
.then(function (result) {
|
||||
// If redirectToCheckout fails due to a browser or network
|
||||
// error, you should display the localized error message to your
|
||||
// customer using error.message.
|
||||
if (result.error) {
|
||||
alert(result.error.message);
|
||||
}
|
||||
})
|
||||
.catch(function (error) {
|
||||
console.error("Error:", error);
|
||||
});
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user