Welcome Guest, Not a member yet? Register   Sign In
Unable to load requested class: paypal_lib
#1

[eluser]jiggs[/eluser]
help!

I just integrated a paypal system to my site using the paypal_lib library.

when i try to load this library from the init function $this->load->library('paypal_lib');

i get error


An Error Was Encountered

Unable to load the requested class: paypal_lib

*I have saved all the necessary files that came with this library to their appropriate locations:
config folder - paypallib_config.php
libraries folder - Paypal_Lib.php

applications folder - paypal.php
views folder - paypal/success.php, paypal/cancel.php, paypal/form.php

I do have my own classes saved under applications/library folder and they were called without problems. But paypal its never called and i get the above error when i run the app.





Can someone please help!! been trying to integrate this paypal system for a few days now...
#2

[eluser]jiggs[/eluser]
and BTW, it works on my localhost (xampp on windows) but not on my server (godaddy - linux)
config.php has been edited to reflect the localhost or the live server settings whichever is currently being used.
#3

[eluser]jiggs[/eluser]
and the only difference between my localhost and the live server is the .htaccess file on the root folder since windows cannot recognize an htaccess file. (other than config settings ofcourse)

my htaccess says:

<IfModule mod_rewrite.c>
Options +FollowSymLinks
RewriteEngine on
RewriteBase /
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ index.php?/$1 [QSA,L]
</IfModule>


I have tried to remove this file on the live server but to no avail. Could there be something else on the htaccess that needs to be placed ?
#4

[eluser]jiggs[/eluser]
just for the curious i have included the code from the controller class:


Code:
class Paypal extends Controller {

    function Paypal()
    {
        parent::Controller();
        $this->load->library('paypal_lib');
    }
    
    function index()
    {
        $this->form();
    }
    
    function form()
    {
        
        $this->paypal_lib->add_field('business', '[email protected]');
        $this->paypal_lib->add_field('return', site_url('paypal/thankyou'));
        $this->paypal_lib->add_field('cancel_return', site_url('application/cancelsubscription'));
        $this->paypal_lib->add_field('notify_url', site_url('paypal/ipn')); // <-- IPN url
        $this->paypal_lib->add_field('custom', '1234567890'); // <-- Verify return

        $this->paypal_lib->add_field('item_name', 'membership');
        $this->paypal_lib->add_field('item_number', '6941');
        $this->paypal_lib->add_field('amount', '197');

        // 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!');

        $this->paypal_lib->button('Secure Checkout - Paypal');

        $data['paypal_form'] = $this->paypal_lib->paypal_form();
    
        $this->view('paypal/form', $data);
        
    }

    function auto_form()
    {
        $this->paypal_lib->add_field('business', '[email protected]');
        $this->paypal_lib->add_field('return', site_url('paypal/success'));
        $this->paypal_lib->add_field('cancel_return', site_url('application/cancelsubscription'));
        $this->paypal_lib->add_field('notify_url', site_url('paypal/ipn')); // <-- IPN url
        $this->paypal_lib->add_field('custom', '1234567890'); // <-- Verify return

        $this->paypal_lib->add_field('item_name', 'membership');
        $this->paypal_lib->add_field('item_number', '6941');
        $this->paypal_lib->add_field('amount', '197');

        $this->paypal_lib->paypal_auto_form();
    }
    function cancelsubscription()
    {
        $this->view('paypal/cancel');
    }
    
    function thankyou()
    {
        // This is where you would probably want to thank the user for their order
        // or what have you.  The order information at this point is in POST
        // variables.  However, you don't want to "process" the order until you
        // get validation from the IPN.  That's where you would have the code to
        // email an admin, update the database with payment status, activate a
        // membership, etc.
    
        // You could also simply re-direct them to another page, or your own
        // order status page which presents the user with the status of their
        // order based on a database (which can be modified with the IPN code
        // below).

        $data['pp_info'] = $this->input->post();
        $this->view('application/thankyou', $data);
    }
    
    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";

            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('CI paypal_lib IPN (Received Payment)');
            $this->email->message($body);    
            $this->email->send();
        }
    }
}
?&gt;

there is really no difference except for some paypal variables.
and the codes doesnt really get to be read since from the initialization the paypal library is not called.
#5

[eluser]jiggs[/eluser]
a few things i have tried:

1. remove the .htaccess file, no good so i restored it
2. copied the Paypal_Lib.php to applications/library and system/libraries, one at a time - no good.
2. all my other classes are working within applications/library folder so i decided to move the Paypal_Lib.php back there.
3. on my config file there was a subclass prefix setting initially to be = 'MY_'; i tried toggling between this and a blank value - no good. so decided to move it back to MY_
4. the instant i deleted the call to the library from my controller everything seemed back to normal.

Im confused already please help!!!
#6

[eluser]johnwbaxter[/eluser]
You need it in system/application/libraries/ and it needs to be called Paypal_Lib.php

I reckon your problem is because the file name / load->library call is not capitalised properly.

You need a capital P and a capital L.

"Paypal_Lib.php"

Then you load it in your controller like this "$this->load->library('Paypal_Lib');"

You can copy and paste what i have put here and you'll be fine.
#7

[eluser]jiggs[/eluser]
audiopleb, you are my angel

hehehe

all the while i thought there was no difference between calling native libraries and my own libraries.

thanks a lot man! and sorry for being an idiot.


case closed.
#8

[eluser]johnwbaxter[/eluser]
Yeah, that drove me bananas for a while when i was doing some paypal action.

Also the email config (if you're using e-mail and a separate config file in something) file needs to be a capital E. Which it doesn't mention in the user_guide.

Glad it worked out for you.
#9

[eluser]ontguy[/eluser]
I encountered this problem as well.

A couple fixes worked:
1. with the file name "Paypal_Lib.php", load it as:
Code:
$this->load->library('paypal_Lib');

2. rename the file to "Paypal_lib.php", load it as:
Code:
$this->load->library('paypal_lib');
#10

[eluser]divayank[/eluser]
I am using the same library and paste all the files as described.
In sandbox mode after making successful payment from paypal when I return back to my website
this function
Code:
paypal_success()
call but it return blank POST variable.

Code:
$this->paypal_lib->add_field('return', site_url('billinginfo/paypal_success'));
$this->paypal_lib->add_field('cancel_return', site_url( 'billinginfo/paypal_cancel') );
$this->paypal_lib->add_field('notify_url', site_url('billinginfo/ipn'));

ipn is also not working. When we press "pay now" button at paypal I should get an email but I didn't get any email.




Theme © iAndrew 2016 - Forum software by © MyBB