Hi I’m working on integration with an online payment gateway in POS
After QR code is need scanned and amount sent, I have to call an API to get the payment response or status… After payment sent successfully the API call failed
Here is the code I made:
var url = "https://api.test-paymentgateway.com/web/v1/merchant/transaction/check-status"; var hashedString = $("#hashedString").val(); var data2 = {merchant_id: this.props.merchantId,reference_id: this.props.referenceNumber,}; var requestString2 = $.map(data2, function(v, k) {return k + "=\"" + v + "\"";}).join(','); var hash = CryptoJS.HmacSHA256(requestString2, this.props.authorizationToken); var signature = CryptoJS.enc.Base64.stringify(hash); console.log("signature: " + signature); $.support.cors = true; $.ajax( { url : url, type: "POST", contentType: "application/json; charset=utf-8", dataType: "json", crossDomain: true, headers: { 'Access-Control-Allow-Origin': window.location.origin, 'Access-Control-Allow-Methods': 'POST, GET, OPTIONS', 'X-FOO-Signature': signature, 'X-CLIENT-ID': this.props.appId, }, data : { 'merchant_id': this.props.merchantId, 'reference_id': this.props.referenceNumber, }, success: function(data) { var jsonData = JSON.stringify(data); var objData = $.parseJSON(jsonData); console.log(objData); }, error: function(xhr) { alert('error :' + xhr.responseText); } });
After calling this API, I got this errorAccess to XMLHttpRequest at
'https://api.test-paymentgateway.com/web/v1/merchant/transaction/check-status'
from origin 'https://somedomain.com' 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.
I dont know how to solve this error and how to enable CORSCan someone please help me on enabling the CORS in odoo-bitnami version?
I am using odoo 14.0