Welcome Guest, Not a member yet? Register   Sign In
Paypal IPN
#1

[eluser]manilodisan[/eluser]
I used the library from the wiki and things go ok except for one issue. The ipn is not called by paypal. I've put a bug on the ipn page and, when called directly via url, it sends out an email, when I do a test transaction...no email is sent so it means that the ipn url is not called by paypal...

Any idea why?
#2

[eluser]CI Lee[/eluser]
Hello,

Have are you using a paypal sandbox account?

-Lee
#3

[eluser]manilodisan[/eluser]
Of course...Paypal makes it ok with everything and I always reach the "success" landing page but no ipn is called during this process...
#4

[eluser]CI Lee[/eluser]
I dont know if it makes a difference but PP posts to your url, will your script still send then?

What does it show in your logs and have you used the paypal_ipn dump?

Also it should be noted somewhere, maybe not for you, but the pp_txn does not get used by paypal on the sandbox site... that was hours of frustration for me.

-Lee
#5

[eluser]manilodisan[/eluser]
The dump shows everything ok. All url's (cancel, success, ipn) are as they should, tested and functional in my browser.

The logs show nothing as I'm not there yet. At this moment, the ipn url is only set to send a dummy email when it's called (no fancy variables and parameters involved, just a dummy email). This is as basic as can be in order to test if the url is called by paypal or not. When accessed in the browser, the email pops...when I complete a transaction with the sandbox account...no email arrives. Sad
#6

[eluser]CI Lee[/eluser]
Well thats what I mean, PayPal does not browse to your site... it posts info to your paypal ipn url. You could test that by creating a form like this...
Code:
<form action="<?=base_url();?>paypal/ipn" method="post">

It doesnt matter what the fields are, and if you submit the form and it does'nt send an email then you know that you are more than likely hitting the ipn url, just your code to send the email only works with GET requests not POST like paypal uses.

Still the dump and logs will tell you straight away,

-Lee
#7

[eluser]CI Lee[/eluser]
try emailing yourself the ipn data...
Code:
function ipn(){

$to    = '[email protected]';    //  your email
if ($this->paypal_lib->validate_ipn())
        {
            $body  = 'An instant payment notification was successfully received from ';
            $body .= $this->paypal_lib->ipn_data['payer_email'] . ' on '.date('m/d/Y') . ' at ' . date('g:i A') . "\n\n";
            $body .= " Details:\n";

            foreach ($this->paypal_lib->ipn_data as $key=>$value)
                $body .= "\n$key: $value";
    
            // load email lib and email results
            $this->load->library('email');
            $this->email->to($to);
            $this->email->from($this->paypal_lib->ipn_data['payer_email'], $this->paypal_lib->ipn_data['payer_name']);
            $this->email->subject('IPN (Received Payment)');
            $this->email->message($body);    
            $this->email->send();
        }
    }
}

-Lee
#8

[eluser]manilodisan[/eluser]
I do email the results. Well, if paypal doesn't browse my site it means that the ipn fails to validate. What could be the possible reason for that? Here's my code:
Code:
function dopurchase ()
    {
        $getscript = $this->master->get_script ( $this->uri->segment ( 3 ) );
        $row = $getscript->row ();
        $data [ 'row' ] = $row;

        if ( $this->session->userdata ( 'logged_in' ) ) {
            $buyer_id = $this->session->userdata ( 'user_id' );
        }
        elseif ( isset ( $_SESSION [ 'buyer_id' ] ) ) {
            $buyer_id = $_SESSION [ 'buyer_id' ];
        }
            
        if ( ! isset ( $buyer_id ) ) {
            $data [ 'msg' ] = setErrors ( 'invalid_username' );
            $this->load->view ( 'purchase', $data );
        }
        else {
            $this->paypal->paypal_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';

            $action = ( $this->uri->segment ( 4 ) ) ? $this->uri->segment ( 4 ) : 'process';

            switch ( $action )
            {
                case 'process':
                    $this->paypal->add_field ( 'business', '[email protected]' );
                    $this->paypal->add_field ( 'return', site_url('purchase/dopurchase/' . $this->uri->segment ( 3 ) . '/success') );
                    $this->paypal->add_field ( 'cancel_return', site_url('purchase/dopurchase/' . $this->uri->segment ( 3 ) . '/cancel') );
                    $this->paypal->add_field ( 'notify_url', site_url('purchase/dopurchase/' . $this->uri->segment ( 3 ) . '/ipn') );
                    $this->paypal->add_field ( 'item_name', $row->title );
                    $this->paypal->add_field ( 'amount', $row->price );
                    $this->paypal->add_field ( 'buyer_id', $buyer_id );

                    echo $this->paypal->paypal_auto_form();
                break;

                case 'success':
                    $data [ 'msg' ] = 'The order was successfull!';
                    $this->load->view ( 'order_success', $data );
                break;

                case 'cancel':
                    $data [ 'msg' ] = 'The order was cancelled!';
                    $this->load->view ( 'order_cancel', $data );
                break;

                case 'ipn':
                    $this->load->helper ( 'email' );//load the email helper

                    if ( $this->paypal->validate_ipn () ) {
                        $this->master->insertNEWorder ( $this->paypal->ipn_data['buyer_id'], $row->ID, $row->price );//insert the new order
                        new_purchase ( $this->paypal->ipn_data['buyer_id'], $this->paypal->ipn_data );//send me the email
                    }
                break;
            }
        }
    }
#9

[eluser]CI Lee[/eluser]
I don't think you follow what I am saying.

When you browse to a site your browser uses the GET method to acquire the information, what paypal does is POST information to the IPN url you have specified similar to what that form example would do. They are not going there for information so they are not using a browser they are pushing information to you.

Do you see what I mean?

If you tried the form test that I showed you, I am sure you would see the difference between the two.

-Lee
#10

[eluser]manilodisan[/eluser]
Ok...following what you said with the form pointing to the ipn url, the app. wrote an invalid response from Paypal. One question: In sandbox, does any of the fake transactions bring a verified response from Paypal? I have 3 transactions on my paypal log file (one of them was done directly by me with the form) and all of them are INVALID.




Theme © iAndrew 2016 - Forum software by © MyBB