贝宝访问控制允许来源 [英] Paypal Access-Control-Allow-Origin

查看:62
本文介绍了贝宝访问控制允许来源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试学习Paypal付款.我已经完成了一个使用Paypal-Express-Checkout的简单AngularJS应用程序.正如文档中所说,首先我必须调用SetExpressCheckout.

I'm trying to learn paypal payment. I have done a simple AngularJS application that use Paypal-Express-Checkout. As it says on the documentation, first of all I have to do the call SetExpressCheckout.

$http.post("https://api-3t.sandbox.paypal.com/nvp", request)
.success(function(data){
    console.log(data);
}).error(function(error){
    console.log(error);
});

对象request中有所有付款明细. 但是,当我运行脚本时,http调用的结果是:XMLHttpRequest cannot load https://api-3t.sandbox.paypal.com/nvp. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. 我试图搜索此错误,但是什么也没找到.我该怎么解决?

In the object request there are all payment details. But when I run the script, the result of http call is: XMLHttpRequest cannot load https://api-3t.sandbox.paypal.com/nvp. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:3000' is therefore not allowed access. I tried to search this error, but I find nothing. How can I solve?

更新:如果来自表单的请求没有给我任何错误,但是来自http.post函数的请求却给了我一个错误

UPDATE: If the request comes from a form does not give me any error but if it come from http.post function it give me an error

推荐答案

您必须在后端执行Paypal交易,并且您看到的消息是Paypal实施了该概念.有关更多信息,请参见这篇有关CORS的文章.

You have to perform your Paypal transaction on the back end, and the message you're seeing is Paypal enforcing that notion. See this article on CORS for more info.

您的角度http调用应该将基本交易信息发送到您的服务器,该服务器随后将为Paypal构造一个API请求,处理来自Paypal的响应,然后将该信息传递给客户端以供使用.

Your angular http call should be sending the basic transaction info to your server, which will then construct an API request for Paypal, handle the response from Paypal, and then convey that information for consumption by the client side.

[已编辑以添加有关CORS的更多信息]

[edited to add more info about CORS]

这篇关于贝宝访问控制允许来源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆