Refactored and formatted unused code in hosting's payment.html payment.js landing-page.css
This commit is contained in:
parent
ed52e396d9
commit
a87c0a89eb
3 changed files with 157 additions and 285 deletions
|
@ -522,22 +522,27 @@ a.unlink:hover {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
right: 0;
|
right: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand {
|
.brand {
|
||||||
float: left;
|
float: left;
|
||||||
width: 10%;
|
width: 10%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.brand #brand-icon {
|
.brand #brand-icon {
|
||||||
vertical-align: bottom;
|
vertical-align: bottom;
|
||||||
padding-top: 13px;
|
padding-top: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-number-element {
|
.card-number-element {
|
||||||
float: left;
|
float: left;
|
||||||
width: 63%;
|
width: 63%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-expiry-element {
|
.card-expiry-element {
|
||||||
float: left;
|
float: left;
|
||||||
width: 17%;
|
width: 17%;
|
||||||
}
|
}
|
||||||
|
|
||||||
.card-cvc-element {
|
.card-cvc-element {
|
||||||
float: left;
|
float: left;
|
||||||
width: 10%;
|
width: 10%;
|
||||||
|
|
|
@ -5,9 +5,8 @@ var cardBrandToPfClass = {
|
||||||
'discover': 'pf-discover',
|
'discover': 'pf-discover',
|
||||||
'diners': 'pf-diners',
|
'diners': 'pf-diners',
|
||||||
'jcb': 'pf-jcb',
|
'jcb': 'pf-jcb',
|
||||||
'unknown': 'pf-credit-card',
|
'unknown': 'pf-credit-card'
|
||||||
}
|
};
|
||||||
|
|
||||||
function setBrandIcon(brand) {
|
function setBrandIcon(brand) {
|
||||||
var brandIconElement = document.getElementById('brand-icon');
|
var brandIconElement = document.getElementById('brand-icon');
|
||||||
var pfClass = 'pf-credit-card';
|
var pfClass = 'pf-credit-card';
|
||||||
|
@ -22,7 +21,6 @@ function setBrandIcon(brand) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
$(document).ready(function () {
|
$(document).ready(function () {
|
||||||
$.ajaxSetup({
|
$.ajaxSetup({
|
||||||
beforeSend: function (xhr, settings) {
|
beforeSend: function (xhr, settings) {
|
||||||
|
@ -41,6 +39,7 @@ $( document ).ready(function() {
|
||||||
}
|
}
|
||||||
return cookieValue;
|
return cookieValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
|
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
|
||||||
// Only send the token to relative URLs i.e. locally.
|
// Only send the token to relative URLs i.e. locally.
|
||||||
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
|
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
|
||||||
|
@ -52,38 +51,19 @@ $( document ).ready(function() {
|
||||||
var hasCreditcard = window.hasCreditcard || false;
|
var hasCreditcard = window.hasCreditcard || false;
|
||||||
if (!hasCreditcard) {
|
if (!hasCreditcard) {
|
||||||
var stripe = Stripe(window.stripeKey);
|
var stripe = Stripe(window.stripeKey);
|
||||||
var elements = stripe.elements({locale: window.current_lan});
|
|
||||||
/*var card = elements.create('card', options={hidePostalCode: true});
|
|
||||||
card.mount('#card-element');*/
|
|
||||||
/* new card */
|
/* new card */
|
||||||
var server_url = "https://datacenterlight.ch";
|
|
||||||
var element_style = {
|
var element_style = {
|
||||||
fonts: [{
|
fonts: [{
|
||||||
family: 'lato-light',
|
family: 'lato-light',
|
||||||
src: 'url(https://cdn.jsdelivr.net/font-lato/2.0/Lato/Lato-Light.woff) format("woff2")',
|
src: 'url(https://cdn.jsdelivr.net/font-lato/2.0/Lato/Lato-Light.woff) format("woff2")'
|
||||||
}, {
|
}, {
|
||||||
family: 'lato-regular',
|
family: 'lato-regular',
|
||||||
src: 'url(https://cdn.jsdelivr.net/font-lato/2.0/Lato/Lato-Regular.woff) format("woff2")',
|
src: 'url(https://cdn.jsdelivr.net/font-lato/2.0/Lato/Lato-Regular.woff) format("woff2")'
|
||||||
},
|
|
||||||
]
|
|
||||||
}
|
}
|
||||||
var elements = stripe.elements(element_style);
|
],
|
||||||
|
locale: window.current_lan
|
||||||
var style = {
|
|
||||||
base: {
|
|
||||||
iconColor: '#666EE8',
|
|
||||||
color: '#31325F',
|
|
||||||
lineHeight: '40px',
|
|
||||||
fontWeight: 300,
|
|
||||||
fontFamily: "'Lato', sans-serif",
|
|
||||||
fontSize: '14px',
|
|
||||||
|
|
||||||
'::placeholder': {
|
|
||||||
color: '#333',
|
|
||||||
},
|
|
||||||
},
|
|
||||||
};
|
};
|
||||||
|
var elements = stripe.elements(element_style);
|
||||||
var credit_card_text_style = {
|
var credit_card_text_style = {
|
||||||
base: {
|
base: {
|
||||||
iconColor: '#666EE8',
|
iconColor: '#666EE8',
|
||||||
|
@ -93,8 +73,8 @@ var credit_card_text_style = {
|
||||||
fontFamily: "'lato-light', sans-serif",
|
fontFamily: "'lato-light', sans-serif",
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
'::placeholder': {
|
'::placeholder': {
|
||||||
color: '#777',
|
color: '#777'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
invalid: {
|
invalid: {
|
||||||
iconColor: '#eb4d5c',
|
iconColor: '#eb4d5c',
|
||||||
|
@ -105,7 +85,7 @@ var credit_card_text_style = {
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
'::placeholder': {
|
'::placeholder': {
|
||||||
color: '#eb4d5c',
|
color: '#eb4d5c',
|
||||||
fontWeight: 400,
|
fontWeight: 400
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -118,8 +98,8 @@ var credit_card_cvv_style = {
|
||||||
fontFamily: "'lato-regular', sans-serif",
|
fontFamily: "'lato-regular', sans-serif",
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
'::placeholder': {
|
'::placeholder': {
|
||||||
color: '#555',
|
color: '#555'
|
||||||
},
|
}
|
||||||
},
|
},
|
||||||
invalid: {
|
invalid: {
|
||||||
iconColor: '#eb4d5c',
|
iconColor: '#eb4d5c',
|
||||||
|
@ -130,14 +110,14 @@ var credit_card_cvv_style = {
|
||||||
fontSize: '14px',
|
fontSize: '14px',
|
||||||
'::placeholder': {
|
'::placeholder': {
|
||||||
color: '#eb4d5c',
|
color: '#eb4d5c',
|
||||||
fontWeight: 600,
|
fontWeight: 600
|
||||||
},
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
var cardNumberElement = elements.create('cardNumber', {
|
var cardNumberElement = elements.create('cardNumber', {
|
||||||
style: credit_card_text_style,
|
style: credit_card_text_style,
|
||||||
placeholder : "____ ____ ____ ____",
|
placeholder: "____ ____ ____ ____"
|
||||||
});
|
});
|
||||||
cardNumberElement.mount('#card-number-element');
|
cardNumberElement.mount('#card-number-element');
|
||||||
|
|
||||||
|
@ -157,10 +137,6 @@ var credit_card_cvv_style = {
|
||||||
}
|
}
|
||||||
//setOutcome(event);
|
//setOutcome(event);
|
||||||
});
|
});
|
||||||
/*$('#payment-form').submit(function(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
stripe.createToken(cardNumberElement).then(setOutcome);
|
|
||||||
});*/
|
|
||||||
/* new card end */
|
/* new card end */
|
||||||
}
|
}
|
||||||
console.log("has creditcard", hasCreditcard);
|
console.log("has creditcard", hasCreditcard);
|
||||||
|
@ -180,72 +156,15 @@ var credit_card_cvv_style = {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//var $form = $('#payment-form');
|
|
||||||
var $form_new = $('#payment-form-new');
|
var $form_new = $('#payment-form-new');
|
||||||
//$form.submit(payWithStripe);
|
|
||||||
$form_new.submit(payWithStripe_new);
|
$form_new.submit(payWithStripe_new);
|
||||||
|
|
||||||
/* If you're using Stripe for payments */
|
|
||||||
function payWithStripe(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
|
|
||||||
function stripeTokenHandler(token) {
|
|
||||||
// Insert the token ID into the form so it gets submitted to the server
|
|
||||||
var form = document.getElementById('payment-form');
|
|
||||||
var hiddenInput = document.createElement('input');
|
|
||||||
$('#id_token').val(token.id);
|
|
||||||
$('#billing-form').submit();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
stripe.createToken(card).then(function(result) {
|
|
||||||
if (result.error) {
|
|
||||||
// Inform the user if there was an error
|
|
||||||
var errorElement = document.getElementById('card-errors');
|
|
||||||
errorElement.textContent = result.error.message;
|
|
||||||
} else {
|
|
||||||
$form.find('[type=submit]').html('Processing <i class="fa fa-spinner fa-pulse"></i>');
|
|
||||||
// Send the token to your server
|
|
||||||
stripeTokenHandler(result.token);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
// /* Visual feedback */
|
|
||||||
// $form.find('[type=submit]').html('Validating <i class="fa fa-spinner fa-pulse"></i>');
|
|
||||||
|
|
||||||
// var PublishableKey = window.stripeKey;
|
|
||||||
// Stripe.setPublishableKey(PublishableKey);
|
|
||||||
// Stripe.card.createToken($form, function stripeResponseHandler(status, response) {
|
|
||||||
// if (response.error) {
|
|
||||||
// /* Visual feedback */
|
|
||||||
// $form.find('[type=submit]').html('Try again');
|
|
||||||
// /* Show Stripe errors on the form */
|
|
||||||
// $form.find('.payment-errors').text(response.error.message);
|
|
||||||
// $form.find('.payment-errors').closest('.row').show();
|
|
||||||
// } else {
|
|
||||||
// /* Visual feedback */
|
|
||||||
// $form.find('[type=submit]').html('Processing <i class="fa fa-spinner fa-pulse"></i>');
|
|
||||||
// /* Hide Stripe errors on the form */
|
|
||||||
// $form.find('.payment-errors').closest('.row').hide();
|
|
||||||
// $form.find('.payment-errors').text("");
|
|
||||||
// // response contains id and card, which contains additional card details
|
|
||||||
// var token = response.id;
|
|
||||||
// // AJAX
|
|
||||||
|
|
||||||
// //set token on a hidden input
|
|
||||||
// $('#id_token').val(token);
|
|
||||||
// $('#billing-form').submit();
|
|
||||||
// }
|
|
||||||
// });
|
|
||||||
}
|
|
||||||
function payWithStripe_new(e) {
|
function payWithStripe_new(e) {
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
||||||
function stripeTokenHandler(token) {
|
function stripeTokenHandler(token) {
|
||||||
// Insert the token ID into the form so it gets submitted to the server
|
// Insert the token ID into the form so it gets submitted to the server
|
||||||
var form = document.getElementById('payment-form-new');
|
var form = document.getElementById('payment-form-new');
|
||||||
var hiddenInput = document.createElement('input');
|
|
||||||
$('#id_token').val(token.id);
|
$('#id_token').val(token.id);
|
||||||
$('#billing-form').submit();
|
$('#billing-form').submit();
|
||||||
}
|
}
|
||||||
|
@ -257,12 +176,18 @@ var credit_card_cvv_style = {
|
||||||
var errorElement = document.getElementById('card-errors');
|
var errorElement = document.getElementById('card-errors');
|
||||||
errorElement.textContent = result.error.message;
|
errorElement.textContent = result.error.message;
|
||||||
} else {
|
} else {
|
||||||
$form_new.find('[type=submit]').html('Processing <i class="fa fa-spinner fa-pulse"></i>');
|
var process_text = "Processing";
|
||||||
|
if (typeof window.processing_text !== 'undefined') {
|
||||||
|
process_text = window.processing_text
|
||||||
|
}
|
||||||
|
|
||||||
|
$form_new.find('[type=submit]').html(process_text + ' <i class="fa fa-spinner fa-pulse"></i>');
|
||||||
// Send the token to your server
|
// Send the token to your server
|
||||||
stripeTokenHandler(result.token);
|
stripeTokenHandler(result.token);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Form validation */
|
/* Form validation */
|
||||||
$.validator.addMethod("month", function (value, element) {
|
$.validator.addMethod("month", function (value, element) {
|
||||||
return this.optional(element) || /^(01|02|03|04|05|06|07|08|09|10|11|12)$/.test(value);
|
return this.optional(element) || /^(01|02|03|04|05|06|07|08|09|10|11|12)$/.test(value);
|
||||||
|
@ -302,18 +227,6 @@ var credit_card_cvv_style = {
|
||||||
$(element).closest('.form-group').append(error);
|
$(element).closest('.form-group').append(error);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
paymentFormReady = function() {
|
|
||||||
if ($form_new.find('[name=cardNumber]').hasClass("success") &&
|
|
||||||
$form_new.find('[name=expMonth]').hasClass("success") &&
|
|
||||||
$form_new.find('[name=expYear]').hasClass("success") &&
|
|
||||||
$form_new.find('[name=cvCode]').val().length > 1) {
|
|
||||||
return true;
|
|
||||||
} else {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
// $form.find('[type=submit]').prop('disabled', true);
|
// $form.find('[type=submit]').prop('disabled', true);
|
||||||
// var readyInterval = setInterval(function() {
|
// var readyInterval = setInterval(function() {
|
||||||
// if (paymentFormReady()) {
|
// if (paymentFormReady()) {
|
||||||
|
|
|
@ -105,53 +105,6 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% else %}
|
{% else %}
|
||||||
|
|
||||||
<!--form role="form" id="payment-form" novalidate>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-12">
|
|
||||||
<div id="card-element">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="form-group col-xs-12">
|
|
||||||
<div id="new-card-element">
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div id="card-errors" role="alert"></div>
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12">
|
|
||||||
<p class="card-warning-content">
|
|
||||||
{% blocktrans %}
|
|
||||||
You are not making any payment yet. After submitting your card
|
|
||||||
information, you will be taken to the Confirm Order Page.
|
|
||||||
{% endblocktrans %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
<div class="col-xs-12">
|
|
||||||
<div class="col-xs-6 pull-right">
|
|
||||||
<button class="btn btn-success stripe-payment-btn" type="submit">{% trans "Submit" %}
|
|
||||||
</button>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<div class="row" style="display:none;">
|
|
||||||
<div class="col-xs-12">
|
|
||||||
<p class="payment-errors"></p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% if paymentError %}
|
|
||||||
<div class="row">
|
|
||||||
<div class="col-xs-12">
|
|
||||||
<p>
|
|
||||||
{% bootstrap_alert paymentError alert_type='danger' %}
|
|
||||||
</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
{% endif %}
|
|
||||||
>
|
|
||||||
</form-->
|
|
||||||
<form action="" id="payment-form-new" method="POST">
|
<form action="" id="payment-form-new" method="POST">
|
||||||
<input type="hidden" name="token"/>
|
<input type="hidden" name="token"/>
|
||||||
<div class="group">
|
<div class="group">
|
||||||
|
@ -180,7 +133,8 @@
|
||||||
</div>
|
</div>
|
||||||
<div class="col-xs-12">
|
<div class="col-xs-12">
|
||||||
<div class="col-xs-6 pull-right">
|
<div class="col-xs-6 pull-right">
|
||||||
<button class="btn btn-success stripe-payment-btn" type="submit">{% trans "Submit" %}
|
<button class="btn btn-success stripe-payment-btn" type="submit">{% trans
|
||||||
|
"Submit" %}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
@ -215,7 +169,7 @@
|
||||||
{% if stripe_key %}
|
{% if stripe_key %}
|
||||||
{% get_current_language as LANGUAGE_CODE %}
|
{% get_current_language as LANGUAGE_CODE %}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
window.processing_text = '{% trans "Processing" %}';
|
||||||
|
|
||||||
(function () {
|
(function () {
|
||||||
window.stripeKey = "{{stripe_key}}";
|
window.stripeKey = "{{stripe_key}}";
|
||||||
|
|
Loading…
Reference in a new issue