/ / Wykorzystanie niezdefiniowanego stałego hosta - zakładany błąd „hosta” w klasie paypal (biblioteka Codeigniter) - php, codeigniter, paypal, paypal-sandbox, paypal-ipn

Wykorzystanie niezdefiniowanego stałego hosta - założony błąd hosta w klasie paypal (codeigniter library) - php, codeigniter, paypal, paypal-sandbox, paypal-ipn

Korzystam z biblioteki Codeigniter o nazwie paypal_class. Wszystko jest w porządku, ale przy sprawdzaniu poprawności funkcji ipn pojawia się ten błąd. Use of undefined constant host - assumed "host" co musi być przyczyną, że poczta nie jest wysyłana do użytkownika. Nic nie jest zwracane.

Jestem nowy w PayPal. Mam więc nadzieję na szczegółowe rozwiązanie. Dziękuję Ci. Proszę pytać o wszelkie inne wymagane informacje.


Błąd występuje w tej linii:

 $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30);

gdzie

$url_parsed = parse_url($this->paypal_url);

oto funkcja ipn:

    function validate_ipn() {

// parse the paypal URL
$url_parsed = parse_url($this->paypal_url);

// generate the post string from the _POST vars aswell as load the
// _POST vars into an arry so we can play with them from the calling
// script.
$post_string = "";
foreach ($_POST as $field => $value) {
$this->ipn_data["$field"] = $value;
$post_string .= $field . "=" . urlencode(stripslashes($value)) . "&";
}
$post_string.="cmd=_notify-validate"; // append ipn command
// open the connection to paypal
$fp = fsockopen($url_parsed["host"], "80", $err_num, $err_str, 30);
if (!$fp) {

// could not open the connection.  If loggin is on, the error message
// will be in the log.
$this->last_error = "fsockopen error no. $errnum: $errstr";
$this->log_ipn_results(false);
return false;
} else {

// Post the data back to paypal
fputs($fp, "POST $url_parsed[path] HTTP/1.1rn");
fputs($fp, "Host: $url_parsed[host]rn");
fputs($fp, "Content-type: application/x-www-form-urlencodedrn");
fputs($fp, "Content-length: " . strlen($post_string) . "rn");
fputs($fp, "Connection: closernrn");
fputs($fp, $post_string . "rnrn");

// loop through the response from the server and append to variable
while (!feof($fp)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}

if (preg_match("/VERIFIED/i", $this->ipn_response)) {

// Valid IPN transaction.
$this->log_ipn_results(true);
return true;
} else {

// Invalid IPN transaction.  Check the log for details.
$this->last_error = "IPN Validation Failed.";
$this->log_ipn_results(false);
return false;
}
}

Odpowiedzi:

1 dla odpowiedzi № 1

musisz to zmienić:

 $fp = fsockopen($url_parsed[host], "80", $err_num, $err_str, 30);

do

 $fp = fsockopen($url_parsed["host"], "80", $err_num, $err_str, 30);

następnie debuguj zwróconą wartość tutaj:

$url_parsed = parse_url($this->paypal_url);
var_dump($url_parsed);