Handle js success/error messages
This commit is contained in:
parent
c3286a68a5
commit
42c9ec6f28
3 changed files with 28 additions and 14 deletions
|
@ -333,6 +333,9 @@
|
||||||
var error_url = '{{ error_msg.redirect }}';
|
var error_url = '{{ error_msg.redirect }}';
|
||||||
var error_msg = '{{ error_msg.msg_body }}';
|
var error_msg = '{{ error_msg.msg_body }}';
|
||||||
var error_title = '{{ error_msg.msg_title }}';
|
var error_title = '{{ error_msg.msg_title }}';
|
||||||
|
var success_msg = '{{ success_msg.msg_body }}';
|
||||||
|
var success_title = '{{ success_msg.msg_title }}';
|
||||||
|
var success_url = '{{ success_msg.redirect }}';
|
||||||
window.stripeKey = "{{stripe_key}}";
|
window.stripeKey = "{{stripe_key}}";
|
||||||
</script>
|
</script>
|
||||||
{%endblock%}
|
{%endblock%}
|
||||||
|
|
|
@ -735,6 +735,14 @@ class OrderConfirmationView(DetailView, FormView):
|
||||||
),
|
),
|
||||||
'cms_integration': get_cms_integration('default'),
|
'cms_integration': get_cms_integration('default'),
|
||||||
'error_msg': get_error_response_dict("Error", request),
|
'error_msg': get_error_response_dict("Error", request),
|
||||||
|
'success_msg': {
|
||||||
|
'msg_title': _("Thank you !"),
|
||||||
|
'msg_body': _("Your product will be provisioned as soon as "
|
||||||
|
"we receive the payment."),
|
||||||
|
'redirect': reverse('hosting:invoices') if
|
||||||
|
request.user.is_authenticated() else
|
||||||
|
reverse('datacenterlight:index')
|
||||||
|
},
|
||||||
'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
|
'stripe_key': settings.STRIPE_API_PUBLIC_KEY,
|
||||||
})
|
})
|
||||||
return render(request, self.template_name, context)
|
return render(request, self.template_name, context)
|
||||||
|
|
|
@ -104,20 +104,23 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
).then(function(result) {
|
).then(function(result) {
|
||||||
window.result = result;
|
window.result = result;
|
||||||
if (result.error) {
|
fa_icon = $('.modal-icon > .fa');
|
||||||
// Display error.message in your UI.
|
modal_btn = $('#createvm-modal-done-btn');
|
||||||
var errorElement = document.getElementById('card-errors');
|
if (result.error) {
|
||||||
errorElement.textContent = result.error.message;
|
// Display error.message in your UI.
|
||||||
} else {
|
modal_btn.attr('href', error_url).removeClass('hide');
|
||||||
// The payment has succeeded
|
fa_icon.attr('class', 'fa fa-close');
|
||||||
// Display a success message
|
modal_btn.attr('class', '').addClass('btn btn-danger btn-ok btn-wide');
|
||||||
alert("Thanks for the order. Your product will be provisioned " +
|
$('#createvm-modal-title').text(error_title);
|
||||||
"as soon as we receive the payment. Thank you.");
|
$('#createvm-modal-body').html(result.error.message + " " + error_msg);
|
||||||
modal_btn.attr('href', err).removeClass('hide');
|
} else {
|
||||||
fa_icon.attr('class', 'checkmark');
|
// The payment has succeeded
|
||||||
$('#createvm-modal-title').text(data.success.msg_title);
|
// Display a success message
|
||||||
$('#createvm-modal-body').html(data.success.msg_body);
|
modal_btn.attr('href', success_url).removeClass('hide');
|
||||||
}
|
fa_icon.attr('class', 'checkmark');
|
||||||
|
$('#createvm-modal-title').text(success_title);
|
||||||
|
$('#createvm-modal-body').html(success_msg);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in a new issue