最近在做一个paypal支付的,不过PDT的全是php和ASP的代码,没有java的;所以···谁有java的代码?<?php$req = 'cmd=_notify-synch';                //  String   req = 'cmd=_notify-synch';      $tx_token = $_GET['tx'];                     //String  tx_token = request.getParameter("tx");    //String    auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";
$auth_token = "GX_sTf5bW3wxRfFEbgofs88nQxvMQ7nsI8m21rzNESnl_79ccFTWj2aPgQ0";   
 
 //req += '&tx=$tx_token&at=$auth_token';
$req .= "&tx=$tx_token&at=$auth_token";
// header  += "";
$header .= "POST /cgi-bin/webscr HTTP/1.0\r\n";
$header .= "Content-Type: application/x-www-form-urlencoded\r\n";
$header .= "Content-Length: " . strlen($req) . "\r\n\r\n";
//  fsockopen 
$fp = fsockopen ('www.paypal.com', 80, $errno, $errstr, 30);
if (!$fp) {    
// HTTP ERROR
} else {
fputs ($fp, $header . $req);    //  fuputs  php函数 :意思: 送一个字符串到一个流中
// read the body data 
$res = '';     //申明一个字符串
$headerdone = false;       // 申明一个bool 初始值为false
while (!feof($fp)) {      // feof php  函数 : 函数检测是否已到达文件末尾
$line = fgets ($fp, 1024);     //  fgets php 函数 :函数读取数据
if (strcmp($line, "\r\n") == 0) { strcmp  // php  函数 : 将字符串比较
// read the header
$headerdone = true;
}
else if ($headerdone)
{
// header has been read. now read the contents
$res .= $line;        // res +=line;
}
}// parse the data
$lines = explode("\n", $res);
$keyarray = array();
if (strcmp ($lines[0], "SUCCESS") == 0) {
for ($i=1; $i<count($lines);$i++){
list($key,$val) = explode("=", $lines[$i]);
$keyarray[urldecode($key)] = urldecode($val);
}
// check the payment_status is Completed
// check that txn_id has not been previously processed
// check that receiver_email is your Primary PayPal email
// check that payment_amount/payment_currency are correct
// process payment
$firstname = $keyarray['first_name'];                          //  $ 用来声明一个数据,声明类型看后面跟的值
$lastname = $keyarray['last_name'];
$itemname = $keyarray['item_name'];
$amount = $keyarray['payment_gross'];echo ("<p><h3>Thank you for your purchase!</h3></p>");     //  echo   是php 用来输出的语句echo ("<b>Payment Details</b><br>\n");
echo ("<li>Name: $firstname $lastname</li>\n");
echo ("<li>Item: $itemname</li>\n");
echo ("<li>Amount: $amount</li>\n");
echo ("");
}
else if (strcmp ($lines[0], "FAIL") == 0) {
// log for manual investigation
}}fclose ($fp);     //  关闭文件?>