PayPal交易列表 [英] List of PayPal transactions

查看:176
本文介绍了PayPal交易列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是设置:

我为客户设置了网站。客户:

I have a site setup for a client. The customer:


  1. 访问网站

  2. 输入我们记录的基本信息

  3. 通过立即购买按钮进入Pay​​Pal

  4. 通过PayPal付款

  5. 返回网站

  1. Visits the site
  2. Enters in basic information for our records
  3. Proceeds to PayPal via a "Buy Now" button
  4. Makes the payment through PayPal
  5. Returns to the site

我想知道的是如何获得所有交易的清单?我有PayPal登录以及API用户名,密码和签名,但在我的生活中,我无法在互联网上找到一个例子,说明如何通过PHP或从PayPal中提取交易列表jQuery / Javascript / Ajax。

What I am wanting to know is how do I get a list of all the transactions? I have the PayPal login as well as the API username, password, and signature, but for the life of me I cannot find a single place on the internet that gives an example of how to pull a list of transactions from PayPal either via PHP or jQuery/Javascript/Ajax.

有没有人有任何想法?示例?

Does anyone have any ideas? examples?

提前致谢。

更新:

我能够开发出这个问题的解决方案。请参阅下面的代码和评论。

I was able to develop a solution to this question. See my answer below with code and comments.

推荐答案

好的,所以我终于能够开发出有效的东西了。代码发布在下面,其中包含指向PayPal的TransactionSearch API选项的链接

Ok, so I finally was able to develop something that works. The code is posted below with a link to the TransactionSearch API options from PayPal

https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/TransactionSearch_API_Operation_NVP/

<?php 
$info = 'USER=[API_USERNAME]'
        .'&PWD=[API_PASSWORD]'
        .'&SIGNATURE=[API_SIGNATURE]'
        .'&METHOD=TransactionSearch'
        .'&TRANSACTIONCLASS=RECEIVED'
        .'&STARTDATE=2013-01-08T05:38:48Z'
        .'&ENDDATE=2013-07-14T05:38:48Z'
        .'&VERSION=94';

$curl = curl_init('https://api-3t.paypal.com/nvp');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_POSTFIELDS,  $info);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);

$result = curl_exec($curl);

# Bust the string up into an array by the ampersand (&)
# You could also use parse_str(), but it would most likely limit out
$result = explode("&", $result);

# Loop through the new array and further bust up each element by the equal sign (=)
# and then create a new array with the left side of the equal sign as the key and the right side of the equal sign as the value
foreach($result as $value){
    $value = explode("=", $value);
    $temp[$value[0]] = $value[1];
}

# At the time of writing this code, there were 11 different types of responses that were returned for each record
# There may only be 10 records returned, but there will be 110 keys in our array which contain all the different pieces of information for each record
# Now create a 2 dimensional array with all the information for each record together
for($i=0; $i<count($temp)/11; $i++){
    $returned_array[$i] = array(
        "timestamp"         =>    urldecode($temp["L_TIMESTAMP".$i]),
        "timezone"          =>    urldecode($temp["L_TIMEZONE".$i]),
        "type"              =>    urldecode($temp["L_TYPE".$i]),
        "email"             =>    urldecode($temp["L_EMAIL".$i]),
        "name"              =>    urldecode($temp["L_NAME".$i]),
        "transaction_id"    =>    urldecode($temp["L_TRANSACTIONID".$i]),
        "status"            =>    urldecode($temp["L_STATUS".$i]),
        "amt"               =>    urldecode($temp["L_AMT".$i]),
        "currency_code"     =>    urldecode($temp["L_CURRENCYCODE".$i]),
        "fee_amount"        =>    urldecode($temp["L_FEEAMT".$i]),
        "net_amount"        =>    urldecode($temp["L_NETAMT".$i]));
}
?>

此外,我想出了这个漂亮的小脚本,以获取有关特定交易的更多详细信息:

Also, I came up with this nifty little, simple script to get more details about a particular transaction:

https://developer.paypal.com/webapps/developer/docs/classic/api/merchant/GetTransactionDetails_API_Operation_NVP/

<?php 
$info =  'USER=[API_USERNAME]'
        .'&PWD=[API_PASSWORD]'
        .'&SIGNATURE=[API_SIGNATURE]'
        .'&VERSION=94'
        .'&METHOD=GetTransactionDetails'
        .'&TRANSACTIONID=[TRANSACTION_ID]'
        .'&STARTDATE=2013-07-08T05:38:48Z'
        .'&ENDDATE=2013-07-12T05:38:48Z';

$curl = curl_init('https://api-3t.paypal.com/nvp');
curl_setopt($curl, CURLOPT_FAILONERROR, true);
curl_setopt($curl, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);

curl_setopt($curl, CURLOPT_POSTFIELDS,  $info);
curl_setopt($curl, CURLOPT_HEADER, 0);
curl_setopt($curl, CURLOPT_POST, 1);

$result = curl_exec($curl);

parse_str($result, $result);

foreach($result as $key => $value){
    echo $key.' => '.$value."<BR>";
}
?>

这篇关于PayPal交易列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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