events['verified'] = 1; }else{ $this->events['invalid'] = 1; } }I think it would also work to put the processing code after the listener and use the "Show Stopper" action in both "On Error" and "On Invalid" but I didn't test that since all my processing was in the "On Verified" and I didn't want to mess with moving it😉Dave"> Suggestion for the PayPal IPN Listener - Forums

Forums

Suggestion for the PayPal IPN Listener

dyoungers 04 Feb, 2012
I was trying to figure out why I didn't see IPN call backs for pending payments so I did a little digging into paypal_listener.php and after seeing why, it might be good to post this. I'd looked at this code before but it didn't sink in at that time but the code around line 113 looks like this:


	function set_events($valid = false, $form){
		if($valid){
			if($form->data['payment_status'] == 'Completed'){
				$this->events['verified'] = 1;
			}
			//$this->events['invalid'] = 1;//delete
		}else{
			$this->events['invalid'] = 1;
		}
	}

That means that the only payment status getting processed is one that is "Completed". Since there are currently 11 statuses (Canceled_Reversal, Completed, Created, Denied, Expired, Failed, Pending, Refunded, Reversed, Processed, Voided) this may cause people a little confusion when the don't see their IPN calls getting processed in their "On Verified" code.

I don't know what other people are doing, but it would seem that it would make more sense to just let all the statuses come through under the "verified" action since the data has been verified. I changed the code on my system to look like this:


	function set_events($valid = false, $form){
		if($valid){
			$this->events['verified'] = 1;
		}else{
			$this->events['invalid'] = 1;
		}
	}

I think it would also work to put the processing code after the listener and use the "Show Stopper" action in both "On Error" and "On Invalid" but I didn't test that since all my processing was in the "On Verified" and I didn't want to mess with moving it😉

Dave
GreyHead 05 Feb, 2012
Hi Dave,

I agree with you that this action could be more sophisticated. I suspect that the train of thought that Max followed was that Completed was the only status that means that you've been paid and that you'd handle all of the other status responses through code in the Invalid event. Perhaps they would be better named something like 'Status: Complete' and 'Status: Other'.

Bob
dyoungers 06 Feb, 2012
Bob,

That makes sense as Completed is the most significant IPN status. As far as possible changes to the listener, renaming the events would help but it might make more sense to add a configuration option where one could enter a list of statuses expected and/or intended to be handled as valid? Seems that could be done without impacting current users, i.e. make Completed the default status to be handled so it works the same way as the current version.

Dave
This topic is locked and no more replies can be posted.