Created a base template for login / signup, Fixed some html design issues on login / signup pages, Added Billing Address Form to payment page, Handle Billing Address Form validation, Created VirtualMachinePlan model in order to store user purchased VM, Create method in order to create a stripe plan , Investigated about stripe payment workflows

This commit is contained in:
Levi 2016-04-23 02:22:44 -05:00
commit 5456c4c341
17 changed files with 573 additions and 415 deletions

View file

@ -59,10 +59,23 @@ h6 {
padding-top: 20%;
padding-bottom: 20%;
}
.intro-signup {
.intro-auth {
text-align: center;
color: #f8f8f8;
position: relative;
padding-top: 20%;
padding-bottom: 20%;
padding-bottom: 25%;
padding-top: 10%;
}
.intro-login {
background: url(../img/intro-bg.jpg) no-repeat center center;
background-size: cover;
}
.intro-signup {
background: url(../img/configure.jpg) no-repeat center center;
background-size: cover;
}
.intro-message > h1 {
@ -200,4 +213,12 @@ a#forgotpassword {
line-height: 1;
font-weight: 700;
color: #6db97c;
}
a.unlink {
color: inherit;
}
a.unlink:hover {
color: inherit;
}

View file

@ -1,4 +1,5 @@
.creditcard-box {padding-top:17%; padding-bottom: 11%;}
.payment-container {padding-top:5%; padding-bottom: 11%;}
.creditcard-box .panel-title {display: inline;font-weight: bold; font-size:17px;}
.creditcard-box .checkbox.pull-right { margin: 0; }
.creditcard-box .pl-ziro { padding-left: 0px; }
@ -20,12 +21,6 @@
margin-top: 2px;
}
.summary-box {
padding-top:17%;
padding-bottom: 11%;
}
.summary-box .content {
padding-top: 15px;

View file

@ -1,5 +1,30 @@
$( document ).ready(function() {
$.ajaxSetup({
beforeSend: function(xhr, settings) {
function getCookie(name) {
var cookieValue = null;
if (document.cookie && document.cookie != '') {
var cookies = document.cookie.split(';');
for (var i = 0; i < cookies.length; i++) {
var cookie = jQuery.trim(cookies[i]);
// Does this cookie string begin with the name we want?
if (cookie.substring(0, name.length + 1) == (name + '=')) {
cookieValue = decodeURIComponent(cookie.substring(name.length + 1));
break;
}
}
}
return cookieValue;
}
if (!(/^http:.*/.test(settings.url) || /^https:.*/.test(settings.url))) {
// Only send the token to relative URLs i.e. locally.
xhr.setRequestHeader("X-CSRFToken", getCookie('csrftoken'));
}
}
});
var $form = $('#payment-form');
$form.submit(payWithStripe);
@ -13,7 +38,6 @@ $( document ).ready(function() {
var PublishableKey = 'pk_test_6pRNASCoBOKtIshFeQd4XMUh'; // Replace with your API publishable key
Stripe.setPublishableKey(PublishableKey);
Stripe.card.createToken($form, function stripeResponseHandler(status, response) {
console.log
if (response.error) {
/* Visual feedback */
$form.find('[type=submit]').html('Try again');
@ -30,19 +54,25 @@ $( document ).ready(function() {
var token = response.id;
console.log(token);
// AJAX
$.post('/account/stripe_card_token', {
token: token
})
// Assign handlers immediately after making the request,
.done(function(data, textStatus, jqXHR) {
$form.find('[type=submit]').html('Payment successful <i class="fa fa-check"></i>').prop('disabled', true);
})
.fail(function(jqXHR, textStatus, errorThrown) {
$form.find('[type=submit]').html('There was a problem').removeClass('success').addClass('error');
/* Show Stripe errors on the form */
$form.find('.payment-errors').text('Try refreshing the page and trying again.');
$form.find('.payment-errors').closest('.row').show();
});
//set token on a hidden input
$('#id_token').val(token);
$('#billing-form').submit();
// $.post('/hosting/payment/', {
// token: token,
// })
// // Assign handlers immediately after making the request,
// .done(function(data, textStatus, jqXHR) {
// $form.find('[type=submit]').html('Payment successful <i class="fa fa-check"></i>').prop('disabled', true);
// })
// .fail(function(jqXHR, textStatus, errorThrown) {
// $form.find('[type=submit]').html('There was a problem').removeClass('success').addClass('error');
// /* Show Stripe errors on the form */
// $form.find('.payment-errors').text('Try refreshing the page and trying again.');
// $form.find('.payment-errors').closest('.row').show();
// });
}
});
}

View file

@ -10,6 +10,7 @@ $( document ).ready(function() {
var ID_SELECTOR = "#";
var CURRENCY = "CHF";
var final_price_selector = ID_SELECTOR.concat(vm_type.concat('-final-price'));
var final_price_input_selector = final_price_selector.concat('-input');
var core_selector = ID_SELECTOR.concat(vm_type.concat('-cores'));
var memory_selector = ID_SELECTOR.concat(vm_type.concat('-memory'));
var disk_size_selector = ID_SELECTOR.concat(vm_type.concat('-disk_space'));
@ -27,8 +28,9 @@ $( document ).ready(function() {
price += company_prices.memory_price*memory;
price += company_prices.disk_size_price*disk_size;
console.log(final_price_selector);
console.log(final_price_input_selector);
$(final_price_selector).text(price.toString().concat(CURRENCY));
$(final_price_input_selector).attr('value', price);
}
@ -47,7 +49,5 @@ $( document ).ready(function() {
$('.disk-space-selector').on('change',change_attribute);
console.log("mirame",window.VMTypesData);
});