Ok, vì vậy cuối cùng tôi đã có thể phát triển thứ gì đó hoạt động. Mã này được đăng tải dưới đây với một liên kết đến các tùy chọn TransactionSearch API từ 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]));
}
?>
Ngoài ra, tôi đã đưa ra rất ít, kịch bản đơn giản tiện lợi này để biết thêm chi tiết về một giao dịch cụ thể:
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>";
}
?>
Xin chào, tôi đã thử mã hóa đầu tiên để hiển thị giao dịch nhưng tôi đã nhận được 'SCREAM: Loại bỏ lỗi bị bỏ qua cho ' ' Lỗi phân tích cú pháp: lỗi cú pháp, không mong muốn '=', mong ')' trong C: \ wamp \ www \ all_transactions.php trên dòng 40' lỗi –
Điều này dường như là một lỗi PHP như thể bạn có một nhân vật không đúng chỗ hoặc cái gì đó. Kiểm tra lại mã của bạn vì không thấy mã của bạn, tôi thậm chí không biết bắt đầu từ đâu. –
Tôi đã mã hóa giải pháp mã hóa đầu tiên mà bạn đã đưa ra trong câu trả lời này bắt đầu bằng ' Php $ info = 'USER = [API_USERNAME]' . '& PWD = [API_PASSWORD]' . '& SIGNATURE = [API_SIGNATURE]' . '& VERSION = 94' . '& METHOD = GetTransactionDetails' . '& TRANSACTIONID = [TRANSACTION_ID]' 'Tôi đã thay đổi tên người dùng, pwd và chữ ký của mình nhưng không hoạt động. –