Tuesday, 6 August 2013

PayPal Pro iFrame Integration cross origin request

PayPal Pro iFrame Integration cross origin request

I am trying to integrate the PayPal Pro hosted solution using iFrames.
The initial form values used to generate the iFrame allow you to specify a
Return Address where Pay Pal will redirect you to once the payment has
been completed...
<input type="hidden" name="return"
value="https://localhost/PaymentComplete.aspx" />
However, when the payment is complete, PayPal attempts to break the user
out of the iFrame and redirect the user to the specified address.
But,, this doesn't work as its not possible for an iFrame to change the
main page's url. I get the following error message in Chrome...
Blocked a frame with origin "https://securepayments.sandbox.paypal.com"
from accessing a frame with origin "https://localhost". Protocols,
domains, and ports must match.
I understand why this happens, but I need to know if there is a solution.
Otherwise I just don't see how hosting PayPal in an iFrame can work.
PayPal's documentation does not seem to offer a solution and I couldn't
find anything despite a lot of searching. Hopefully its something obvious
I have missed.
Note: I am using a self signed certificate on my local IIS 7 install for
testing - but I don't think this will make any difference. I am able to
request localhost over https.

No comments:

Post a Comment