如何在Paypal中访问第三方交易信息 [英] How to access 3rd party transaction information in Paypal

查看:62
本文介绍了如何在Paypal中访问第三方交易信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正试图弄清楚如何从Paypal中访问第三方用户的交易信息(包括在仪表板中).

I'm trying to figure out how to access transaction information from a third party user (to include in a dashboard) from Paypal.

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

Ideally I need to be able to pull in transaction data, without having to manually authorize the app everytime, as a lot of it needs to happen in the background. So far using a test account, I can see how I could obtain the API username, password and signature which I guess I would need to use.

我将使用哪个API(经典/其余),哪种身份验证方法最安全?

Which API would I use for this (Classic / Rest) and which method of authentication would be safest?

推荐答案

经过一段时间的努力,我在这里找到了一个简单但粗略的实现-

After struggling with this for sometime I found a simple, but crude implementation here - List of PayPal transactions.

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

The original code didn't work - here's a corrected version

<?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);

这显然不是生产代码,但足以向后进行工作.

This is obviously not production code, but it's good enough to work backwards from.

这篇关于如何在Paypal中访问第三方交易信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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