javascript - Implement cybersource silent order post with ajax -
i using cybersource silent order post inside magento 1 page checkout. want ajax post "https://testsecureacceptance.cybersource.com/silent/pay/". it's giving me below error:- "xmlhttprequest cannot load https://testsecureacceptance.cybersource.com/silent/pay/. no 'access-control-allow-origin' header present on requested resource. origin therefore not allowed access. response had http status code 403"
i want answer specific cybersource. let me know if there option except ajax
please find below code:-
var url = jquery("#post_url").val(); var access_key=jquery("#access_key").val(); var profile_id=jquery("#profile_id").val(); var signed_field_names=jquery("#signed_field_names").val(); var unsigned_field_names=jquery("#unsigned_field_names").val(); var bill_to_forename=jquery("#bill_to_forename").val(); var bill_to_surname=jquery("#bill_to_surname").val(); var bill_to_email=jquery("#bill_to_email").val(); var bill_to_phone=jquery("#bill_to_phone").val(); var bill_to_address_line1=jquery("#bill_to_address_line1").val(); var bill_to_address_city=jquery("#bill_to_address_city").val(); var bill_to_address_state=jquery("#bill_to_address_state").val(); var bill_to_address_country=jquery("#bill_to_address_country").val(); var bill_to_address_postal_code=jquery("#bill_to_address_postal_code").val(); var signed_date_time=jquery("#signed_date_time").val(); var locale=jquery("#locale").val(); var card_type=jquery("#cybersource_cc_type").val(); var card_number=jquery("#cybersource_cc_number").val(); var card_expiry_date=jquery("#cybersource_expiration").val(); var params ='access_key='+access_key+ '&profile_id='+profile_id+ '&signed_field_names='+signed_field_names+ '&bill_to_forename='+bill_to_forename+ '&bill_to_surname='+bill_to_surname+ '&bill_to_email='+bill_to_email+'&bill_to_phone='+bill_to_phone+'&bill_to_address_line1='+bill_to_address_line1+'&bill_to_address_city='+bill_to_address_city+'&bill_to_address_state='+bill_to_address_state+'&bill_to_address_country='+bill_to_address_country+'&bill_to_address_postal_code='+bill_to_address_postal_code+'&signed_date_time='+signed_date_time+'&locale='+locale+'&card_type='+card_type+'&card_number='+card_number+'&card_expiry_date='+card_expiry_date; //alert(url); var http= new xmlhttprequest(); http.open("post", url, true); http.setrequestheader("content-type", "application/x-www-form-urlencoded"); http.send(params); //send proper header information along request http.onreadystatechange = function() {//it never comes section if(http.readystate == 4) { alert(http.responsetext); console.log("i came back"); } }
i don't believe cybersource endpoints allow ajax calls. given ajax calls not supported, cybersource endpoint not have cors configured, hence seeing errors when making ajax calls.
according documentation silent order post form should submitted , user redirected. once payment processed, cybersource redirect user appropriate page. similar flow used cybersource secure acceptance web/mobile, , different flows used adyen, braintree, or stripe (which do make ajax calls responses should processed server).
I am getting the same error.
ReplyDelete