php paypal服务器端REST集成失败 [英] php paypal Server-side REST integration failure

查看:160
本文介绍了php paypal服务器端REST集成失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

(我无法发布代码/错误等,原因是:您需要至少10个信誉才能发布2个以上的链接";并且所有内容都包含很多链接;仅花了几个小时就完成了详细说明发布).

(I'm not able to post code/errors etc because: 'You need at least 10 reputation to post more than 2 links'; and everything contains a lot of links; just spent a couple of hours on a fully detailed post).

我在这里(和其他地方)读过类似的帖子,但它们没有帮助.

I've read similar posts here (and other places) but they have not helped.

我基本上是在关注:

I'm basically following: https://developer.paypal.com/docs/integration/direct/express-checkout/integration-jsv4/server-side-REST-integration/#set-up-your-client

但是PayPal的文档有些混乱,缺少一些关键细节,而且有些地方还很神秘.显然是由委员会撰写的.

but PayPal's documentation is somewhat chaotic, lacking in some crucial details and mysterious in places. Obviously written by a committee.

简而言之,我有一个PayPal付款ID:"id": "PAY-0J356327TH335450NK56Y2PQ"

In a nutshell I have a PayPal payment id: "id": "PAY-0J356327TH335450NK56Y2PQ",

PayPal说从我的创建付款脚本中返回此内容.我不完全确定应如何返回:只需回显"PAY-0J356327TH335450NK56Y2PQ";或返回json字符串.都试过了,什么都没解决.

PayPal say return this from my create payment script. I'm not entirely sure how it should be returned: simply echo "PAY-0J356327TH335450NK56Y2PQ"; or return a json string. Tried both, did not solve anything.

然后(从客户端按钮):

Then there is (from the client side button):

onAuthorize: function(data) {
            return paypal.request.post(EXECUTE_PAYMENT_URL, {
                paymentID: data.paymentID,
                payerID:   data.payerID
            }).then(function() {

                // The payment is complete!
                // You can now show a confirmation message to the customer
            });

我读到它用两个变量(paymentID和payerID)调用我的执行付款脚本时,需要在脚本中使用它.

Which I read as it calling my execute payment script with 2 variables (paymentID and payerID), which I need to use in my script.

我已经尝试过显而易见的事情:

I've tried the obvious:

$paymentID = $_POST["paymentID"];
$payerID = $_POST["payerID"];

不太明显(因为我假设它是POSTing数据,尽管一些文档在这一点上似乎有些困惑):

The not so obvious (because I'm assuming it's POSTing data although some docs seem somewhat confused on this point):

$paymentID = $_GET["paymentID"];
$payerID = $_GET["payerID"];

我的最终尝试:

$ret = file_get_contents("php://input");
$ar = json_decode($ret, TRUE);
$paymentID = $ar["paymentID"];
$payerID = $ar["payerID"];

没有任何改变.

我从PayPal收到的错误是:

The errors I'm getting from PayPal are:

ppxo_no_token_passed_to_payment Object ...
ppxo_unhandled_error Object ...

Error: No value passed to payment
decorate ...

我显然有一个有效的访问令牌,否则我得到的付款ID不够.

I obviously have a valid access token otherwise I'd not get as far as getting a payment id.

目前被困;任何想法/指针都表示赞赏.

Currently stumped; any ideas/pointers appreciated.

这真的应该很简单.

推荐答案

我有相同的错误消息.

I had the same error message.

对我来说,当JavaScript代码收到我的CREATE_PAYMENT_URL ajax请求的响应时,就会发生这种情况.

For me it occured when the javascript code receieved the response from my CREATE_PAYMENT_URL ajax request.

我从服务器发送回的响应不是有效的JSON,因此当需要执行onAuthorize data.paymentID和data.payerID时.

The response I was sending back from the server was not valid JSON so when it came time to execute onAuthorize data.paymentID and data.payerID were not available.

我建议在onAuthorize的return语句上方使用console.log(data),以确保数据json对象具有paymentId和payerId.

I suggests using console.log(data) just above the return statement in onAuthorize to make sure the data json object has a paymentId and payerId.

如果不是,则可能是您的上位CREATE_PAYMENT_URL没有返回付款ID.

If not then it may be that your previoius CREATE_PAYMENT_URL is not returning the payment id.

响应应为json.例如,有效的创建付款响应:

The responses should be json. For example a valid create payment response:

{"id":"PAY-5T1130394T551090NLGRLACY"}

{"id":"PAY-5T1130394T551090NLGRLACY"}

希望有帮助.

这篇关于php paypal服务器端REST集成失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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