Rename template

This commit is contained in:
Nico Schottelius 2020-12-25 17:33:01 +01:00
parent 6efedcb381
commit f7c68b5ca5
3 changed files with 69 additions and 94 deletions

View file

@ -0,0 +1,68 @@
{% extends 'uncloud/base.html' %}
{% block header %}
<script src="https://js.stripe.com/v3/"></script>
<style>
#content {
width: 400px;
margin: auto;
}
</style>
{% endblock %}
{% block body %}
<div id="content">
<h1>Register Credit Card with Stripe</h1>
<p>
By submitting I authorise to send instructions to
the financial institution that issued my card to take
payments from my card account in accordance with the
terms of my agreement with you.
</p>
<!-- Stripe form and messages -->
<span id="message"></span>
<div id="card-element"></div>
<button type='button' id="card-button"> Save
</button>
<div id="ungleichmessage">The card will be registered with stripe.</div>
</div>
<!-- Enable Stripe from UI elements - standard code -->
<script>
var stripe = Stripe('{{ stripe_pk }}');
var elements = stripe.elements();
var cardElement = elements.create('card');
cardElement.mount('#card-element');
var cardButton = document.getElementById('card-button');
var messageContainer = document.getElementById('message');
var clientSecret = '{{ client_secret }}';
cardButton.addEventListener('click', function(ev) {
stripe.confirmCardSetup(
clientSecret,
{
payment_method: {
card: cardElement,
billing_details: { name: "{{username}}", },
},
}
).then(function(result) {
if (result.error) {
var message = document.createTextNode('Error:' + result.error.message);
messageContainer.appendChild(message);
} else {
// Return to API on success.
document.getElementById("ungleichmessage").innerHTML
= "Registered credit card with Stripe."
}
});
});
</script>
{% endblock %}

View file

@ -1,93 +0,0 @@
{% extends 'uncloud/base.html' %}
{% block header %}
<script src="https://js.stripe.com/v3/"></script>
<style>
#content {
width: 400px;
margin: auto;
}
#callback-form {
display: none;
}
</style>
<script>
billing_details: { email: email }
}
})
.then(function(result) {
if (result.error) {
changeLoadingState(false);
var displayError = document.getElementById("card-errors");
displayError.textContent = result.error.message;
} else {
// The PaymentMethod was successfully set up
orderComplete(stripe, setupIntent.client_secret);
}
});
});
};
</script>
{% endblock %}
{% block body %}
<div id="content">
<h1>Registering Credit Card with Stripe</h1>
<p>
By submitting I authorise to send instructions to
the financial institution that issued my card to take
payments from my card account in accordance with the
terms of my agreement with you.
</p>
<!-- Stripe form and messages -->
<span id="message"></span>
<div id="card-element"></div>
<button type='button' id="card-button"> Save
</button>
<div id="ungleichmessage">The card will be registered with stripe.</div>
</div>
<!-- Enable Stripe from UI elements - standard code -->
<script>
var stripe = Stripe('{{ stripe_pk }}');
var elements = stripe.elements();
var cardElement = elements.create('card');
cardElement.mount('#card-element');
var cardButton = document.getElementById('card-button');
var messageContainer = document.getElementById('message');
var clientSecret = '{{ client_secret }}';
cardButton.addEventListener('click', function(ev) {
stripe.confirmCardSetup(
clientSecret,
{
payment_method: {
card: cardElement,
billing_details: { name: "{{username}}", },
},
}
).then(function(result) {
if (result.error) {
var message = document.createTextNode('Error:' + result.error.message);
messageContainer.appendChild(message);
} else {
// Return to API on success.
document.getElementById("ungleichmessage").innerHTML
= "Registered credit card with Stripe."
}
});
});
</script>
{% endblock %}

View file

@ -51,7 +51,7 @@ class OrderViewSet(viewsets.ReadOnlyModelViewSet):
class RegisterCard(LoginRequiredMixin, TemplateView):
login_url = '/login/'
template_name = "uncloud_pay/stripe.html"
template_name = "uncloud_pay/register_stripe.html"
def get_context_data(self, **kwargs):