Post by briciu » Mon Oct 05, 2020 2:26 pm

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">&times;</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">&times;</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);
}
});

Newbie

Posts

Joined
Sat Aug 25, 2018 5:21 am

Post by ADD Creative » Mon Oct 05, 2020 6:58 pm

Check in your browser development tool that none of the requests or cookies are being blocked or cached.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by briciu » Tue Oct 06, 2020 8:50 pm

it doesn't block anything..I don't have anything in the browser like that

Newbie

Posts

Joined
Sat Aug 25, 2018 5:21 am

Post by ADD Creative » Tue Oct 06, 2020 11:50 pm

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.

www.add-creative.co.uk


Expert Member

Posts

Joined
Sat Jan 14, 2012 1:02 am
Location - United Kingdom

Post by briciu » Wed Oct 07, 2020 4:34 pm

I have been a programmer for 13+ years ... I know how to make a debug but this situation is incomprehensible...maybe a wrong server side setting

Newbie

Posts

Joined
Sat Aug 25, 2018 5:21 am

Post by Randazzo995 » Mon Feb 08, 2021 7:22 pm

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.

Newbie

Posts

Joined
Mon Feb 08, 2021 7:17 pm
Who is online

Users browsing this forum: Baidu [Spider] and 23 guests