PHP Paypal IPN return valideerd niet
met die code doet het script het niet en zonder wel.
echter moet hij wel controleren of het gelukt is of niet.
hierbij de controle code :
Quote:
Code (php)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
require_once('paypal.class.php');
require_once('whm.class.php');
// include the class file
$p = new paypal_class;
if ($p->validate_ipn()) { << [b][i][u]HIER GAAT HET OM IS DIT WEG WERKT HET WEL ANDERS NIET![/u][/i][/b]
include "config.php";
mysql_connect("$host", "$username", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$pid = $_GET['pid'];
$m1 = $_GET['name'];
$m2 = $_GET['lastname'];
$m3 = $_GET['street'];
$m4 = $_GET['Zip'];
$m5 = $_GET['country'];
$m6 = $_GET['username'];
$m7 = $_GET['password'];
$m8 = $_GET['domain'];
$m9 = $_GET['email'];
$mk = $_GET['kosten'];
if ($pid == 1)
{
$pack = "****";
$p2 = "basic";
}
if ($pid == 2)
{
$pack = "****";
$p2 = "PRO";
}
if ($pid == 3)
{
$pack = "****";
$p2 = "Developer pack";
}
if ($pid == 4)
{
$pack = "****";
$p2 = "ultimate";
}
if ($pid == 5)
{
$pack = "****";
$p2 = "clanpack";
}
//$WHM = new WHM( false , '*****' , '*****' , '******');
// $return = $WHM->create_account($m8,$m6,$m7,$m9,$pack);
// if (empty($return['domain'])) {
// $error = $return;
// }
// else
// {
// $u1 = $return['domain'];
// $u2 = $return['username'];
// $u3 = $return['password'];
// $u4 = $return['package'];
// $u5 = $return['nameserver1'];
// $u6 = $return['nameserver2'];
// $u7 = $return['account_info'];
// }
$mydate = date( 'Y-m-d' );
// For this example, we'll just email ourselves ALL the data.
$subject = 'New Payment for account';
$to = 'payment@********'; // your email
$body = "is there a error?{ ".$error." } your account info : <br/> username:".$u2."<br/> password: ".$u3."<br/> Domain: ".$u1." <br/> Please point your domain to : ".$u5." and ".$m6." <br/> other information : ".$u7." <br/>";
$body .= "".$pid."".$m1."".$m2."".$m3."".$m4."".$m5."".$m6."".$m7."".$m8."".$m9."".$mk."".$mp."".$pack."";
$body .= "from ".$p->ipn_data['payer_email']." on ".date('m/d/Y');
$body .= " at ".date('g:i A')."\n\nDetails:\n";
mail($to, $subject, $body);
$sql2="INSERT INTO `*******_clientarea`.`clients` (`id` ,`voornaam` ,`achternaam` ,`adress` ,`postcode` ,`land` ,`email` ,`username` ,`pass` ,`start` ,`kostenpm` ,`package` ,`packstatus`)VALUES (NULL , '".$m1."', '".$m2."', '".$m3."', '".$m4."', '".$m5."', '".$m9."', '".$m6."', '".$m7."', '".$mydate."', '".$mk."', '".$p2."', 'active');";
$result2=mysql_query($sql2);
$subject2 = 'Instant Payment Notification - payment complete!';
$body2 = ' <center><IMG SRC="http://******.****/wpimages/wp57182a00.png" ALT="client area"></center> <br/><br/><br/>we have your payment succesfully and created your account. <br/> you can always access your client area from the site or visit http://******/cpanel to go to CPanel for your account <br/>';
$body2 .= "your account info : <br/> username:'.$u2.'<br/> password: '.$u3.'<br/> Domain: '.$u1.' <br/> Please point your domain to : '.$u5.' and '.$u6.' <br/> other information : '.$u7.' <br/>";
$body2 .= "Thanks for hosting with **** ! and see you soon! <br/>";
$body2 .= "Good luck! M.Groeneveld **** Service center for support contact us at support@*****.*** or Using our Live chat/skype";
mail($m9, $subject2, $body2);
}
?>
require_once('paypal.class.php');
require_once('whm.class.php');
// include the class file
$p = new paypal_class;
if ($p->validate_ipn()) { << [b][i][u]HIER GAAT HET OM IS DIT WEG WERKT HET WEL ANDERS NIET![/u][/i][/b]
include "config.php";
mysql_connect("$host", "$username", "$pass")or die("cannot connect");
mysql_select_db("$db")or die("cannot select DB");
$pid = $_GET['pid'];
$m1 = $_GET['name'];
$m2 = $_GET['lastname'];
$m3 = $_GET['street'];
$m4 = $_GET['Zip'];
$m5 = $_GET['country'];
$m6 = $_GET['username'];
$m7 = $_GET['password'];
$m8 = $_GET['domain'];
$m9 = $_GET['email'];
$mk = $_GET['kosten'];
if ($pid == 1)
{
$pack = "****";
$p2 = "basic";
}
if ($pid == 2)
{
$pack = "****";
$p2 = "PRO";
}
if ($pid == 3)
{
$pack = "****";
$p2 = "Developer pack";
}
if ($pid == 4)
{
$pack = "****";
$p2 = "ultimate";
}
if ($pid == 5)
{
$pack = "****";
$p2 = "clanpack";
}
//$WHM = new WHM( false , '*****' , '*****' , '******');
// $return = $WHM->create_account($m8,$m6,$m7,$m9,$pack);
// if (empty($return['domain'])) {
// $error = $return;
// }
// else
// {
// $u1 = $return['domain'];
// $u2 = $return['username'];
// $u3 = $return['password'];
// $u4 = $return['package'];
// $u5 = $return['nameserver1'];
// $u6 = $return['nameserver2'];
// $u7 = $return['account_info'];
// }
$mydate = date( 'Y-m-d' );
// For this example, we'll just email ourselves ALL the data.
$subject = 'New Payment for account';
$to = 'payment@********'; // your email
$body = "is there a error?{ ".$error." } your account info : <br/> username:".$u2."<br/> password: ".$u3."<br/> Domain: ".$u1." <br/> Please point your domain to : ".$u5." and ".$m6." <br/> other information : ".$u7." <br/>";
$body .= "".$pid."".$m1."".$m2."".$m3."".$m4."".$m5."".$m6."".$m7."".$m8."".$m9."".$mk."".$mp."".$pack."";
$body .= "from ".$p->ipn_data['payer_email']." on ".date('m/d/Y');
$body .= " at ".date('g:i A')."\n\nDetails:\n";
mail($to, $subject, $body);
$sql2="INSERT INTO `*******_clientarea`.`clients` (`id` ,`voornaam` ,`achternaam` ,`adress` ,`postcode` ,`land` ,`email` ,`username` ,`pass` ,`start` ,`kostenpm` ,`package` ,`packstatus`)VALUES (NULL , '".$m1."', '".$m2."', '".$m3."', '".$m4."', '".$m5."', '".$m9."', '".$m6."', '".$m7."', '".$mydate."', '".$mk."', '".$p2."', 'active');";
$result2=mysql_query($sql2);
$subject2 = 'Instant Payment Notification - payment complete!';
$body2 = ' <center><IMG SRC="http://******.****/wpimages/wp57182a00.png" ALT="client area"></center> <br/><br/><br/>we have your payment succesfully and created your account. <br/> you can always access your client area from the site or visit http://******/cpanel to go to CPanel for your account <br/>';
$body2 .= "your account info : <br/> username:'.$u2.'<br/> password: '.$u3.'<br/> Domain: '.$u1.' <br/> Please point your domain to : '.$u5.' and '.$u6.' <br/> other information : '.$u7.' <br/>";
$body2 .= "Thanks for hosting with **** ! and see you soon! <br/>";
$body2 .= "Good luck! M.Groeneveld **** Service center for support contact us at support@*****.*** or Using our Live chat/skype";
mail($m9, $subject2, $body2);
}
?>
Is die class door jezelf gemaakt?
Quote:
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.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)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (eregi("VERIFIED",$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;
}
}
// 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.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)) {
$this->ipn_response .= fgets($fp, 1024);
}
fclose($fp); // close connection
}
if (eregi("VERIFIED",$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;
}
}
dat is de functie
Toevoeging op 04/05/2011 19:12:36:
o en dit is de error in de IPN LOG
[04/29/2011 7:55 PM] - FAIL: IPN Validation Failed.
IPN POST Vars from Paypal:
IPN Response from Paypal Server:
HTTP/1.1 200 OK
Date: Fri, 29 Apr 2011 17:55:27 GMT
Server: Apache
Set-Cookie: cwrClyrK4LoCV1fydGbAxiNL6iG=Ad_My0WFQHGGQnKgdLakvcu5OtVVszbZ5RvZW3ksmQeXKmF9YdZ-RHqRo3WbuDg1a5LtbW_N-pFZSRi4iFaUjWLLtskcCL2JaG1rrMfXOGyGb0sH_RO4uJxZAzafQ5IjDY0uIG%7cQuU9kkinwPXaoM9RfUK_L6bwATdsSOtM2S8emIk3Sh0F3vTtO74pgo5qOGnFFDwFwBDF6m%7cWp9BEPwEFOj8amzxGCdoHYxc05JVDNjFZYokJYzXrdxbTAEVrV-1yuCrB2XRSAKsaBheM0%7c1304099728; domain=.paypal.com; path=/; HttpOnly
Set-Cookie: cookie_check=yes; expires=Mon, 26-Apr-2021 17:55:28 GMT; domain=.paypal.com; path=/; HttpOnly
Set-Cookie: navcmd=_notify-validate; domain=.paypal.com; path=/; HttpOnly
Set-Cookie: navlns=0.0; expires=Thu, 24-Apr-2031 17:55:28 GMT; domain=.paypal.com; path=/; HttpOnly
Vary: Accept-Encoding
Connection: close
Transfer-Encoding: chunked
Content-Type: text/html; charset=UTF-8
7
INVALID
das kut