【发布时间】:2017-02-04 23:48:56
【问题描述】:
我尝试将 paypal 支付网关集成到我的应用程序中。
我只是使用 angularjs get 方法调用 java webservice。
下面是angularjs http get方法代码
$http({
method : 'GET',
url : 'http://localhost:8080/xxxx/redirect'
}).then(function successCallback(response) {
console.info("success");
});
尝试的Java端代码是-
@RequestMapping(value = "/redirect", method = RequestMethod.GET, headers = "Accept=application/json")
public ModelAndView method(Payment pPayment) {
String amount=pPayment.getAmount();
String url="https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=wipro-seller@gmail.com&first_name=smartCity&city=Madurai&state=Tamilnadu&item_name=shirt&amount=10&night_phone_a=9513335437&item_name=shirt&address1=wipro-seller@gmail.com&business=k.tapankumar@gmail.com&quantity=1¤cy=USD";
return new ModelAndView("redirect:" + url);
}
我仅从 Java 服务器端调用 Paypal 测试帐户 url,但仍然出现以下错误
XMLHttpRequest cannot load https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_xclick&business=wipro-se…o-seller@gmail.com&business=k.tapankumar@gmail.com&quantity=1¤cy=USD. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8080' is therefore not allowed access.
请告诉我我哪里做错了..
【问题讨论】:
-
这是一个 CORS 错误,您可能需要在服务器端进行更改以包含响应标头。看流程图here可能会帮助你理解CORS
标签: java angularjs web-services paypal get