Maybe this means that you are only allowed to use this library from inside the native/shell PhonePe app?
I am not aware of this service but I think this is an issue with that service and not Playcanvas. I’d say try and reaching out to their support forums.
This is quite a common issue with PhonePe API. Imo, if you can, avoid using this payment gateway as it caused quite a few issues on my apps in the past. Razorpay offers a rock solid WebAPI that’s far superior when compared to PhonePe. If it’s not imperative for you to use PhonePe, I’d recommend Razorpay, as it offers the same features with a better documented API.
Sorry I don’t have any experience with PhonePe, but given the error you are getting is at the library side most likely the sdk init or loading isn’t correctly.
This is something better asked on the PhonePe forums or support channels.
Its okay…
No need to say sorry…
I will try to contact them…
Last thing…
Here take a look…
Well when i added lib in console and executed same code through console then it worked!
Also generate desired output on playcanvas screen…
Then after also it is still not working through the playcanvas code…
R u sure about es6 promise kind of thing? it is working well here?
var data = JSON.stringify({
"request": "xyz"
});
var xhr = new XMLHttpRequest();
xhr.withCredentials = true;
xhr.addEventListener("readystatechange", function () {
if (this.readyState === this.DONE) {
console.log(this.responseText);
}
});
xhr.open("POST", "https://apps-uat.phonepe.com/v3/service/auth/access");
xhr.send(data);
Gives this error:
Access to XMLHttpRequest at ‘https://apps-uat.phonepe.com/v3/service/auth/access’ from origin ‘https://playcanv.as’ has been blocked by CORS policy: Response to preflight request doesn’t pass access control check: No ‘Access-Control-Allow-Origin’ header is present on the requested resource.
You have to ask PhonePe. At a guess, you might have to whitelist the domain or URL in your PhonePe Dev/project account or host your app on their servers.