the sessions are somehow destroyed and I don't understand where the problem may come from!
in api/payment/address the $this->session->data['payment_address'] is set and keeps the variables.
in same ajax call
api/payment/methods $this->session->data['payment_address'] =NULL
what could be the problem ? Thank you !
$('#button-payment-address').on('click', function() {
console.log(token);
$.ajax({
url: 'index.php?route=api/payment/address&token=' + token + '&store_id=' + $('select[name='store_id'] option:selected').val(),
type: 'post',
data: $('#tab-payment input[type='text'], #tab-payment input[type='hidden'], #tab-payment input[type='radio']:checked, #tab-payment input[type='checkbox']:checked, #tab-payment select, #tab-payment textarea'),
dataType: 'json',
crossDomain: true,
beforeSend: function() {
$('#button-payment-address').button('loading');
},
complete: function() {
$('#button-payment-address').button('reset');
},
success: function(json) {
console.log(JSON.stringify(json));
$('.alert, .text-danger').remove();
$('.form-group').removeClass('has-error');
// Check for errors
if (json['error']) {
if (json['error']['warning']) {
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error']['warning'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
}
for (i in json['error']) {
var element = $('#input-payment-' + i.replace('_', '-'));
if ($(element).parent().hasClass('input-group')) {
$(element).parent().after('<div class="text-danger">' + json['error'] + '</div>');
} else {
$(element).after('<div class="text-danger">' + json['error'] + '</div>');
}
}
// Highlight any found errors
$('.text-danger').parentsUntil('.form-group').parent().addClass('has-error');
} else {
// Payment Methods
$.ajax({
url: '<?php echo $catalog; ?>index.php?route=api/payment/methods&token=' + token + '&store_id=' + $('select[name=\'store_id\'] option:selected').val(),
dataType: 'json',
crossDomain: true,
beforeSend: function() {
$('#button-payment-address').button('loading');
},
complete: function() {
$('#button-payment-address').button('reset');
},
success: function(json) {
if (json['error']) {
$('#content > .container-fluid').prepend('<div class="alert alert-danger"><i class="fa fa-exclamation-circle"></i> ' + json['error'] + ' <button type="button" class="close" data-dismiss="alert">×</button></div>');
} else {
html = '<option value=""><?php echo $text_select; ?></option>';
if (json['payment_methods']) {
for (i in json['payment_methods']) {
if (json['payment_methods']['code'] == $('select[name=\'payment_method\'] option:selected').val()) {
html += '<option value="' + json['payment_methods']['code'] + '" selected="selected">' + json['payment_methods']['title'] + '</option>';
} else {
html += '<option value="' + json['payment_methods']['code'] + '">' + json['payment_methods']['title'] + '</option>';
}
}
}
$('select[name=\'payment_method\']').html(html);
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
}).done(function() {
// Refresh products, vouchers and totals
$('#button-refresh').trigger('click');
// If shipping required got to shipping tab else total tabs
if ($('select[name=\'shipping_method\']').prop('disabled')) {
$('a[href=\'#tab-total\']').tab('show');
} else {
$('a[href=\'#tab-shipping\']').tab('show');
}
});
}
},
error: function(xhr, ajaxOptions, thrownError) {
alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
}
});
Check in your browser development tool that none of the requests or cookies are being blocked or cached.
Every modern browser has as developer tool. It's usually accessed with F12. Then look at the network tab and messages in the console. You may find requests blocked for some reason such as CORS. You may find responses have been cached due to not having correct control headers. You may also find cookies, such as api, are being blocked due to browser security restrictions.
You may also want to check both your OpenCart and PHP error logs.
You may also want to check both your OpenCart and PHP error logs.
You may discover demands hindered for reasons unknown, for example, CORS. You may discover reactions have been reserved because of not having right control headers. You may likewise discover treats, for example, programming interface, are being obstructed because of program security limitations.
Who is online
Users browsing this forum: No registered users and 27 guests