CodeIgniter Forums

Full Version: [SOLVED] Paypal_lib probs
You're currently viewing a stripped down version of our content. View the full version with proper formatting.

El Forum

[eluser]stuffradio[/eluser]
I'm using that Paypal_lib from the wiki. I have the IPN set to mysite.com/index.php/jobs/ipn.

This is the code for ipn

Code:
function ipn()
    {
        // Payment has been received and IPN is verified.  This is where you
        // update your database to activate or process the order, or setup
        // the database with the user's order details, email an administrator,
        // etc. You can access a slew of information via the ipn_data() array.

        // Check the paypal documentation for specifics on what information
        // is available in the IPN POST variables.  Basically, all the POST vars
        // which paypal sends, which we send back for validation, are now stored
        // in the ipn_data() array.

        // For this example, we'll just email ourselves ALL the data.
        //$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";*/
            
            $data = $this->paypal_lib->ipn_data;

            $this->job->id = $this->paypal_lib->ipn_data['custom'];
            $this->job->finalize();
            $message = "IPN has been hit... job id\n";
            $message .= $this->paypal_lib->ipn_data['custom'];
        }
    }

This is the form

Code:
$this->paypal_lib->add_field('business', $paypaladdress->paypalemail);
        $this->paypal_lib->add_field('return', site_url('jobs/completed/thankyou'));
        $this->paypal_lib->add_field('cancel_return', site_url('jobs/completed'));
        $this->paypal_lib->add_field('notify_url', site_url('jobs/ipn')); // <-- IPN url
        $this->paypal_lib->add_field('custom', $paypalstuff->id); // <-- Verify return

        $this->paypal_lib->add_field('item_name', $paypalstuff->title);
        $this->paypal_lib->add_field('item_number', '6941');
        $this->paypal_lib->add_field('amount', $paypalstuff->money);

        // if you want an image button use this:
        //$this->paypal_lib->image('button_03.gif');
        
        // otherwise, don't write anything or (if you want to
        // change the default button text), write this:
         $this->paypal_lib->button('Click to Pay!');
        
        $data['paypal_form'] = $this->paypal_lib->paypal_form();

The IPN history says it's going to the correct url with a response of 200.

What am I missing? Why won't it go update the db?

Here is the DB part

Code:
function finalize()
    {
        $this->db->query("UPDATE `jobs` SET `status`='Complete' WHERE `id`='$this->id'");
        $this->db->query("INSERT INTO `paypallog` (text) VALUES ('Hit')");
    }

Any help is appreciated!

El Forum

[eluser]stuffradio[/eluser]
It wasn't working out, so I just used a single file instead of CI to do it and it works.

This can be closed.