Note that there are some explanatory texts on larger screens.

plurals
  1. POPaypal with IPN in PHP not working in new Beta developer sandbox
    primarykey
    data
    text
    <p>i had integrated PayPal with IPN in PHP, before new Paypal development it redirect to sandbox and successfully login with Sandbox it allow to test payment, now its redirect to beta developer site and not going to test the payment,</p> <p>following is PHP Paypal class i used,</p> <pre><code>class paypal_class { var $error; // holds the error encountered var $ipn_log; // log IPN results var $ipn_log_file; // filename of the IPN log var $ipn_response; // holds the IPN response from PayPal var $ipn_data = array(); // contains the POST values for IPN var $fields = array(); // holds the fields to submit to PayPal function paypal_class() { // constructor. $this-&gt;paypal_url = 'https://www.paypal.com/cgi-bin/webscr'; $this-&gt;error = ''; $this-&gt;ipn_log_file = '.ipn_results.log'; $this-&gt;ipn_log = true; $this-&gt;ipn_response = ''; $this-&gt;add_field('rm','2'); // Return method = POST $this-&gt;add_field('cmd','_xclick'); } function add_field($field, $value) { // adds a key=&gt;value pair to the fields array $this-&gt;fields["$field"] = $value; } function submit_paypal_post() { // generates an HTML page consisting of // a form with hidden elements which is submitted to PayPal echo "&lt;html&gt;\n"; echo "&lt;head&gt;&lt;title&gt;Processing...&lt;/title&gt;&lt;/head&gt;\n"; echo "&lt;body onLoad=\"document.forms['paypal_form'].submit();\"&gt;\n"; echo "&lt;center&gt;&lt;h2&gt;Please wait, your order is being processed and you"; echo " will be redirected to the paypal website.....&lt;/h2&gt;&lt;/center&gt;\n"; echo "&lt;form method=\"post\" name=\"paypal_form\" "; echo "action=\"".$this-&gt;paypal_url."\"&gt;\n"; foreach ($this-&gt;fields as $name =&gt; $value) { echo "&lt;input type=\"hidden\" name=\"$name\" value=\"$value\"/&gt;\n"; } echo "&lt;center&gt;&lt;br/&gt;&lt;br/&gt;If you are not automatically redirected to "; echo "paypal within 5 seconds...&lt;br/&gt;&lt;br/&gt;\n"; echo "&lt;input type=\"submit\" value=\"Click Here\"&gt;&lt;/center&gt;\n"; echo "&lt;/form&gt;\n"; echo "&lt;/body&gt;&lt;/html&gt;\n"; } function validate_ipn() { // parse the paypal URL $url_parsed=parse_url($this-&gt;paypal_url); // generate the post string from the _POST vars $post_string = ''; foreach ($_POST as $field=&gt;$value) { $this-&gt;ipn_data["$field"] = $value; $post_string .= $field.'='.urlencode (stripslashes ($value)).'&amp;'; } $post_string .= "cmd=_notify-validate"; // open the connection to paypal $fp = fsockopen($url_parsed[host],"80",$err_num,$err_str,30); if(!$fp) { // Print the error if not able to open the connection. $this-&gt;error = "Error no. $errnum: $errstr"; $this-&gt;log_ipn_results(false); return false; } else { // Post 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-&gt;ipn_response .= fgets($fp, 1024); } fclose($fp); // close connection } if (eregi("VERIFIED",$this-&gt;ipn_response)) { // Valid IPN. $this-&gt;log_ipn_results(true); return true; } else { // Invalid IPN. $this-&gt;error = 'IPN Validation Failed.'; $this-&gt;log_ipn_results(false); return false; } } function log_ipn_results($success) { if (!$this-&gt;ipn_log) return; // Timestamp $text = '['.date('m/d/Y g:i A').'] - '; // Success or failure if ($success) $text .= "SUCCESS!\n"; else $text .= 'FAIL: '.$this-&gt;error."\n"; // Log the POST variables $text .= "IPN POST Values from Paypal:\n"; foreach ($this-&gt;ipn_data as $key=&gt;$value) { $text .= "$key=$value, "; } // response from the paypal server $text .= "\nIPN Response from Paypal Server:\n ".$this-&gt;ipn_response; // Write to log $fp=fopen($this-&gt;ipn_log_file,'a'); fwrite($fp, $text . "\n\n"); fclose($fp); // close file } } </code></pre> <p>Thanks in Advance,</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload