このクラスを使用しています
<?php
class paypalIPN {
//sandbox:
private $paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
//live site:
//private $paypal_url = 'https://www.paypal.com/cgi-bin/webscr';
private $data = null;
public function __construct()
{
$this->data = new stdClass;
}
public function isa_dispute()
{
//is it some sort of dispute.
return $this->data->txn_type == "new_case";
}
public function validate()
{
// parse the paypal URL
$response = "";
$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->data->$field = $value;
$post_string .= $field.'='.urlencode(stripslashes($value)).'&';
}
$post_string.="cmd=_notify-validate"; // append ipn command
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $this->paypal_url);
//curl_setopt($ch, CURLOPT_VERBOSE, 1);
//keep the peer and server verification on, recommended
//(can switch off if getting errors, turn to false)
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);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_string);
$response = curl_exec($ch);
if (curl_errno($ch))
{
die("Curl Error: " . curl_errno($ch) . ": " . curl_error($ch));
}
curl_close($ch);
return $response;
if (preg_match("/VERIFIED/", $response))
{
// Valid IPN transaction.
return $this->data;
}
else
{
return false;
}
}
}
そして、私はこのモードで思い出します:
public function get_ipn()
{
$ipn = new paypalIPN();
$result = $ipn->validate();
$logger = new Log('/error.log');
$logger->write(print_r($result));
}
しかし、「VERIFIED」または「1」しか取得できません(抜き差しまたはprint_r関数を使用)。
生のカール応答を直接返すことも試みました
return $response;
また
return $this->response;
またはまた
return $this->parse_string;
しかし、毎回「1」または「VERIFIED」しか受け取りません.......
どうもありがとうございました