当前位置: 首页 > 面试题库 >

贝宝交易清单

公冶嘉
2023-03-14
问题内容

设置如下:

我有一个客户端的站点设置。客户:

  1. 访问该网站
  2. 输入我们的记录的基本信息
  3. 通过“立即购买”按钮进入贝宝
  4. 通过贝宝付款
  5. 返回网站

我想知道的是如何获得所有交易的清单?我拥有PayPal登录名以及API用户名,密码和签名,但是对于我来说,我一生中都找不到一个可以在互联网上找到单个位置的示例,该示例说明了如何通过PHP或PHP从PayPal中提取交易列表。
jQuery / Javascript / Ajax。

有人有什么想法吗?例子?

提前致谢。

更新:

我能够解决这个问题。请参阅下面的代码和注释我的答案。


问题答案:

好的,所以我终于能够开发出行之有效的东西。该代码在下面发布,带有指向PayPal的TransactionSearch API选项的链接

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

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

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 express签出登录。 paypal登录屏幕以正确的货币显示正确的金额,例如10英镑 用户登录(验证事务) 付款成功,用户返回我们的网站。 可爱。这一切都和我预期的一样。 然而,当我登录商家沙盒帐户检查活动时,我的测试用户所做的所有xx支付现在都

  • 谢谢你的预付费。

  • 我使用java开发贝宝支付。我成功地向PayPal提交订单,获取付款url。 我使用个人帐户登录,然后单击按钮。 然后paypal重定向到我设置的url。 如何确定我的付款是否成功 我从这里尝试这个教程 https://developer.paypal.com/docs/business/checkout/server-side-api-calls/create-order/ https://de

  • 当使用NodeJS SDK与PayPal的V2订单API集成时,什么时候是完成订单的正确时间(例如,向客户运送产品)。

  • 收藏宝贝 /** * 收藏宝贝 * * @memberOf Tida * @module social * @name itemFavor * @function * * @param {object} options 入参 * @param {number} options.shopId 店铺ID * @param {function} callback 回调函数 *

  • 我正在工作的一个项目,需要贝宝的ACH支持。你能告诉我如何使用贝宝进行交易吗? 我指的是以下链接:http://www.codeproject.com/articles/152280/online-credit-card-transaction-in-asp-net-using-pa 它正在使用PayFlow SDK,并做信用卡转账。我也能为阿奇做同样的事。但更大的问题是代码没有使用任何贝宝秘密/