If their api does not support CORS it is not callable with Ajax. an api needs custom code to support jsonp and this is not common anymore. They probably expect your website to make the api call, not the browser.
Redsys InSite mode with independent elements
I am doing a development with ASP.Net Core (Razor pages) and I am in the last step of the integration of the redsys gateway with the InSite mode with integration of independent elements; working in the test environment.
In the InSite integration guide, in step 5, it says: "The merchant launches the payment operation through a REST connection". The link takes you to the REST integration guide.
Following all the steps in this guide, the message to be sent to the REST api is obtained, in my case to the test api https://sis-t.redsys.es:25443/sis/rest/trataPeticionREST
The result of JSON.stringify(dataRest) is:
{"Ds_MerchantParameters":"eyJEU19NRVJDSEFOVF9BTU9VTlQiOiI3Myw4NCIsIkRTX01FUkNIQU5UX0NVUlJFTkNZIjoiOTc4IiwiRFNfTUVSQ0hBTlRfTUVSQ0hBTlRDT0RFIjoiMzUyNDM0NDM1IiwiRFNfTUVSQ0hBTlRfT1JERVIiOiIwMDAwMDAwMDA3NjUiLCJEU19NRVJDSEFOVF9JRE9QRVIiOiIxODExNzViOTBjNDM2ZDNlZDQ3ODg4OWEyMjdjNjI2Yjc0MDBiOTEyIiwiRFNfTUVSQ0hBTlRfVEVSTUlOQUwiOiIxIiwiRFNfTUVSQ0hBTlRfVFJBTlNBQ1RJT05UWVBFIjoiMCJ9","Ds_Signature":"X5IoP/ssIy+8gBFbD9znLoz4dFOH/mWRjMCaE/8kq65XJJVLywT05wVXE4Fqbbo6","Ds_SignatureVersion":"HMAC_SHA256_V1"}
I'm doing it with Jquery Ajax and every time I get a 405 Method Not Allowed error. I've tried with GET and POST, but it's the same.
This is the ajax code:
$.ajax({
method: 'POST',
url: 'https://sis-t.redsys.es:25443/sis/rest/trataPeticionREST',
dataType: 'jsonp',
data: JSON.stringify(dataRest)
}).done(function (response) {
console.log(response);
}).fail(function (error) {
console.error(error.status + '\n' + error.responseText);
});
dataType: 'jsonp' is to avoid this error
Access to XMLHttpRequest at 'https://sis-t.redsys.es:25443/sis/rest/trataPeticionREST' from origin 'https://xxxxxxxx.xxx' 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.
Thank you very much in advance for the help if someone has managed this type of integration.
Note: When I finish the integration I will post all the code (html, js and c#), since almost everything found in redsys is about integration with redirection, regarding InSite integration there is nothing, what is found is with CMS's, but not with custom programming, it is worth saying, the Redsys guides are quite bad and do not include any complete example. The only (pretty bad) example is the one that goes all the way to getting the operation id.
Developer technologies | ASP.NET | ASP.NET Core
-
Bruce (SqlWork.com) 78,236 Reputation points Volunteer Moderator
2022-04-23T18:13:05.56+00:00