简体   繁体   English

如何获得paypal自适应支付IPN帖子?

[英]how to get the paypal adaptive payments IPN posts?

So I have my PHP IPN script working, now I am just not sure how to get the post values? 所以我的PHP IPN脚本正常工作,现在我只是不确定如何获取帖子值? Paypal returns the post as an array like this. Paypal将帖子作为这样的数组返回。

transaction[0].is_primary_receiver=false
&transaction[0].id_for_sender_txn=50E02759CC687801U
&log_default_shipping_address_in_transaction=false
&transaction[0].receiver=xxxxxxxxxx@gmail.com
&action_type=PAY
&transaction[1].status=Completed

There is obviously more but you get the idea, I tried accessing the post for status like this. 显然有更多,但你明白了,我试着访问这个状态的帖子。

$payment_status = $_POST['transaction'][1]['status']

but this doesn't work, it returns the first letter which is C. So how do I access the values for all of them. 但这不起作用,它返回的第一个字母是C.那么我该如何访问所有这些值。

With a little search I've found this link to be helpfull: https://developer.paypal.com/webapps/developer/docs/classic/ipn/ht_ipn/ 通过一点点搜索,我发现此链接有用: https//developer.paypal.com/webapps/developer/docs/classic/ipn/ht_ipn/

The most relevant part of the page: 页面最相关的部分:

// Reading POSTed data directly from $_POST causes serialization issues with array data in the POST.
// Instead, read raw POST data from the input stream. 
$raw_post_data = file_get_contents('php://input');
$raw_post_array = explode('&', $raw_post_data);
$myPost = array();
foreach ($raw_post_array as $keyval) {
    $keyval = explode ('=', $keyval);
    if (count($keyval) == 2)
        $myPost[$keyval[0]] = urldecode($keyval[1]);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM