paypal - 如何在 Paypal 中访问第三方交易信息

标签 paypal

我正在尝试了解如何从 Paypal 访问第三方用户的交易信息(以包含在仪表板中)。

理想情况下,我需要能够提取交易数据,而不必每次都手动授权该应用,因为很多交易都需要在后台进行。到目前为止,使用测试帐户,我可以看到如何获取我想我需要使用的 API 用户名、密码和签名。

我将为此使用哪个 API(经典/休息)以及哪种身份验证方法最安全?

最佳答案

在为此苦苦挣扎了一段时间后,我在这里找到了一个简单但粗糙的实现 - List of PayPal transactions .

原始代码无效 - 这是更正后的版本

<?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];
}


for($i=0; $i<(count($temp)/11)-1; $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]));
}

var_dump($returned_array);

这显然不是生产代码,但它足以从中逆向工作。

关于paypal - 如何在 Paypal 中访问第三方交易信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24561873/

相关文章:

具有多个项目的 Paypal 购物车

button - PayPal 返回 URL 无效

forms - 使用 PayPal 的 Wordpress 用户角色和报名表

paypal - PayPal Hosted Checkout 中模板 C 的移动版本

php - paypal iPN 和 custom 不会将自定义变量添加到数据库

PayPal 将授权交易转换为定期付款配置文件

email - 如何处理无效的Paypal订单邮件地址?

php - Magento 中的 Paypal 错误 #10602

iphone - 付款被拒绝。请在您的计算机上为此金额添加有效的付款方式。 (iOS 中的 PayPal 实时模式)

express - Paypal Express Checkout- 重新激活暂停的个人资料和余额