ohno Posted December 6, 2012 Share Posted December 6, 2012 Not even sure if this is possible, I know nothing about programming!! Basically our developer disappeared mid job, never good but hey. Anyway, I've bungled my way through most of the issues that were outstanding with help from others which in a way has been good fun On to the problem, we have a payment page which takes users details such as address etc. When the user clicks "make payment" the page changes to the payment screen where the card data appears in an iFrame (it's a Pay Pal Hosted solution). The issue is the cart progress is reported in our admin section, the line of code I can see is as follows :- $sql = "UPDATE carts SET progress='19' WHERE cartid='".$_SESSION['cartid']."'"; mysql_query($sql); I can see the set progress number is pulled from another file which features code such as :- elseif ( $row['progress'] == '19' ) { echo 'iFrame Payment Page'; This works all well & good. The problem is the iFrame has two stages, the first stage is card data like number & expiry, once this is submitted the iFrame changes to 3D Secure (Mastercard Secure code or Verfied by Visa). What I don't know how to do is get the progress to report this? It seems it is possible as the code is there ready & waiting :- elseif ( $row['progress'] == '15' ) { echo '3Ds iframe Page'; I "just" don't know how to get the sql output? I tried adding :- $sql = "UPDATE carts SET progress='15' WHERE cartid='".$_SESSION['cartid']."'"; mysql_query($sql); Below the iFrame code but of course that just chages the progress status when the iFrame loads NOT when the iFrame changes. I guess I need some way of detecting the iFrame refresh or page change? Any help would be great, or if someone can fix this for some beer money then feel free to contact me. A web design company say they can do it but it would take around 4 hours @ £25 PH, not really worth me spending £100 to get a status changed in an admin system!(especially as this is the back up payment method that rarely gets used, it's just me wanting to fix the "bugs"!!) Thanks for any help Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/ Share on other sites More sharing options...
kicken Posted December 6, 2012 Share Posted December 6, 2012 It's not possible to monitor the status of an iframe when the content it is showing is not yours, due to a security policy browsers implement called the same-origin policy. The most you can do is tell if they have entered the iframe, and then update the status to complete or failed when paypal notifies you of the result. Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1397928 Share on other sites More sharing options...
ohno Posted December 7, 2012 Author Share Posted December 7, 2012 Oh well, that's a shame. Seems strange the programmer did not know this The status updates once the payment is complete as it redirects to another page, shame the 3DS does not have that ability as we could then fix this issue. I do have another problem(!). We also have JS validation on one of the entry pages(hosted on our server this time), it uses a script called Fvalidator which has been modified so we can switch the JS on & off from our back end system. I'd like to add this to another page for an email entry text box, if anyone fancies earning some beer money please drop me a message! TIA Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398050 Share on other sites More sharing options...
ohno Posted December 7, 2012 Author Share Posted December 7, 2012 hmm, back to the iFrame issue. Looking at the process further what happens is the card payment info opens in an iFrame, once that stage is complete the 3DS info opens another iFrame, so an iFrame in an iFrame! Is there a way to detect that happeing? We don't need to know what the URL is or anything like that just the fact a second iFrame has opened in the iFrame(!!). Or does the fact that this happens in an iFrame mean we can't detect anyhting? Sorry if these are dumb questions but I know nothing about this, just trying to finish what a pro started. Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398055 Share on other sites More sharing options...
ohno Posted December 7, 2012 Author Share Posted December 7, 2012 I found this code when looking around :- function iframeClickHandler() { alert("Iframe clicked"); } var iframe = document.getElementById("myIframe"); var iframeDoc = iframe.contentDocument || iframe.contentwindow.document; if (typeof iframeDoc.addEventListener != "undefined") { iframeDoc.addEventListener("click", iframeClickHandler, false); } else if (typeof iframeDoc.attachEvent != "undefined") { iframeDoc.attachEvent ("onclick", iframeClickHandler); } Which claims it can detect a click in an iFrame? If that is correct then if this could be made to detect the click then call the sql function this would work?? Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398061 Share on other sites More sharing options...
kicken Posted December 7, 2012 Share Posted December 7, 2012 (edited) I found this code when looking around :- Which claims it can detect a click in an iFrame? It'll only work if the frame is from the same origin as the parent script. If they are different, it is blocked by the same-origin policy, and you'd just get an error along the lines of Unsafe Javascript attempt to access frame with URL http://example.net/ from frame with URL http://example.com/. Domains, protocols and ports must match. Edited December 7, 2012 by kicken Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398094 Share on other sites More sharing options...
ohno Posted December 7, 2012 Author Share Posted December 7, 2012 OK, thanks. So there really is no way to detect anything on an iFrame that resides on a different domain? Be it a click or height change or another window opening? Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398098 Share on other sites More sharing options...
kicken Posted December 7, 2012 Share Posted December 7, 2012 Not really. Not without cooperation with the other site. They would have to send notification messages whenever anything interesting happens. Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398099 Share on other sites More sharing options...
ohno Posted December 7, 2012 Author Share Posted December 7, 2012 Hmm, it may be worth an email to Pay Pal MTS to see if this happens in any way, I doubt it though! Thanks again for your help. Quote Link to comment https://forums.phpfreaks.com/topic/271677-detecting-iframe-status/#findComment-1398100 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.