tags:

views:

211

answers:

1

I'm using a Paypal Lib for CI--On success, it returns to the "success" page that says "thanks!", and it adds 1 credit for the user. The problem is, the page "success" is accessable at any time.

How can I make this page inaccessible, but still functional?

I'm a CI noob! Thanks for the help!

A: 

In the controller method that serves up the "success" view you could wrap the success actions (adding +1 credit, etc.) and the loading of the "success" view in a conditional to see that one of the variables set by the PayPal library, after a successful purchase, exists.

If it doesn't exist you can just call:

redirect('');

(be sure you're loading the URL Helper first)

Which will send the user to the site's base_url as-defined in your application/config/config.php file.

Here is an example (specific to your library, I believe):

function success()
{
     if(!$this->input->post('payer_id'))
     {
          redirect('');
     }

     $data['pp_info'] = $this->input->post();
     $this->view('paypal/success', $data);
}
Trae
This isn't working...I'm not sure that I have the lib working yet, though...
Kevin Brown
Now that I'm looking at this, shouldn't I tie the credit addition to the ipn function?
Kevin Brown
Yes, absolutely. Then the viewing of the success message doesn't need to be secured, and I believe the ipn method is already conditional on certain data being present, similar to my example above.
Trae