Jump to content
  • Checkout
  • Login
  • Get in touch

osCommerce

The e-commerce.

Target redirect


mjaegare

Recommended Posts

Hi all.

I´m forced to use a payment gateway in an iframe.

Once the payment is complete the customer is sent back to checkout_process.php and then redirected to checkout_success.php.

This all happens inside the iframe. I need the checkout_success page to open in the full unframed window.

 

So... is there a way to get the following redirect (from checkout_process.php) to open in the full unframed window using target="_top"?

 

tep_redirect(tep_href_link('shop/' . FILENAME_CHECKOUT_SUCCESS, '', 'SSL'));

 

Where would I put the code to get this done??

 

MJ

Link to comment
Share on other sites

Hi Manfred, thanks for your reply.

 

That did not work. It passes an URL that looks like this (still within the IFRAME):

 

"www.esy.se/shop/checkout_process.php?target=_top&DATA=%3CIDP+MSGTYPE%3D%22PayConfirm%22+blablablablabla+blablablablabla+blablablablablablabl.etc..."

 

Any ideas?

 

Would it be easier to make this work from within the redirect function itself:

 

// Redirect to another page or site
 function tep_redirect($url) {
if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { 
  tep_redirect(tep_href_link(FILENAME_DEFAULT_SHOP, '', 'NONSSL', false));
}

if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
  if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
	$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
  }
}
	# BC Redirects shouldn't have '&'s in them
$url = preg_replace('/&/','&',$url);
header('Location: ' . $url);

tep_exit();
 }

 

Hmm... if this doesn´t work, maybe I could use a another page to redirect.

If the completed payment is sent to say "www.esy.se/shop/a_redirect_page.php?&DATA=%3CIDP+MSGTYPE%3D%22PayConfirm%22+..."

 

Do you know how to just pass the URL forward to checkout_success.php, in the full unframed window?

Link to comment
Share on other sites

OK, so I tried another approach.

 

I made a new function to use only with this IFRAME payment option.

Using a javascript redirect instead of header('Location: ' . $url).

Like this:

 

  // Redirect to another page or site
 function tep_redirect2($url) {
if ( (strstr($url, "\n") != false) || (strstr($url, "\r") != false) ) { 
  tep_redirect2(tep_href_link(FILENAME_DEFAULT_SHOP, '', 'NONSSL', false));
}

if ( (ENABLE_SSL == true) && (getenv('HTTPS') == 'on') ) { // We are loading an SSL page
  if (substr($url, 0, strlen(HTTP_SERVER)) == HTTP_SERVER) { // NONSSL url
	$url = HTTPS_SERVER . substr($url, strlen(HTTP_SERVER)); // Change it to SSL
  }
}
	# BC Redirects shouldn't have '&'s in them
$url = preg_replace('/&/','&',$url);

 //  header('Location: ' . $url);

 echo '<script>
window.top.location.href = "' . $url . '";
</script>';

tep_exit();
 }

 

 

Since I´m not a programmer I really need your comments on this.

I´m sure this is NOT good practice in many ways.

Please tell me if this approach is a bad way to go?

 

Anyway, it seems to work...

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...