Post by hounw » Fri Mar 26, 2021 8:01 am

Hello!

We're coding a custom payment gateway and have stumbled upon an issue... we're unable to properly refresh the order summary in the confirm step...

Here's the details:

The payment gateway is for a local credit card processor which offers financing, problem is you need to add a "fee" for this financing based on the financing months so you need to "refresh" the summary table when you change a select on the payment form, however after doing everything right, for reasons that are beyond me the scripts in our payment method's twig file stops running, not even a simple alert("hello world") runs which tells me the whole script doesn't run after it is refreshed using ajax...

So being it a bug so weird and unusual that I have been unable to find anything that remotely helps me solve it I can only conclude I'm doing something wrong in the design of the gateway... something as simple as adding a fee based on selection of a payment form should NOT be this complicated, right?

Here's the code

Code: Select all

$('#some-select').on('change', function() {
      $.ajax({
        url: 'index.php?route=extension/payment/custom_gateway/save_option&option='+$('#some-select').val(),
        type: 'post',		
        dataType: 'json',
        cache: false,
        success: function(json) {
        
        // inocently simple code that should refresh the checkout confirm step
          $.ajax({
						url: 'index.php?route=checkout/confirm',
						dataType: 'html',
						success: function (html) {
							$('#collapse-checkout-confirm .panel-body').html(html);
						},
						error: function (xhr, ajaxOptions, thrownError) {
							alert(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
						}
					});
        },
        error: function (request, error) {
          console.log(arguments);
          alert(error);
        }
      });
    });
Obviously there are no errors in the backend nor the javascript console... after the ajax runs it refreshes the checkout (we see the fee added) but disables all the script in our payment gateway's twig...

Newbie

Posts

Joined
Tue Nov 03, 2020 1:41 am

Post by sw!tch » Fri Mar 26, 2021 8:45 am

Code: Select all

type: 'post',		
dataType: 'json',
cache: false,
You are passing the option selector as a querystring and expecting a json response. Do you have a json response in your controller save_option method?

Full Stack Web Developer :: Send a PM for Custom Work.
Backup and learn how to recover before you make any changes!


Active Member

Posts

Joined
Sat Apr 28, 2012 2:32 pm
Location - USA
Who is online

Users browsing this forum: No registered users and 120 guests