Support

Home Forums Event Espresso Premium Payment status: Incomplete

Payment status: Incomplete

Posted: December 5, 2013 at 2:58 pm


Tony

December 5, 2013 at 2:58 pm

I’ve looked through several forum entries about this and cannot find anything that directly relates to what I’m seeing.

Make a purchase
Get directed from PayPal with a successful transaction back to the website
The Thank You page gives me an Incomplete payment status but after a couple minutes, refresh and the payment status is “completed”.

All successful transactions show as complete in the back-end, it is just that initial redirect from the PayPal. The entries in the log seem to be updating without any errors.

How would I make this a little less confusing to the user? Could I make the default go to PENDING or does that need to stay at Incomplete? We don’t want to manually have to change anything.

Other info:
The IPN is enabled
The IPN URL has the http://www.ourwebsite.com/transactions/
log folder is changed to 777
no plugin or theme conflicts
cURL is enabled (fsockopen/cURL:Your server has fsockopen and cURL enabled.)
I cannot think of anything else that would be getting in the way.

Any suggestions of other things to check?

Thank you

ADDITION: I also have the blank template applied to the transaction page.
Gateway folder empty (uploads/espresso)

  • This topic was modified 10 years, 5 months ago by  Tony.
  • This topic was modified 10 years, 5 months ago by  Tony.


Tony

December 5, 2013 at 3:00 pm

Also, PayPal account is a business account and verified.


Josh

  • Support Staff

December 5, 2013 at 3:57 pm

I think you’re spot on. You could set the default payment status to Pending so it’s less confusing to customers. Unfortunately we are seeing that the PayPal IPN is getting slower and slower. If it’s eventually switching the status to complete then it is working, but the IPN can be slow due to network traffic, or PayPal’s IPN isn’t really that “instant” these days.

A few other options to consider:

1) You can add a message to the Thank You page that instructs to check their email for the payment confirmation if it’s still incomplete or pending.

2) This gist has some sample code that can be used to modify the Event Espresso PayPal gateway so it will automatically switch the Payment status to Pending when the return from PayPal:

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

When the IPN finally makes it, the payment status will automatically switch to Completed.

3) Consider using a more reliable payment gateway like Stripe.


Tony

December 5, 2013 at 4:11 pm

Great, thank you Josh!

So I copied over the paypal_ipn.php & init.php in the uploads/espresso/gateway/paypal directory. I’m unclear exactly what to replace since line 24 is just a bit of code compared to the longer version on github.

Here is my code:

<code>function espresso_transactions_paypal_get_attendee_id($attendee_id) {
	if (!empty($_REQUEST[&#039;id&#039;])) {
		$attendee_id = $_REQUEST[&#039;id&#039;];
	}
	return $attendee_id;
}

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();
	}
&lt;LINE 24&gt;	if ($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>

Github:

<code>// replaces line 24 of gateways/paypal/paypal_ipn.php
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()) {</code>

I understand that I just need to add an extra line on the init.php, so no questions there.


Tony

December 5, 2013 at 4:13 pm

I tried to put where line 24 was on my paypal_ipn.php
Here it is again, just that particular line:

<code>
if ($myPaypal-&gt;validateIpn()) {
</code>


Tony

December 5, 2013 at 4:20 pm

One other question, do I need that added code? Or, if I add a message stating that they will receive an email once the payment goes through will the status still be changed from PENDING to COMPLETED? Or, is the code needed change the PENDING to COMPLETED once the system hears from PayPal?


Josh

  • Support Staff

December 5, 2013 at 4:20 pm

You replace the one line with all of it, so you end up with more code there.

For clarity, you’ll replace this:

if ($myPaypal->validateIpn()) {

with this:

if (empty($_POST['ipn_track_id']) && ($_POST['payment_status'] == 'Completed' || $_POST['payment_status'] == 'Pending')) {
  $payment_data['txn_details'] = serialize($_POST);
  $payment_data['txn_id'] = $_POST['txn_id'];
  $payment_data['payment_status'] = 'Pending';
} elseif ($myPaypal->validateIpn()) {

Also, you’ll need to copy over the entire PayPal folder from event-espresso/gateways to /wp-content/uploads/espresso/gateways in order to make the customizations work.


Josh

  • Support Staff

December 5, 2013 at 4:24 pm

What the code addition does is set the payment status from incomplete to pending if the Thank You page has loaded up, but the payment status hasn’t already been switched to Pending or Complete yet. It’s up to you whether you implement this. The status will switch to Complete either way with or without it as long as they’ve paid and PayPal’s IPN reaches your server.


Tony

December 5, 2013 at 4:31 pm

Ok, sorry about another question! Do I need to change the default setting in General Settings to Pending or just leave it as Incomplete.


Josh

  • Support Staff

December 5, 2013 at 4:36 pm

If you set it to Pending in the General Settings, there is no need to add the code that automatically sets it to Pending after coming back from PayPal.

If you leave the default setting as Incomplete, then you might want to add the code from that Sidney posted in the gist. The extra code will only execute if the payment status is incomplete and there hasn’t been and IPN received yet.


Tony

December 5, 2013 at 4:37 pm

Thanks so much.


Tony

December 5, 2013 at 4:46 pm

Well I marked resolved but it didn’t seem to work using the code. I changed the default setting back to Incomplete and added the code to the files paypal.ipn.php and init.php. I moved the entire directory over to uploads/espresso/gateways/paypal but still got an Incomplete when redirected to the Thank You page.


Josh

  • Support Staff

December 6, 2013 at 8:47 am

Hi Tony,

Can you go into the Event Espresso>Payment Settings and check to see if the PayPal gateway is now listed first? If it’s listed as the first payment option, that means the files in /wp-content/uploads/espresso/gateways are being loaded up.

If that’s the case, can you post the entire contents of the paypal_ipn.php file that’s been modified in a gist or pastebin so we can doublecheck it?


Tony

December 6, 2013 at 9:32 am

It is now, it wasn’t yesterday when I tried it so let me try to go through the process again.

The code is here: http://pastebin.com/74uAmzYK


Tony

December 6, 2013 at 12:21 pm

I tried it again and it doesn’t update the Thank You page to the pending status.


Sidney Harrell

December 6, 2013 at 3:54 pm

One thing you might want to try, and is a general debugging strategy, is if you are working with a piece of code which should be running, but you are not sure if it is running, is to stick a debugging line in, to check if the code is being run. For example, in the modified copy that you think is running, put in a line like:

die("It's running");

Then try a test transaction. If the code runs, then the page should stop loading when it gets to that line and output “It’s running”.


Tony

December 9, 2013 at 12:29 pm

Thanks, I am throwing in the towel on this. I just switched the default to PENDING and put a note on the Thank You page explaining that they will receive a confirmation email once their payment has been processed and a confirmation sent from PayPal.

Thank you

The support post ‘Payment status: Incomplete’ 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