这可能有什么错误?我真的无法说出上述脚本中的错误,并且代码完整无缺,API内的设置也很好,也许有人可以帮我解决这个问题
Paypalapi.php
<?php
class PaypalApi {
public function __construct($username='', $password='', $signature='')
{
$this->username = urlencode("abne_ceejay_api1.yahoo.com");
$this->password = urlencode("ZQBSRB26EUEE45EV");
$this->signature = urlencode("A9BiAtHlNpvdHOX3mPrOVBHDOETPAxPLD9F-1SSya0f8zZiJv6S.0V4v");
$this->version = urlencode("51.0");
$this->api = "https://api-3t.paypal.com/nvp";
//$this->api = "https://api-3t.sandbox.paypal.com/nvp";
//The functions can be modified but need to be urlencoded
$this->type = urlencode("EmailAddress");
$this->currency = urlencode("USD");
$this->subject = urlencode("Instant Paypal Payment");
}
public function pay($email, $amount, $note="Instant Payment") {
$string = "&EMAILSUBJECT=".$this->subject."&RECEIVERTYPE=".$this->type."&CURRENCYCODE=".$this->currency;
$string .= "&L_EMAIL0=".urlencode($email)."&L_Amt0=".urlencode($amount)."&L_NOTE0=".urlencode($note);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->api);
curl_setopt($ch, CURLOPT_VERBOSE, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
$request = "METHOD=MassPay&VERSION=".$this->version."&PWD=".$this->password."&USER=".$this->username."&SIGNATURE=".$this->signature."$string";
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
$httpResponse = curl_exec($ch);
if(!$httpResponse) {
exit("MassPay failed: ".curl_error($ch).'('.curl_errno($ch).')');
}
$httpResponseArray = explode("&", $httpResponse);
$httpParsedResponse = array();
foreach ($httpResponseArray as $i => $value) {
$tempArray = explode("=", $value);
if(sizeof($tempArray) > 1) {
$httpParsedResponse[$tempArray[0]] = $tempArray[1];
}
}
if((0 == sizeof($httpParsedResponse)) || !array_key_exists('ACK', $httpParsedResponse)) {
exit("Invalid HTTP Response for POST request($request) to ".$this->api);
}
return $httpParsedResponse;
}
}?>
这是
Paypal IPN
<?php
class PayPal_IPN {
function infotuts_ipn($im_debut_ipn) {
define('SSL_P_URL', 'https://www.paypal.com/cgi-bin/webscr');
define('SSL_SAND_URL', 'https://www.sandbox.paypal.com/cgi-bin/webscr');
$hostname = gethostbyaddr($_SERVER['REMOTE_ADDR']);
if (!preg_match('/paypal\.com$/', $hostname)) {
$ipn_status = 'Validation post isn\'t from PayPal';
if ($im_debut_ipn == true) {
echo "mail testing";
// mail test
}
echo "no mail testing";
return false;
}
// parse the paypal URL
$paypal_url = ($_REQUEST['test_ipn'] == 1) ? SSL_SAND_URL : SSL_P_URL;
$url_parsed = parse_url($paypal_url);
$post_string = '';
foreach ($_REQUEST as $field => $value) {
$post_string .= $field . '=' . urlencode(stripslashes($value)) . '&';
}
$post_string.="cmd=_notify-validate"; // append ipn command
// get the correct paypal url to post request to
$paypal_mode_status = $im_debut_ipn; //get_option('im_sabdbox_mode');
if ($paypal_mode_status == true)
$fp = fsockopen('ssl://www.sandbox.paypal.com', "443", $err_num, $err_str, 60);
else
$fp = fsockopen('ssl://www.paypal.com', "443", $err_num, $err_str, 60);
$ipn_response = '';
echo "<br/>user:".$fb;
if (!$fp) {
// could not open the connection. If loggin is on, the error message
// will be in the log.
$ipn_status = "fsockopen error no. $err_num: $err_str";
if ($im_debut_ipn == true) {
echo 'fsockopen fail';
}
return false;
} else {
// Post the data back to paypal
fputs($fp, "POST $url_parsed[path] HTTP/1.1\r\n");
fputs($fp, "Host: $url_parsed[host]\r\n");
fputs($fp, "Content-type: application/x-www-form-urlencoded\r\n");
fputs($fp, "Content-length: " . strlen($post_string) . "\r\n");
fputs($fp, "Connection: close\r\n\r\n");
fputs($fp, $post_string . "\r\n\r\n");
// loop through the response from the server and append to variable
while (!feof($fp)) {
$ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
// Invalid IPN transaction. Check the $ipn_status and log for details.
if (!preg_match("/VERIFIED/s", $ipn_response)) {
$ipn_status = 'IPN Validation Failed';
if ($im_debut_ipn == true) {
echo 'Validation fail';
print_r($_REQUEST);
}
return false;
} else {
$ipn_status = "IPN VERIFIED";
if ($im_debut_ipn == true) {
echo 'SUCCESS';
}
return true;
}
}
function ipn_response($request) {
$mail_status = mail("priya@arminfotech.org","Paypal payment",print_r($request,true));
if($mail_status) {
echo 'mailed';
} else {
echo 'no mail';
}
$im_debut_ipn=true;
if ($this->infotuts_ipn($im_debut_ipn)) {
// if paypal sends a response code back let's handle it
if ($im_debut_ipn == true) {
$sub = 'PayPal IPN Debug Email Main';
$msg = print_r($request, true);
$aname = 'infotuts';
//mail send
}
// process the membership since paypal gave us a valid +
// $this->insert_data($request);
return $request;
}
}
function issetCheck($post,$key) {
if(isset($post[$key])){
$return=$post[$key];
}
else{
$return='';
}
return $return;
}
// function insert_data($request) {
// require_once('dbconnect.php');
// $post=$request;
// $item_name=$this->issetCheck($post,'item_name');
// $amount=$this->issetCheck($post,'mc_gross');
// $currency=$this->issetCheck($post,'mc_currency');
// $payer_email=$this->issetCheck($post,'payer_email');
// $first_name=$this->issetCheck($post,'first_name');
// $last_name=$this->issetCheck($post,'last_name');
// $country=$this->issetCheck($post,'residence_country');
// $txn_id=$this->issetCheck($post,'txn_id');
// $txn_type=$this->issetCheck($post,'txn_type');
// $payment_status=$this->issetCheck($post,'payment_status');
// $payment_type=$this->issetCheck($post,'payment_type');
// $payer_id=$this->issetCheck($post,'payer_id');
// $create_date=date('Y-m-d H:i:s');
// $payment_date=date('Y-m-d H:i:s');
// mysqli_query($con,"INSERT INTO infotuts_transection_tbl (item_name,payer_email,first_name,last_name,amount,currency,country,txn_id,txn_type,payer_id,payment_status,payment_type,create_date,payment_date)
// VALUES ('$item_name','$payer_email','$first_name','$last_name','$amount','$currency','$country','$txn_id','$txn_type','$payer_id','$payment_status','$payment_type','$create_date','$payment_date')");
// mysqli_close($con);
// }
}
?>
我不是技术人员,我只是购买了整个脚本,而我的卖家也不再回复了,谢谢您!