Posted: 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 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: Any suggestions of other things to check? Thank you ADDITION: I also have the blank template applied to the transaction page. |
|
Also, PayPal account is a business account and verified. |
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. |
|
|
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['id'])) { $attendee_id = $_REQUEST['id']; } return $attendee_id; } function espresso_process_paypal($payment_data) { do_action('action_hook_espresso_log', __FILE__, __FUNCTION__, ''); $payment_data['txn_type'] = 'PayPal'; $payment_data['txn_id'] = 0; $payment_data['payment_status'] = 'Incomplete'; $payment_data['txn_details'] = serialize($_REQUEST); include_once ('Paypal.php'); $myPaypal = new EE_Paypal(); echo '<!--Event Espresso PayPal Gateway Version ' . $myPaypal->gateway_version . '-->'; $myPaypal->ipnLog = TRUE; $paypal_settings = get_option('event_espresso_paypal_settings'); if ($paypal_settings['use_sandbox']) { $myPaypal->enableTestMode(); } <LINE 24> if ($myPaypal->validateIpn()) { $payment_data['txn_details'] = serialize($myPaypal->ipnData); $payment_data['txn_id'] = $myPaypal->ipnData['txn_id']; if ($myPaypal->ipnData['mc_gross'] >= $payment_data['total_cost'] && ($myPaypal->ipnData['payment_status'] == 'Completed' || $myPaypal->ipnData['payment_status'] == 'Pending')) { $payment_data['payment_status'] = 'Completed'; if ($paypal_settings['use_sandbox']) { // For this, we'll just email ourselves ALL the data as plain text output. $subject = 'Instant Payment Notification - Gateway Variable Dump'; $body = "An instant payment notification was successfully recieved\n"; $body .= "from " . $myPaypal->ipnData['payer_email'] . " on " . date('m/d/Y'); $body .= " at " . date('g:i A') . "\n\nDetails:\n"; foreach ($myPaypal->ipnData as $key => $value) { $body .= "\n$key: $value\n"; } wp_mail($payment_data['contact'], $subject, $body); } } elseif(in_array($myPaypal->ipnData['payment_status'],array( 'Refunded', 'Reversed','Canceled_Reversal')) ){ /*$subject = 'Payment Refund Notice from PayPal'; $body = "A payment has been refunded or reversed:\n"; $body .= "Payer's Email: " . $myPaypal->ipnData['payer_email'] . " on " . date('m/d/Y'); $body .= " at " . date('g:i A') . "\n\nDetails:\n"; foreach ($myPaypal->ipnData as $key => $value) { $body .= "\n$key: $value\n"; } $body .= "Event Espresso does not handle payment refunds automatically. You will want to verify that the registration for this user has been cancelled here ".site_url()."/wp-admin/"; wp_mail($payment_data['contact'], $subject, $body);*/ die; }else { $subject = 'Instant Payment Notification - Gateway Variable Dump'; $body = "An instant payment notification failed\n"; $body .= "from " . $myPaypal->ipnData['payer_email'] . " on " . date('m/d/Y'); $body .= " at " . date('g:i A') . "\n\nDetails:\n"; foreach ($myPaypal->ipnData as $key => $value) { $body .= "\n$key: $value\n"; } wp_mail($payment_data['contact'], $subject, $body); } } //add_action('action_hook_espresso_email_after_payment', 'espresso_email_after_payment'); return $payment_data; } </code> Github: <code>// replaces line 24 of gateways/paypal/paypal_ipn.php 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()) {</code> I understand that I just need to add an extra line on the init.php, so no questions there. |
|
I tried to put where line 24 was on my paypal_ipn.php <code> if ($myPaypal->validateIpn()) { </code> |
|
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? |
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. |
|
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. |
|
|
Ok, sorry about another question! Do I need to change the default setting in General Settings to Pending or just leave it as Incomplete. |
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. |
|
|
Thanks so much. |
|
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. |
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? |
|
|
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 |
|
I tried it again and it doesn’t update the Thank You page to the pending status. |
|
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”. |
|
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.