Post by Qphoria » Sat Nov 14, 2009 12:34 am

The "no order" problem was initially fixed by my additional conditional check.

However, as davgothic pointed out, this decreases security, as now the auto-verification response is moot.

So a much simpler solution is to simply add an "else" and have it default to "Pending" state when the order comes back unverified.
Orders that come back as verified will goto the final state (typically processing or complete).
Orders that come back unverified will goto the store default state (typically pending)

Solution for lost orders:

(v1.3.2)
1. EDIT: catalog/controller/payment/pp_standard.php

2. FIND (2 places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
3. REPLACE WITH (Both places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
	$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
	mail($this->config->get('config_email'), 'ATTN: Unverified Paypal Order', "Order ID: $order_id needs manual review");
}

(v1.3.4)
1. EDIT: catalog/controller/payment/pp_standard.php

2. FIND (2 places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed')) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
3. REPLACE WITH (Both places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
	$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
	mail($this->config->get('config_email'), 'ATTN: Unverified Paypal Order', "Order ID: $order_id needs manual review");
}
This fixes the lost order problem, while still keeping validation security active for orders that do get verified.
Now unverified orders will go into a pending state instead of being lost. You should also receive an ALERT email about the unverified order so that you can verify it manually by checking your paypal account for the actual transaction.

But I think the problem with the auto-verification still needs to be addressed. Perhaps there is some encoding/decoding used that isn't expected

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by kfchoy » Wed Dec 02, 2009 2:29 pm

Base on your suggestion, I have made the modification.
As a result, the order is still placed in "Missing Orders"

I am using v1.3.4
When I use PayPal sandbox to test my OpenCart (that is localhost), the payment is already settled successfully.
And I also saw the notification in PayPal sandbox account, that is completed.

I also check that the default order state is "Pending".

However, it still placed in "Missing Orders"

Would you give me some guides to solve this issue?

Thanks

Newbie

Posts

Joined
Wed Dec 02, 2009 11:18 am

Post by mab » Wed Dec 02, 2009 8:36 pm

Just to be crystal clear.

1) I think this refers only to the version of pp_standard.php that is in catalog/controller/payment. Please correct me if I have misunderstood.

2) The from code has changed between versions 1.32 and 1.34. The equivalent code in 1.34 appears to be:

Code: Select all

if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') 
{
 $this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}


Is the fix still valid for this version? As the orginal code has been modified does the replacement code have to be?

Regards
MAB

mab
New member

Posts

Joined
Sun Oct 18, 2009 7:22 am

Post by fernando » Thu Dec 03, 2009 4:38 pm

I would like to know as well,i have 1.3.4 new install have done orders in test mode and full payment through paypal from a verified account and the orders do not show in admin.

Newbie

Posts

Joined
Thu Dec 03, 2009 4:32 pm

Post by Qphoria » Sat Dec 05, 2009 12:57 am

mab wrote:Just to be crystal clear.

1) I think this refers only to the version of pp_standard.php that is in catalog/controller/payment. Please correct me if I have misunderstood.
Correct.
2) The from code has changed between versions 1.32 and 1.34. The equivalent code in 1.34 appears to be:
I've updated the first post to be clearer

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by Qphoria » Sat Dec 05, 2009 1:05 am

kfchoy wrote:(that is localhost),
IPN cannot work with localhost. It obviously cannot find your site called "localhost" since that is a relative name. You need to do it on a live server that can be reached from the outside

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by mab » Sat Dec 05, 2009 8:31 am

Thanks Q
Regards
MAB

mab
New member

Posts

Joined
Sun Oct 18, 2009 7:22 am

Post by herbalgrinders » Sat Dec 12, 2009 2:28 am

Hey,
I just updated the pp_standard.php file.
I was direct to the sandbox and then once the payment was complete i was directed back to the checkout success page. When i then checked the orders, nothing was created.
How could i find out what the cause of this is?
Regards,
Phil


Posts

Joined
Sun Nov 29, 2009 8:53 am

Post by Qphoria » Sat Dec 12, 2009 3:02 am

There is only ONE reason that this and any other solutions won't work.
1. Because paypal cannot reach your site from the internet.


There are multiple reasons that paypal may not be able to reach your site:
1. You are using a localhost address. IPN won't work with localhost for obvious reasons. localhost is not a resolvable web address. It is a relative link to your own local network.. with the ip of 127.0.0.1
2. You're site isn't reachable due to ip blocking or the dns hasn't been propagated throughout the entire internet (usually only a problem for the first 48 hours after creating a new web address)
3. You're webhost blocks inbound POST data from paypal or all sites.

A good host with a good webaddress should have no problems with this.

The fix I have offered above is simply adding an "else" condition for when the IPN verification fails. If IPN is NEVER getting to you, then you have much bigger network connection problems. If paypal can't find your site, then it is likely others cannot either.

The best way to check to see if the IPN is even reaching your site is to add this line at the top of the callback() function in the catalog/controller/payment/pp_standard.php file:

Code: Select all

mail($this->config->get('config_email'), "IPN REACHED", "IPN REACHED");
That will send an email to the store email account as soon as IPN returns to your store. Regardless of the order itself, this will fire immediately before any logic takes place. If you are not getting this email, then you have other connection issues that need to be fixed before worrying about this. If paypal can't find you, then it is likely that all other payment modules may also not find you.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by herbalgrinders » Sat Dec 12, 2009 3:18 am

Small update. I had a look in the database and the orders are recorded but don't show in the order history of the admin or customer.


Posts

Joined
Sun Nov 29, 2009 8:53 am

Post by Qphoria » Sat Dec 12, 2009 3:21 am

They they are still in No Order state and that means IPN is not reaching you.
You can see these "lost" orders in the admin order view and filter on "No Status"

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by chapstick » Sun Jan 03, 2010 3:46 am

Qphoria wrote:
Solution for lost orders:

(v1.3.2)
1. EDIT: catalog/controller/payment/pp_standard.php

2. FIND (2 places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
3. REPLACE WITH (Both places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
	$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
	mail($this->config->get('config_email'), 'ATTN: Unverified Paypal Order', "Order ID: $order_id needs manual review");
}

(v1.3.4)
1. EDIT: catalog/controller/payment/pp_standard.php

2. FIND (2 places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed')) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
3. REPLACE WITH (Both places):

Code: Select all

if (strcmp($response, 'VERIFIED') == 0) {
	$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
	$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
	mail($this->config->get('config_email'), 'ATTN: Unverified Paypal Order', "Order ID: $order_id needs manual review");
}

I uploaded the PaypalItemizedPatch_OCv134.1 and it looks like my v134 pp_standard.php file now looks like v132.

Here is what is the standard install for this file for v134 (as referenced above in Qphoria's code snippet):
if ($fp) {
fputs($fp, $header . $request);

while (!feof($fp)) {
$response = fgets($fp, 1024);

if (strcmp($response, 'VERIFIED') == 0 || $this->request->post['payment_status'] == 'Completed') {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
}
}

fclose($fp);
}


This is the same code after installing the PaypalItemizedPatch_OCv134.1:
if ($fp) {
fputs($fp, $header . $request);

while (!feof($fp)) {
$response = fgets($fp, 1024);

if (strcmp($response, 'VERIFIED') == 0) {
$this->model_checkout_order->confirm($order_id, $this->config->get('pp_standard_order_status_id'));
} else {
$this->model_checkout_order->confirm($order_id, $this->config->get('config_order_status_id'));
mail($this->config->get('config_email'), 'ATTN: Unverified Paypal Order', "Order ID: $order_id needs manual review");
}
}

fclose($fp);
}

This looks like v132 even though the PaypalItemizedPatch_OCv134.1 says its for v134.

My PayPal sandbox used to work fine, and after installing the PaypalItemizedPatch_OCv134.1, I can no longer get it to work.

Can someone please clarify whether it's possible to use PaypalItemizedPatch_OCv134.1 AND this mod for lost orders or do you have to pick only one?

Thanks.

Newbie

Posts

Joined
Wed Oct 28, 2009 10:26 pm

Post by Qphoria » Sun Jan 03, 2010 4:23 am

The code is correct. The code should look like the 1.3.2 code because the 1.3.4 patch is a security risk based on an earlier (solution 1) fix that I made. The itemized patch and the fix from the first post here removes that security risk and replaces it with a proper conditional.

That particular code has nothing to do with sandbox. Somewhere in the itemized code when sending would be the root of that problem. But I'm not quite sure which field causes the error. The fields are straight from paypals documentation, but for those familiar with it, it is quite bug ridden and contradictory. It works in live mode just find. So I will have to test more. Unfortunately the errors returned from paypal are quite useless.

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by chapstick » Sun Jan 03, 2010 5:48 am

@Qphoria - thanks.

So, to be clear, I need to upload the Itemized patch for v134 then follow the v132 instructions for this mod?

Thanks

Newbie

Posts

Joined
Wed Oct 28, 2009 10:26 pm

Post by Qphoria » Sun Jan 03, 2010 6:03 am

no. Upload the v1.3.4 itemized patch and you are done. It already has this fix

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by halena » Mon Jan 04, 2010 2:45 am

Hi..

Need your kind help. My version is (v1.3.4) I have made the changes as indicated but still have the lost order problem, also admin did not receive an ALERT email about the unverified order.

For processing and payment orders all in great working conditions (with order no. and notification email).

Your kind reply is much appreciated.

Thanks!

Newbie

Posts

Joined
Mon Jan 04, 2010 2:37 am

Post by Qphoria » Mon Jan 04, 2010 5:01 am


Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by christopherdarling » Mon Jan 04, 2010 9:55 pm

Just a quick note, as I implemented this patch but it didn't work for me. I realised the problem was that I had password protected the directory. This stops PayPal IPN Reaching your site.

Make sure you remove any directory password protection (htaccess/htpasswd) or PayPal will NOT work.

Christopher Darling - Web Design Bristol


New member

Posts

Joined
Sat Jan 02, 2010 12:26 am

Post by Qphoria » Fri Jan 08, 2010 11:10 pm

Here is a page I found on the paypal forums that may help:
http://www.pdncommunity.com/pdn/board/m ... ad.id=7479

After working with another forum member to get his site working. The problem looks to be that Paypal is not getting a response handshake from the server when performing an IPN callback step. This is needed obviously for the callback to even be reached.

There are 2 ways to test if your site is also unreachable by paypal:
1. Create a paypal sandbox account and use the IPN simulator
* Enter your callback address:

Code: Select all

http://www.yoursite.com/shop/index.php?route=payment/pp_standard.php
* Submit. If you get an error like:
IPN delivery failed. Unable to connect to the specified URL. Please verify the URL and try again.
Then paypal is unable to connect to your site.

OR

2. Goto your paypal account and on the front page, goto the "History->IPN History" menu
* If you see a list with the status of "Retrying" instead of "Sent" then you likely have this problem.
* Click the message id of one of the retrying items. If you see no value for the HTTP response code then paypal is unable to reach your site.

HOW TO FIX?
Not sure. If paypal can't reach your site with a simple HTTP POST command, then there must be some blocking or error at the apache level. This is where the message first hits the network and gets routed to your site.
- Check your cpanel access logs for errors
- Check with your host to see if they can see paypal messages attempting to reach your site but not making it.

I've tested this with a simple standalone script OUTSIDE of opencart and got the same result so it doesn't appear to be cart related. On my site and most others it works fine.

As a last resort, move to a higher rated host like HostGator or any number of good ones featured on sites like http://www.webhostingtalk.com

Image


User avatar
Administrator

Posts

Joined
Tue Jul 22, 2008 3:02 am

Post by ramblin54321 » Tue Jan 12, 2010 8:00 pm

Hi,
unfortunately I'm having the same problem. The IPN test in sandbox gives this error message:
IPN delivery failed. HTTP error code 403: Forbidden

Please tell me what I need to do. Change a file permission or something?

Newbie

Posts

Joined
Tue Jan 12, 2010 7:47 pm
Who is online

Users browsing this forum: Amazon [Bot] and 73 guests