Question

Two random question as I try to integerate Paypal IPN into my Codeigniter based web app.

1) Are these two lines the same?

$data['pp_info'] = $this->input->post();

$data['pp_info'] = $_POST;

2) A user agrees to pay a monthly recurring fee to use your service using paypal - first payment you are aware they have paid as you get data returned from paypal. But how do you keep track if users has paid for the following months? How do you know the user has not cancelled from their paypal account?

Thanks all for any help

Was it helpful?

Solution

1) Yes, but you should use the first one, incase CI makes changes to the method in the future (security filters, etc).

2) PayPal have a URL you need to call every few hours that says "this guys card has expired" and "this other guys recurring payment has been processed". The URL will be in your PayPal control panel thingy.

OTHER TIPS

1) Be careful - for security you want to use CodeIgniter's post() handler, but note that while CI standardises line-returns to \n, PayPal expects \r\n. So if you're not careful, PayPal will reject multi-line input as INVALID. To get around this in my PayPal IPN library I do this:

    foreach (array_keys($_POST) as $field)
    {
            $value = $this->input->post($field);
            $ipnData[$field] = str_replace("\n", "\r\n", $value);
    }

2) If you're using IPN for recurring payments, then PayPal will send notifications of updates to a user's subscription level to your IPN URL. You want to look at the txn_type variable - valid values include subscr_signup, subscr_failed and subscr_eot (end-of-term). You want to check for these values and handle them in your app.

1) Nope they are not the same.

You should normally use $this->input->post(); because it is a short hand that helps you check if that POST array index isset.

if nothing is post to your page and you call $_POST['mydata'] you will get an error because the that array index does not exist. to overcome this you would do a "if (isset($_POST['mydata']))" check but CI already does that for you.

and like what Coronatus said you get the additional CI goodies

2) don't called paypal every few hours, like what alex dean said. use IPN so paypal will do a "push" to your server whenever something happens.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top