Jump to content
Latest News: (loading..)
Sign in to follow this  
ytswy

Hosted Solution and 2.2MS2

Recommended Posts

Hi, I'm trying to integrate the "PayPal Payments Pro (Hosted Solution) v1.0" module, and having some issues. While trying to track down the cause I noticed the "Test API Server Connection" link in the admin screen doesn't work.

 

The Error Console gives me the following:

 

 

Error: ReferenceError: $ is not defined

Source File: https://www.appcentre.co.uk/softstore/admin/modules.php?set=payment&module=paypal_pro_hs

Line: 233

 

 

Line 233 in the source of the page is the second line below, but I don't know enough javascript to even understand what is going on there, let alone if there is a problem:

 

 

function openTestConnectionDialog() {
var d = $('<div>').html($('#testConnectionDialog').html()).dialog({
modal: true,
title: '{$dialog_title}',
buttons: {
'{$dialog_button_close}': function () {
$(this).dialog('destroy');
}
}
});

var timeStart = new Date().getTime();

$.ajax({
url: '{$test_url}'
}).done(function(data) {
if ( data == '1' ) {
d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: green;">{$dialog_success}</p>');
} else {
d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: red;">{$dialog_failed}</p>');
}
}).fail(function() {
d.find('#testConnectionDialogProgress').html('<p style="font-weight: bold; color: red;">{$dialog_error}</p>');
}).always(function() {
var timeEnd = new Date().getTime();
var timeTook = new Date(0, 0, 0, 0, 0, 0, timeEnd-timeStart);

d.find('#testConnectionDialogProgress').append('<p>{$dialog_connection_time} ' + timeTook.getSeconds() + '.' + timeTook.getMilliseconds() + 's</p>');
});
}

 

Any ideas?

Share this post


Link to post
Share on other sites

Hi Harald

 

Thanks for getting back to me! No there is not - there is no ext/jquery/ directory.

 

The site is oscommerce 2.2MS2 - have I misinterpreted the compatibility for your module?

 

Michael

Share this post


Link to post
Share on other sites

You are right - jQuery was first included in v2.3.0.

 

Could you try the following:

 

1) Download jQuery:

 

http://code.jquery.com/jquery-1.11.1.min.js

 

and save it in your catalog/ext/jquery directory. You will need to create the ext/jquery directory if they don't exist already.

 

2) Link to jQuery

 

In catalog/checkout_confirmation.php and catalog/admin/modules.php, add the following line inside the <head> .. </head> area:

 

For catalog/checkout_confirmation.php:

 

<script type="text/javascript" src="ext/jquery/jquery-1.11.1.min.js"></script>

 

For catalog/admin/modules.php:

 

<script type="text/javascript" src="../ext/jquery/jquery-1.11.1.min.js"></script>

 

That should then work for you.


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Hi Harald, thank-you so much for the support!

 

After uploading jquery and linking it in, the link still didn't work, and the Error Console was giving another (different) error:

 

 

Error: TypeError: $(...).html(...).dialog is not a function

 

 

Searching around for that I found people talking about needing jquery ui. I downloaded the latest version of oscommerce, and copied the contents of catalog/ext/jquery/ui/ to my site and uploaded it, and added into the head elements of the files you mentioned:

 

catalog/checkout_confirmation.php:

 

<script type="text/javascript" src="ext/jquery/ui/jquery-ui-1.10.4.min.js"></script>

 

For catalog/admin/modules.php:

 

<script type="text/javascript" src="..ext/jquery/ui/jquery-ui-1.10.4.min.js"></script>

 

Does that seem the correct thing to do? It got me further and the "Test API Server Connection" link produced a result and stopped throwing errors. But after I tried fiddling with a few options in the module's admin interface something went wrong, and it ended up with the module only giving me the option to install it (which produced no change), but still appearing as a payment option in checkout_payment.php

 

I've reverted to a backup of the files, and cleaned out the configuration table of the database of all the "MODULE_PAYMENT_PAYPAL_PRO_HS" entries, and I'll try it again from scratch on Monday. But if you could tell me whether I'm on the right track with the jquery ui stuff, that would be a great help!

Edited by ytswy

Share this post


Link to post
Share on other sites

Hi Michael..

 

I will test it with 2.2MS2 over the weekend and get back to you with what to do. I will do my best to come up with a workaround to get the module working in v2.2.

 

Kind regards,


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Michael, could you try the attached package and test if the following work:

 

1) Test API Server Connection works with a dialog opening

2) PayPal Hosted payment page shown in the checking confirmation page

 

Thanks,

 

oscom_paypal_pro_hosted-1.1.zip


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Harald, this is fantastic, thank-you!

 

Works great. I've processed live orders, both with a card and with a PayPal account. It worked perfectly out of the box - I just configured it with our paypal details and everything worked fine. Edit: Test API server link also works fine.

 

The only thing I would mention is incredibly minor - there isn't a vertical scroll bar on the payment iframe if it gets too long - with the way I've got the site I've been experimenting on set up, the Verified By Visa data was too long for the iframe, and I could only see the top half of the submit button. I will obviously resolve this myself, but I thought I'd point it out.

 

Again, thank-you so much!

 

Michael

Edited by ytswy

Share this post


Link to post
Share on other sites

One other small cosmetic thing I've noticed.

 

The Test API Server link produces a dialogue which always says "Sandbox Server:", even when I'm connected to the Live server (and have that selected in the module configuration).

 

The test for this seems to be in catalog/includes/modules/payment/paypal_pro_hs.php:

 

      if ( MODULE_PAYMENT_PAYPAL_PRO_HS_TRANSACTION_SERVER == 'Live' ) {
        $info .= 'Live Server:<br />' . $this->api_url;
      } else {
        $info .= 'Sandbox Server:<br />' . $this->api_url;
      }
I don't think this is being set anywhere. Querying the database with:

SELECT * FROM `configuration` WHERE `configuration_key` = 'MODULE_PAYMENT_PAYPAL_PRO_HS_TRANSACTION_SERVER'
Produces an empty result. And a site-wide search for MODULE_PAYMENT_PAYPAL_PRO_HS_TRANSACTION_SERVER does not produce any other results apart from the if statement above.

 

 

Edit: Changing the test to be for MODULE_PAYMENT_PAYPAL_PRO_HS_GATEWAY_SERVER resolves this.

Edited by ytswy

Share this post


Link to post
Share on other sites

Hi Harald, I've spotted something you might want to look at (not sure if I should be adding this to a thread already marked as solved, apologies if I should have started a new one).

 

If the customer is paying by card in the iframe on checkout_confirmation.php, but clicks the standard "Confirm Order" button, rather than the one within the iframe, they get thrown back to checkout_payment.php with a query string of ?payment_error=paypal_pro_hs

 

I assume it isn't possible to give the Confirm Order button the required functionality? So I think it would be better to remove that button entirely if this payment method is selected.

 

Quick and dirty fix for anyone else using this is to change in checkout_confirmation.php:

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER)
to:

if ($payment != 'paypal_pro_hs') { echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER) };
But it would probably be better if the test could be for something less hardcoded.

 

-----------

 

On a different subject, I've been trying to add this to a much more customised site, and I'm running into an issue where when I select the payment method on checkout_payment.php and hit confirm, checkout_confirmation.php starts to come up, you see the iframe try and load, and then I get thrown back to checkout_payment.php?payment_error=paypal_pro_hs

 

Since it works fine on the first site, this is obviously due to something I've done, but I'm having problems working out what. I'm wondering if anything immediately occurs to you that could cause that error?

Share this post


Link to post
Share on other sites

If the customer is paying by card in the iframe on checkout_confirmation.php, but clicks the standard "Confirm Order" button, rather than the one within the iframe, they get thrown back to checkout_payment.php with a query string of ?payment_error=paypal_pro_hs

 

Did you perhaps change the name of the form on the checkout confirmation page? The original form name is checkout_confirmation.

 

Before the module loads the iframe on the checkout confirmation page, it executes javascript (jQuery) to hide all submit buttons and images in the checkout_confirmation form.

 

If you didn't change the form name, which browser and version are you using? Do you also see the same behaviour on our demo site at:

 

http://demo.oscommerce.com

 

(the module code name to choose on the checkout payment page is paypal_pro_hs)


:heart:, osCommerce

Share this post


Link to post
Share on other sites

The form appears to be correct as far as I can see, although it is certainly possible I have changed it at some point. Both of the two code snippets below are from viewing source on checkout_confirmation.php on my site (after reverting the change I made to hide the button):

 

The form as it appears is:

 

<form name="checkout_confirmation" action="https://www.appcentre.co.uk/softstore/checkout_process.php" method="post"><table width="100%" class="infobox" border="0" style="border-collapse: collapse"><tr>
            <td><table border="0" width="100%" cellspacing="0" cellpadding="0" style="border-collapse: collapse">
              <tr class="infoBoxContents">
                <td align="right" border="0" colspan="2">

		  </td>
          </tr>
       
              </table>
            </table></td>
          </tr>
            <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="10"></td>
          </tr>
          <tr>
            <td><table border="0" width="100%" cellspacing="1" cellpadding="2"  class="infoBox">
              <tr class="infoBoxContents">
                <td align="right"><input type="image" src="includes/languages/english/images/buttons/button_confirm_order.gif" border="0" alt="Confirm Order" title=" Confirm Order "></td>
              </tr>

            </table></td>
          </tr>
          <tr>
            <td><img src="images/pixel_trans.gif" border="0" alt="" width="100%" height="10"></td>
          </tr>
    </form>
What I assume is the jQuery stuff a little above it:

 

<script>
if ( typeof jQuery == 'undefined' ) {
  document.write('<scr' + 'ipt src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></scr' + 'ipt>');
}
</script>

<script>
$(function() {
  $('form[name="checkout_confirmation"] input[type="submit"], form[name="checkout_confirmation"] input[type="image"], form[name="checkout_confirmation"] button[type="submit"]').hide();
  $('form[name="checkout_confirmation"]').attr('action', 'https://www.appcentre.co.uk/softstore/checkout_payment.php?payment_error=paypal_pro_hs');
});
</script>
I see the button in both Safari 5.1.10 and Firefox 30.0, both running on OSX 10.6.8

 

I do not see the button on the demo.oscommerce.com site (only tested in Firefox).

 

The confirmation button is generated by the following:

 

echo tep_image_submit('button_confirm_order.gif', IMAGE_BUTTON_CONFIRM_ORDER);
The tep_image_submit() function in functions/html_output.php is:

 

  function tep_image_submit($image, $alt = '', $parameters = '') {
    global $language;

    $image_submit = '<input type="image" src="' . tep_output_string(DIR_WS_LANGUAGES . $language . '/images/buttons/' . $image) . '" border="0" alt="' . tep_output_string($alt) . '"';

    if (tep_not_null($alt)) $image_submit .= ' title=" ' . tep_output_string($alt) . ' "';

    if (tep_not_null($parameters)) $image_submit .= ' ' . $parameters;

    $image_submit .= '>';

    return $image_submit;
  }
Edited by ytswy

Share this post


Link to post
Share on other sites

I get an ton of warnings, which I can't find a convenient way to export, almost all of them with the source file as:

https://securepayments.paypal.com/webapps/HostedSoleSolutionApp/webflow/sparta/hostedSoleSolutionProcess
This is the error:

 

Timestamp: 13/06/2014 14:14:22

Error: www.paypalobjects.com : server does not support RFC 5746, see CVE-2009-3555

 

Also tested in Internet Explorer 11.0.7 and Firefox, on Windows 7 with the same result (and same error on FireFox).

 

I don't mean to waste your time on this Harald. If this doesn't occur on a clean install of oscommerce 2.2MS2 then it's obviously down to something unique to this site, and I can work around it in the way I already have - I brought it up thinking it was something that had been overlooked.

Share this post


Link to post
Share on other sites

Oh sorry, you asked for Javascript errors from the Web Console. I gave you the Error Console from the Web Developer Toolbar.

 

The only error I get listed under "Javascript" is an encoding error:

 

A form was submitted in the windows-1252 encoding which cannot encode all Unicode characters, so user input may get corrupted. To avoid this problem, the page should be changed so that the form is submitted in the UTF-8 encoding either by changing the encoding of the page itself to UTF-8 or by specifying accept-charset=utf-8 on the form element.

Edited by ytswy

Share this post


Link to post
Share on other sites

You'd have to debug why jQuery isn't hiding the button.

 

To confirm that jQuery is executing that part of the code, in includes/modules/payment/paypal_pro_hs.php, around line 388 change from:

<script>
$(function() {
  $('form[name="checkout_confirmation"] input[type="submit"], form[name="checkout_confirmation"] input[type="image"], form[name="checkout_confirmation"] button[type="submit"]').hide();
  $('form[name="checkout_confirmation"]').attr('action', '{$form_url}');
});
</script>

to:

<script>
$(function() {
  alert('1');
  $('form[name="checkout_confirmation"] input[type="submit"], form[name="checkout_confirmation"] input[type="image"], form[name="checkout_confirmation"] button[type="submit"]').hide();
  alert('2');
  $('form[name="checkout_confirmation"]').attr('action', '{$form_url}');
  alert('3');
});
</script>

You should then get three javascript alert prompts when loading the checkout confirmation page.


:heart:, osCommerce

Share this post


Link to post
Share on other sites

Got the little bleeder! After all that it was a sodding html error.

 

At some point previously, I'd added a (subsequently removed) 'you must accept terms and conditions' checkbox to that page, and expanded the form to accommodate it. Either when I did it, or when I removed it, I screwed up and ended with the form straddling table cells in a way that makes the W3C validator tell me that the form was not closed. I never noticed because it displayed fine, and the form submitted ok.

 

What didn't work with it however, was your jQuery descendent selector...

 

Harald, you have the patience of a saint! Thank-you so much for your help, and sorry for taking up your time.

Share this post


Link to post
Share on other sites

Hi Harald, I'm sorry, its me again… I've been trying to integrate the module into our main site, but run into a problem. I've got a functional workaround, but it is truly bizarre and I don't know if it is indicative of a problem with the site. If you could tell me whether you think the problem must be due to some change I have made to the stock 2.2MS2 this would be a huge help.

 

The problem:

After choosing the payment module of checkout_payment.php, checkout_confirmation.php starts to load the frame, then throws the user back to checkout_payment.php with a query string of: payment_error=paypal_pro_hs

 

The cause:

The error is being created by this test in catalog/ext/modules/payment/paypal/hosted_checkout.php

 

  if ( $error === false ) {
    if ( !isset($HTTP_GET_VARS['key']) || !tep_session_is_registered('pphs_key') || ($HTTP_GET_VARS['key'] != $pphs_key) || !tep_session_is_registered('pphs_result') ) {
      $error = true;	  
    }
  }
Specifically, it is this condition that is met:

$HTTP_GET_VARS['key'] != $pphs_key
I added an alert box to check on the values of these, with the following added straight after the $error = true; line:

echo '<script>alert("$HTTP_GET_VARS[\'key\'] - ' . $HTTP_GET_VARS['key'] . '\n$pphs_key - ' . $pphs_key .'");</script>';
Here is a series of results, run immediately one after the other:

 

$HTTP_GET_VARS['key'] - oDKHFUl2vw4Xsl0L

$pphs_key - UFFUStj1PmLf6CiI

 

$HTTP_GET_VARS['key'] - gPbxlqffASlRqyDw

$pphs_key - oDKHFUl2vw4Xsl0L

 

$HTTP_GET_VARS['key'] - i0DRxAUdWqpKUNFH

$pphs_key - gPbxlqffASlRqyDw

 

As you can see, the value of $HTTP_GET_VARS['key'] on each attempt has migrated to $pphs_key on the next.

 

I went looking for where $pphs_key is set, and found in catalog/modules/payment/paypal_pro_hs.php the line:

$pphs_key = tep_create_random_value(16);
To check that this code was being run, I put immediately after it:

echo '<script>alert("X");</script>';
This popped the alert box up as expected, but once clicked through the error no longer occured.

 

I tried replacing the altert box with a php command to delay for 5 seconds:

sleep(5);
This did not bypass the error. However, a time delay loop in javascript at the same place for the same time period did.

echo '<script>  var start = new Date().getTime();
  for (var i = 0; i < 1e7; i++) {
    if ((new Date().getTime() - start) > 5000){
      break;
    }
  }</script>';
Experimenting, it seems to require a delay of around 500ms - when first doing this yesterday, a delay of that length resolved the problem. Trying it again today, 500ms does not resolve the problem while 1000ms does.

 

This very same module is working fine on the first site I put it on, which runs on the same server. This other one is our main site. It is considerably more modified, and has more products (though products table is still less than 1000 rows), and has taken many many more orders (orders table is over 40,000 rows, customers table just over 35,000).

 

Any idea? If you were able to just eliminate it being a bug in the module itself, so I know that it is definitely a problem at my end, it would help a lot.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×