• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Problem with IPN paypal after update

#1
Hi guys,

I have a big problem with my IPN paypal after the update codeigniter.

PHP Code:
public function ipn() {
        if (!
count($_POST)) {
            throw new 
Exception("Missing POST Data");
        }
        
$raw_post_data file_get_contents('php://input');
        
$raw_post_array explode('&'$raw_post_data);
        
$myPost = [];
        foreach (
$raw_post_array as $keyval) {
            
$keyval explode('='$keyval);
            if (
count($keyval) == 2) {
                if (
$keyval[0] === 'payment_date') {
                    if (
substr_count($keyval[1], '+') === 1) {
                        
$keyval[1] = str_replace('+''%2B'$keyval[1]);
                    }
                }
                
$myPost[$keyval[0]] = urldecode($keyval[1]);
            }
        }
        
$req 'cmd=_notify-validate';
        
$get_magic_quotes_exists false;
        if (
function_exists('get_magic_quotes_gpc')) {
            
$get_magic_quotes_exists true;
        }
        foreach (
$myPost as $key => $value) {
            if (
$get_magic_quotes_exists == true && get_magic_quotes_gpc() == 1) {
                
$value urlencode(stripslashes($value));
            } else {
                
$value urlencode($value);
            }
            
$req .= "&$key=$value";
        }
        
$ch curl_init(info('link_paypal''shop'));
        
curl_setopt($chCURLOPT_HTTP_VERSIONCURL_HTTP_VERSION_1_1);
        
curl_setopt($chCURLOPT_POST1);
        
curl_setopt($chCURLOPT_RETURNTRANSFER,1);
        
curl_setopt($chCURLOPT_POSTFIELDS$req);
        
curl_setopt($chCURLOPT_SSL_VERIFYPEER1);
        
curl_setopt($chCURLOPT_SSL_VERIFYHOST2);
        
curl_setopt($chCURLOPT_FORBID_REUSE1);
        
curl_setopt($chCURLOPT_HTTPHEADER, array('Connection: Close'));
        
$res curl_exec($ch);
        
$info curl_getinfo($ch);
        
$http_code $info['http_code'];
        if (
$http_code != 200) {
            throw new 
Exception("PayPal responded with http code $http_code");
        }
        if (!(
$res)) {
            
$errno curl_errno($ch);
            
$errstr curl_error($ch);
            
curl_close($ch);
            throw new 
Exception("cURL error: [$errno$errstr");
        }
        
$my_file 'file.txt';
        
$handle fopen($my_file'w') or die('Cannot open file:  '.$my_file);
        
fwrite($handle$res);
        
curl_close($ch);
        if (
$res == 'VERIFIED') {
            
$payment_amount $myPost['mc_gross'];
            
$payment_currency $myPost['mc_currency'];
            
$txn_id $myPost['txn_id'];
            
$payer_email $myPost['payer_email'];
            
$custom explode('|'$myPost['custom']);
            
$userID $custom[0];
            
$username $custom[1];
            
$custom $myPost['custom'];
            
$payment_status $myPost['payment_status'];
            
$this->load->model('shop/donations');
            
$this->donations->add_coins($payment_amount$payment_currency$txn_id$payer_email$userID$username);
            return 
true;
        } else {
            return 
false;
        }
    } 

And this is the form

PHP Code:
{form url="https://www.sandbox.paypal.com/cgi-bin/webscr" type=""}
                            <
input type="hidden" name="cmd" value="_xclick" />
                            <
input type="hidden" name="item_name" value="tester" />
                            <
input type="hidden" name="business" value="email"/>
                            <
input type="hidden" name="notify_url" value="{base_url}index.php/shop/donation/ipn" />
                            <
input type="hidden" name="return" value="{base_url}index.php/shop/donation/success" />
                                <
input type="hidden" name="cancel_return" value="{base_url}index.php/shop/donation/delete" />
                            <
input type="hidden" name="rm" value="2" />
                            <
input type="hidden" name="no_note" value="1" />
                            <
input type="hidden" name="no_shipping" value="1" />
                            <
input type="hidden" name="currency_code" value="EUR" />
                            <
input type="hidden" name="page_style" value="paypal" />
                            <
select name="amount">
                                {foreach 
$donation_view as $dv}
                                    <
option value="{$dv.price}">{$dv.name}</option>
                                {/foreach}
                                  </
select>
                            <
input value="Donate" type="submit" name="submit" />
                        {
form


Before updating the codeigniter files it worked perfectly.

Now when I make a donation I can not make any mistakes in any way is like PayPal does not contact ipn.

Instead if I go to the ipn link, it returns the various errors.

How can I fix this problem?

I look forward to your answer.



EDIT: Sorry, I write in a wrong section
Reply

#2
I rewrite the code and works perfectly Wink
Reply


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


Users browsing this thread:
1 Guest(s)


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2017 MyBB Group.