Use different js code for one-time and subscriptions
This commit is contained in:
parent
2c3d00f03f
commit
ba3c5ddd1d
1 changed files with 85 additions and 84 deletions
|
@ -92,38 +92,7 @@ $(document).ready(function() {
|
||||||
});
|
});
|
||||||
|
|
||||||
var create_vm_form = $('#virtual_machine_create_form');
|
var create_vm_form = $('#virtual_machine_create_form');
|
||||||
create_vm_form.submit(placeOrderPaymentIntent);
|
if (window.isSubscription) {
|
||||||
|
|
||||||
function placeOrderPaymentIntent(e) {
|
|
||||||
e.preventDefault();
|
|
||||||
var stripe = Stripe(window.stripeKey);
|
|
||||||
stripe.confirmCardPayment(
|
|
||||||
window.paymentIntentSecret,
|
|
||||||
{
|
|
||||||
payment_method: window.pm_id
|
|
||||||
}
|
|
||||||
).then(function(result) {
|
|
||||||
window.result = result;
|
|
||||||
fa_icon = $('.modal-icon > .fa');
|
|
||||||
modal_btn = $('#createvm-modal-done-btn');
|
|
||||||
if (result.error) {
|
|
||||||
// Display error.message in your UI.
|
|
||||||
modal_btn.attr('href', error_url).removeClass('hide');
|
|
||||||
fa_icon.attr('class', 'fa fa-close');
|
|
||||||
modal_btn.attr('class', '').addClass('btn btn-danger btn-ok btn-wide');
|
|
||||||
$('#createvm-modal-title').text(error_title);
|
|
||||||
$('#createvm-modal-body').html(result.error.message + " " + error_msg);
|
|
||||||
} else {
|
|
||||||
// The payment has succeeded
|
|
||||||
// Display a success message
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
create_vm_form.submit(function () {
|
create_vm_form.submit(function () {
|
||||||
$('#btn-create-vm').prop('disabled', true);
|
$('#btn-create-vm').prop('disabled', true);
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -186,7 +155,39 @@ $(document).ready(function() {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
});*/
|
});
|
||||||
|
} else {
|
||||||
|
create_vm_form.submit(placeOrderPaymentIntent);
|
||||||
|
function placeOrderPaymentIntent(e) {
|
||||||
|
e.preventDefault();
|
||||||
|
var stripe = Stripe(window.stripeKey);
|
||||||
|
stripe.confirmCardPayment(
|
||||||
|
window.paymentIntentSecret,
|
||||||
|
{
|
||||||
|
payment_method: window.pm_id
|
||||||
|
}
|
||||||
|
).then(function(result) {
|
||||||
|
window.result = result;
|
||||||
|
fa_icon = $('.modal-icon > .fa');
|
||||||
|
modal_btn = $('#createvm-modal-done-btn');
|
||||||
|
if (result.error) {
|
||||||
|
// Display error.message in your UI.
|
||||||
|
modal_btn.attr('href', error_url).removeClass('hide');
|
||||||
|
fa_icon.attr('class', 'fa fa-close');
|
||||||
|
modal_btn.attr('class', '').addClass('btn btn-danger btn-ok btn-wide');
|
||||||
|
$('#createvm-modal-title').text(error_title);
|
||||||
|
$('#createvm-modal-body').html(result.error.message + " " + error_msg);
|
||||||
|
} else {
|
||||||
|
// The payment has succeeded
|
||||||
|
// Display a success message
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
$('#createvm-modal').on('hidden.bs.modal', function () {
|
$('#createvm-modal').on('hidden.bs.modal', function () {
|
||||||
$(this).find('.modal-footer .btn').addClass('hide');
|
$(this).find('.modal-footer .btn').addClass('hide');
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue