Iframe payone redirect parent
I have one payment form. When I submit that form it will redirect to PAYONE for payment information when I successfully submitted. That page redirect to success link of my site for further开发者_开发百科 details.
Now my question start: I open my payment gateway (PAYONE) page into an iframe in same window. But when I successfully submitted information and click to submit. Then it will redirect in the iframe.
How can I redirect to success link which I provided in post data?
I know this Q&A is older than dirt, but thought I'd clarify for anyone else looking for this information.
Since the redirect is going to be on a page in the same domain, cross domain scripting security doesn't come into play, so you don't need to put any code on the iframe parent, simply have the payment provider return to a page with the following:
<html><head><title></title></head>
<body onload="parent.location='http://www.google.com';">
If you are not redirect in 5 seconds, please click here... etc..
</body></html>
Becaues of security and having now control over your payment provider, the easiest way to handle this is to have a 'landing' iframe page that the customer gets redirected back to from the payment provider.. That page then calls a function to reload the entire page to a new URL...
In the parent window: put this in the section
<script type="text/javascript">
function payment_redirect(url) { document.location=url;}
</script>
Then just have a simple iframe landing page to trigger the update
<html><head><title></title></head>
<body onload="parent.payment_redirect('http://www.google.com');">
If you are not redirect in 5 seconds, please click here... etc..
</body></html>
notice how i included the function in the parent window, and then called it from the iframe page via 'parent' - iframe security will not let you redirect or refresh a page directly from the iframe...
Since this question was raised, PAYONE have incorporated iframe-busting into their API. When creating the link or POST parameters to the payment form, include this parameter:
'targetwindow' => 'top'
Other permitted values are:
- window
- opener
- top
- parent
- blank
- self
The user returning from the payment form will be sent to the specified target window.
精彩评论