Paypal testing failed!! |
[eluser]T I[/eluser]
I am just testing the paypal lib of CI for my next app. but when i run it(http://localhost/mysite/paypal), it tells: Call to undefined method Paypal::view(){i colored the line in red, which it take as an error} here is the code, i did not even changed any thing, please help: [code]class Paypal extends Controller { function Paypal() { parent::Controller(); $this->load->helper('url'); $this->load->helper('form'); $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/success')); $this->paypal_lib->add_field('cancel_return', site_url('paypal/cancel')); $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', 'Paypal Test Transaction'); $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!'); $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('paypal/cancel')); $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', 'Paypal Test Transaction'); $this->paypal_lib->add_field('item_number', '6941'); $this->paypal_lib->add_field('amount', '197'); $this->paypal_lib->paypal_auto_form(); } function cancel() { $this->view('paypal/cancel'); } function success() { // 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('paypal/success', $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(); } } } ?>/code]
[eluser]Bart v B[/eluser]
it should be: Code: $this->load->view('paypal/form', $data); %-P Code: $this->load->view(‘paypal/success’, $data); And so on.. Code: function cancel()
[eluser]T I[/eluser]
Dear Bart v B Yes. Its solved. But why it is not corrected by the class author?. BTW, thank you.
[eluser]Bart v B[/eluser]
youre welcome don't know why it is not corrected by the author.. Maybe he did not noticed that. But when is saw the line of code i just missed the part 'load->' between.
[eluser]Bart v B[/eluser]
Sorry for the bump.. Forgot one.. mind the quotes that you use -> ' <- instead of -> ‘ <- it is also not correct. This is the correct way: Code: $this->load->view('paypal/form', $data); This is not ok: Code: $this->load->view(‘paypal/success’, $data); |
Welcome Guest, Not a member yet? Register Sign In |