Mangopay / cardregistration-js-kit

Mangopay V2 JS resources for card registration front-end workflow
MIT License
38 stars 34 forks source link

CORS issue when running in Ionic/Cordova on iOS #55

Closed andufratu closed 4 years ago

andufratu commented 4 years ago

Hi,

we are running into issues with the CORS preflight request when using the library in a Ionic/Cordova project on iOS. image As can be seen in the screenshot, Ionic uses a custom schema on iOS which does not pass the CORS preflight request on the MangoPay servers. Is there any way to bypass this error?

Thank you.

RAPHAELSTZ commented 4 years ago

Im having a CORS issue as well when using registerCard method on ionic 4 on chrome preview.

mangomaxoasis commented 4 years ago

Hi @raphaelstz and @andufratu This issue is ongoing, we'll keep you updated, Max

mangomaxoasis commented 4 years ago

Hi @andufratu , @raphaelstz Enacting changes to how our API, as well as that of banking partners, processes the origin header is not something we can easily enact. This resources talks about a few solutions https://fdezromero.com/cors-errors-in-ionic-apps/ We have prioritized this issue on our roadmap, but cannot give a delivery date at this stage. Best, Max

andufratu commented 4 years ago

@mangomaxoasis, unfortunately those solutions can't be applied in this case, since the failing requests are made from the MangoPay library and we have no way to intercept them.

mangomaxoasis commented 4 years ago

Hi ,

We are currently looking into a plugin for Cordova, but it's an ongoing subject.

Here is another solution, a bit more manual but still nice.

As the issue seems to be specific to IOS, for the card registration function (which is where the problem is, as it calls a banking partner from the front end) Can you try replacing JS code with code from the IOS card reg kit in objC.

https://github.com/Mangopay/cardregistration-ios-kit/blob/master/mangopay/MPAPIClient.h

Cordova offers the option of adding in native code where appropriate.

As such the request will come from the device, not necessarily the browser.

mangomaxoasis commented 4 years ago

HI Guys, The inclusion of native code is what we deem the best solution in the medium term. I'm closing this issue. max