I’m integrating a payment provider that uses a 3D Secure authentication iframe. The flow is as follows:
- The payment provider returns an HTML string for the 3D Secure authentication.
- This HTML is set as the
srcdoc
of an iframe in our app. - Upon successful payment, the iframe redirects to a success URL (which we can configure in the payment provider’s panel).
To handle the redirect, I’m using our API server (different from the Capacitor webapp server) as the redirect target. This requires setting the CSP_FRAME_ANCESTORS
on our API server to allow it to be framed by our webapp and Capacitor apps.
Currently, I have:
CSP_FRAME_ANCESTORS = ("'self'", "https://*.mywebapp.com", "file:", "my_app://")
This works for the web app but not for iOS and Android Capacitor apps. Interestingly, using "*"
works for the webapp but still fails for mobile apps.
Questions:
- What
CSP_FRAME_ANCESTORS
configuration would allow framing in both web and Capacitor apps (iOS/Android)? - Are there any Capacitor-specific considerations for handling iframes and CSP?
- Is there a better approach to handle 3D Secure redirects in a Capacitor app?
Any insights or best practices would be greatly appreciated!