Support

Home Forums Event Espresso Premium Paypal – Paid but Incomplete Transaction

Paypal – Paid but Incomplete Transaction

Posted: October 31, 2013 at 9:43 am


IPES

October 31, 2013 at 9:43 am

I’ve been reading up on this common problem but I’m still getting this problem despite trying the fixes you’ve listed.

I’ve reset the permissions on the log file, I’m getting transactions and logs no problem. The site seems to work generally well and Paypal works fine. payments can be made in Sandbox mode and Live mode fine.

However, on the transaction page in Live mode the Payments are still being marked as Incomplete. If I leave that page for a minute then hit the refresh button – the status changes to Complete and the registration is confirmed.

Sandbox mode works straight away.

So is something being slow ? How can I fix this!?

Thanks,


Josh

  • Support Staff

October 31, 2013 at 10:50 am

Hi Nick,

It’s becoming more of a problem recently because it appears that the Instant Payment Response times from PayPal are varying much more than they used to. What happens is the payer returns from PayPal to your site *before* the IPN gets sent from PayPal. At this point we are not sure what is causing the delay.

In the past the delay was happening on the transactions shortcode page (the receiving end), and installing the simplified page template worked quite well to speed up the Instant Payment Notification on the receiving end.

However it appears now that the Instant Payment Notification isn’t getting sent from PayPal right away. In our testing we’ve seen the IPN get received up to a minute *after* the Thank You page loads up. The idea that we’re testing now that seems to work well is add a check to see if the IPN has been received yet. If it hasn’t been received yet once the Thank You page is loaded up it will set the Payment status as Pending. Here’s a link to the code that adds this check:

https://gist.github.com/sidharrell/7087307


IPES

October 31, 2013 at 10:53 am

As always thanks Josh but the problem is now. When eventually the IPN has completed/received. My registrant won’t receive the emails, become confirmed, etc ? or is this something done behind the scenes ?


IPES

October 31, 2013 at 11:18 am

oh and that code does not seem to have worked – I’ve replaced line 24 but the page still returns as Incomplete.


IPES

October 31, 2013 at 11:28 am

in fact it appears to be ignoring my entire /uploads/espresso/gateways/paypal template!


IPES

October 31, 2013 at 11:35 am

Yep – paypal_ipn.php is being completly ignored in the uploads/ path. Any help ?


IPES

October 31, 2013 at 11:39 am

I’m just confused, I put the code from GitHub but it just doesn’t work. I thought about even adding a sleep(6); but that doesn’t have any effect. Need some help asap!

<code>function espresso_process_paypal($payment_data) {
	
	do_action(&#039;action_hook_espresso_log&#039;, __FILE__, __FUNCTION__, &#039;&#039;);
	$payment_data[&#039;txn_type&#039;] = &#039;PayPal&#039;;
	$payment_data[&#039;txn_id&#039;] = 0;
	$payment_data[&#039;payment_status&#039;] = &#039;Incomplete&#039;;
	$payment_data[&#039;txn_details&#039;] = serialize($_REQUEST);
	include_once (&#039;Paypal.php&#039;);
	$myPaypal = new EE_Paypal();
	echo &#039;&lt;!--Event Espresso PayPal Gateway Version &#039; . $myPaypal-&gt;gateway_version . &#039;--&gt;&#039;;
	$myPaypal-&gt;ipnLog = TRUE;
	$paypal_settings = get_option(&#039;event_espresso_paypal_settings&#039;);
	if ($paypal_settings[&#039;use_sandbox&#039;]) {
		$myPaypal-&gt;enableTestMode();
	}
	if (empty($_POST[&#039;ipn_track_id&#039;]) &amp;&amp; ($_POST[&#039;payment_status&#039;] == &#039;Completed&#039; || $_POST[&#039;payment_status&#039;] == &#039;Pending&#039;)) {
	$payment_data[&#039;txn_details&#039;] = serialize($_POST);
	$payment_data[&#039;txn_id&#039;] = $_POST[&#039;txn_id&#039;];
	$payment_data[&#039;payment_status&#039;] = &#039;Pending&#039;;
	} elseif ($myPaypal-&gt;validateIpn()) {
		$payment_data[&#039;txn_details&#039;] = serialize($myPaypal-&gt;ipnData);
		$payment_data[&#039;txn_id&#039;] = $myPaypal-&gt;ipnData[&#039;txn_id&#039;];
		if ($myPaypal-&gt;ipnData[&#039;mc_gross&#039;] &gt;= $payment_data[&#039;total_cost&#039;] &amp;&amp; ($myPaypal-&gt;ipnData[&#039;payment_status&#039;] == &#039;Completed&#039; || $myPaypal-&gt;ipnData[&#039;payment_status&#039;] == &#039;Pending&#039;)) {
			$payment_data[&#039;payment_status&#039;] = &#039;Completed&#039;;
			if ($paypal_settings[&#039;use_sandbox&#039;]) {
				// For this, we&#039;ll just email ourselves ALL the data as plain text output.
				$subject = &#039;Instant Payment Notification - Gateway Variable Dump&#039;;
				$body = &quot;An instant payment notification was successfully recieved\n&quot;;
				$body .= &quot;from &quot; . $myPaypal-&gt;ipnData[&#039;payer_email&#039;] . &quot; on &quot; . date(&#039;m/d/Y&#039;);
				$body .= &quot; at &quot; . date(&#039;g:i A&#039;) . &quot;\n\nDetails:\n&quot;;
				foreach ($myPaypal-&gt;ipnData as $key =&gt; $value) {
					$body .= &quot;\n$key: $value\n&quot;;
				}
				wp_mail($payment_data[&#039;contact&#039;], $subject, $body);
			}
		} elseif(in_array($myPaypal-&gt;ipnData[&#039;payment_status&#039;],array( &#039;Refunded&#039;, &#039;Reversed&#039;,&#039;Canceled_Reversal&#039;)) ){
			/*$subject = &#039;Payment Refund Notice from PayPal&#039;;
			$body = &quot;A payment has been refunded or reversed:\n&quot;;
			$body .= &quot;Payer&#039;s Email: &quot; . $myPaypal-&gt;ipnData[&#039;payer_email&#039;] . &quot; on &quot; . date(&#039;m/d/Y&#039;);
			$body .= &quot; at &quot; . date(&#039;g:i A&#039;) . &quot;\n\nDetails:\n&quot;;
			foreach ($myPaypal-&gt;ipnData as $key =&gt; $value) {
				$body .= &quot;\n$key: $value\n&quot;;
			}
			$body .= &quot;Event Espresso does not handle payment refunds automatically. You will want to verify that the registration for this
				user has been cancelled here &quot;.site_url().&quot;/wp-admin/&quot;;
			wp_mail($payment_data[&#039;contact&#039;], $subject, $body);*/
			die;
		}else {
			
			$subject = &#039;Instant Payment Notification - Gateway Variable Dump&#039;;
			$body = &quot;An instant payment notification failed\n&quot;;
			$body .= &quot;from &quot; . $myPaypal-&gt;ipnData[&#039;payer_email&#039;] . &quot; on &quot; . date(&#039;m/d/Y&#039;);
			$body .= &quot; at &quot; . date(&#039;g:i A&#039;) . &quot;\n\nDetails:\n&quot;;
			foreach ($myPaypal-&gt;ipnData as $key =&gt; $value) {
				$body .= &quot;\n$key: $value\n&quot;;
			}
			wp_mail($payment_data[&#039;contact&#039;], $subject, $body);
		}
	}
	//add_action(&#039;action_hook_espresso_email_after_payment&#039;, &#039;espresso_email_after_payment&#039;);
	return $payment_data;
}
</code>


Josh

  • Support Staff

October 31, 2013 at 12:48 pm

Hi Nick,

What you do is make the change in wp-content/plugins/event-espresso/gateways/paypal/paypal_ipn.php. Then copy over the entire /paypal/folder to /wp-content/uploads/espresso/gateways to prevent your changes from being overridden on an update.

With the emails not firing: If it’s set to send emails after payment I don’t think the PayPal IPN can be relied on. I’ve read in PayPal’s docs that they more or less say the IPN can’t be relied on for being an instant notification. So if you’re using the PayPal IPN and you need the confirmation email to go out then at this time I can advise setting the email settings to go out before payment.

A good alternative to PayPal that’s worth looking into is Stripe. There is no delay with Stripe’s API.

The support post ‘Paypal – Paid but Incomplete Transaction’ is closed to new replies.

Have a question about this support post? Create a new support post in our support forums and include a link to this existing support post so we can help you.

Event Espresso