We have had this happen a few times where commerce does not move the order from the checkout. I am assuming this is because a user has made a payment on paypal and not returned to the website.

I can see the IPN information reaching me in the log. This is a little worrying as we might be overlooking orders. I assume there is some processing that is happening once the IPN is received and it is then tied back to and order that is supposed to move it out of that state...

Once I have manually found that 'stuck' order I move it out of check out to pending and the information is assigned to the order when I look at the payment under the order.

Not sure if this is a rules thing or if there is a hook forfilling this.

CommentFileSizeAuthor
#9 not_moving_order-1130166-9.patch1.54 KBguillaumev

Comments

roam2345’s picture

Also any rules that would be associated with the 'action' that would have taken place with it are not applied. (rightly so but can be an adminstraion pain if you are doing a few tasks)

roam2345’s picture

On review of our 404 errors we spotted that we are seeing checkout/[order-id]/payment littering the log where orders failed.

roam2345’s picture

Status: Active » Closed (fixed)

This patch seems to have fixed this for me http://drupal.org/node/1129188

gagoo’s picture

Status: Closed (fixed) » Active

Hello,

Sorry to re-activate this issue, I have the same one :

"We have had this happen a few times where commerce does not move the order from the checkout. I am assuming this is because a user has made a payment on paypal and not returned to the website.

I can see the IPN information reaching me in the log. This is a little worrying as we might be overlooking orders. I assume there is some processing that is happening once the IPN is received and it is then tied back to and order that is supposed to move it out of that state..."

Could you explain to me how did you resolve it please ?
Now, are your orders status automatically updated without the customer returning from Paypal to your website ?

Thanks

roam2345’s picture

If you have updated commerce you must reset any rules... this is an undocumented and hardly spoken about issue that lurks... I have opened an issue for this. Be sure to check that when looking at the linked issue above.

With regards to having people not returning from paypal we have custom code processing orders when paypal sends us the IPN back.. you can see some of that here if you are interested.... but there are issues there as well http://drupal.org/node/1207878 am hoping for some feed back there from the commerce guys to wrap that up. If you are interested in that out side of product keys I can move that code to a separate add on module to paypal, or push for a feature patch once I have something generic working there.

Bcwald’s picture

Hi Jucallme, how do you reset all the rules? what is the best way to handle that?

dbkern’s picture

Jucallme,

I would love to see that code without product keys. I looked at your code and am not advanced enough at programming to make it work. Having it would solve a big headache for me right now.

Thanks!

guillaumev’s picture

Hi,

I'm having the same problem. When a customer returns from Paypal to the store, everything works fine, all rules are triggered, such as for example sending an email to the customer, sending a notification email to myself and decrementing the stock...

However, when a customer does not return from Paypal, yes the payment transaction is processed and marked as completed, but the order is not marked as completed and all those rules are not triggered...

guillaumev’s picture

Status: Active » Needs review
StatusFileSize
new1.54 KB

Hi,

Attached is a proposed patch which sets the order to complete directly after the IPN has been validated. It also changes the return URL to checkout/order_id/complete, in case the customer clicks on the "Return to store" button...

dbkern’s picture

Tried patch in #9 and the order is still not processed--it retains the order status of Checkout:Payment rather than Pending. It is not visible in the orders view--only in my custom view that tracks orders that are not completed correctly.

dbkern’s picture

I attempted again this morning--thinking I may have forgotten to clear my cache--but still not working. In fact, if I do return to the website after the PayPal payment is processed, the order status doesn't even get marked Pending--it remains Checkout: Payment and doesn't get moved into my processed orders list. So, this patch does not appear to help the situation for me.

The redirect url is fine--but it doesn't seem to trigger the checkout rules.

guillaumev’s picture

dbkern > Do you see the message "IPN processed for Order xxx" in the log messages ? Is the payment transaction status set as completed ?

dbkern’s picture

When I look in the log, the only thing I find is this notice: IPN rejected: invalid receiver e-mail specified. It does not appear occur when I am not using your patch--I looked back through the log and couldn't find it at the same time as successful transactions.

I guess there's always a chance I applied the patch incorrectly but it's a simple patch..

I do have a question about why line 110 is commented out in the patch rather than just removed/replaced--or is it a typo or am I reading it incorrectly?

guillaumev’s picture

If the IPN is rejected yes, the code in my patch does not trigger anything, as it considers that the transaction failed. Unless I missed something, the fact that the IPN is rejected does not come from my patch, since all the processing I'm doing in my patch comes AFTER validating the IPN. How are you testing it ? With Paypal's sandbox or with live transactions ? Make sure that the receiver email's address in your configuration on your Drupal site is valid...

Concerning the line commented out, yes it's a mistake on my side. I had commented it out for testing and forgot to completely remove it in the patch. It shouldn't impact anything, however...

dbkern’s picture

I'm testing it live. We have had numerous transactions without any IPNs being rejected. Only the two test transactions I made while using the patch were rejected. I will give it another try tonight when activity is slower.

I didn't think the commented out line 110 would be an issue but I just wanted to make sure that it was supposed to be commented out.

Thanks. I'll report back with the results of my tests.

Discussions about resolving this issue appear to be taking place here as well: http://drupal.org/node/1216386

roam2345’s picture

This issue is fundamentally the same thing I have been trying to overcome with commerce product key... http://drupal.org/node/1207878

What I have been trying todo is find away for the IPN to trigger the payment successful event and trigger the rules. That is rather trivial via adding the call to

commerce_checkout_complete($order);

When we receive a successful and fully paid IPN that will trigger the event and fire all the rules... the gotcha then arrises down the road when a user then returns to the site.

But that page is now not accessible to them as it fails the permissions check...

Im also looking for a clean way to do this.

@dbkern in your patch you assume at least one flaw, know from what Ryan has said not everyone assumes a order is complete upon payment, however the payment is complete. Further more that the payment was of the full value of the product. We need to have that check and the optional administration option in the payment rule settings page to move a order to complete or just the payment.

dbkern’s picture

Jucallme,

Thanks for your input. I have been following your struggles as well in other issue threads.

You bring up to good points. 1) that the payment that is made without the user returning to the site should be handled as "pending" (with validation of payment amount and triggering of events) and not "completed." I agree with that as it'd be consistent with what happens when a user does return to the site. 2) the lack of ability for said user to return to the resulting order page.

I, for one, would be happy to at least get issue #1 handled--it would make things easier on the administrative end. Currently, we have a non-pending/complete view set up to capture these and we deal with them manually (something learned from one of your comments elsewhere). I completely understand issue #2 and it being necessary for customer satisfaction and hadn't gotten far enough in testing to notice that was going to be a problem.

Unfortunately, I am not the author of the patch and have lesser programming skills than guillaumev so I am able to offer little more than user feedback and testing.

Thanks!

Jason Dean’s picture

+ subscribe

MZiray’s picture

We changed the patch slightly to accommodate an order that goes to Pending, not completed:

if ($ipn['payment_status'] == 'Completed' || $ipn['payment_status'] == 'Pending') {
    $order = commerce_order_status_update($order, 'checkout_complete');
    commerce_checkout_complete($order);
    watchdog('commerce_paypal_wps', 'Checkout set to success', array(), WATCHDOG_INFO);
  }

Instead of
if ($ipn['payment_status'] == 'Completed'){
We added the case for an order to go to Pending. We found that this if statement wasn't being called for us because the orders we being set to Pending, not Completed per the commerce rule that is set up. This may be why some people experienced the patch not working and just wanted to share our changes in case someone didn't want to spend the time figuring out why it's not being called.

Also, we added a watchdog call to ensure the if statement was being called, so remove that line if you don't want to have it appear in the site logs.

- Mike

jakonore’s picture

subscribe

fonant’s picture

Glad others have found the same problem!

The payment completion needs to be set by the successful IPN, and not by the visitor returning to the checkout/%order/payment/return/%key page, which they quite often don't bother to do.

fonant’s picture

Another slight problem in my case, where only admin (and Commerce) can create new users.

The return page checkout/%order/complete gives "Page not found", when the user clicks on the button to return from PayPal, because the user isn't logged in.

carn1x’s picture

subscribe

UserFriendly’s picture

I've tried the patch in #9 and unfortunately it didn't work for me. Orders stayed at Checkout: Payment and if I used the Return to Store link after making payment I was taken back to the Payment redirect page. This was using the PayPal Sandbox.

carn1x’s picture

Priority: Major » Critical
Status: Needs review » Needs work

Commerce Stock rules do not trigger until Order moves to Status: Pending, which means that payment for out of stock items can be taken.

While this issue technically still exists if the Paypal module is setting Status: Pending on Payment instead of Return to Store, the window of opportunity currently is much greater and the likelihood of payment of out of stock items is much higher.

carn1x’s picture

Applied patch in #9, Orders now move to Checkout: Complete without the User needing to return to the site.

Strangely however the default rule "Update the order status on checkout completion" which should move Order to Pending is not firing.

I created another rule that checks Updated Orders for status: Checkout:Complete and pushes them to Pending, and this appears to fire where the default rule does not.

carn1x’s picture

Ok strangely the following custom rule to move Orders from Checkout: Complete to Pending is also not firing:

{ "rules_update_the_order_status_when_checkout_complete" : {
    "LABEL" : "Update the order status when Checkout:Complete",
    "PLUGIN" : "reaction rule",
    "REQUIRES" : [ "rules", "commerce_order", "entity" ],
    "ON" : [ "commerce_order_update" ],
    "IF" : [
      { "data_is" : { "data" : [ "commerce-order:status" ], "value" : "checkout_complete" } },
      { "NOT data_is" : {
          "data" : [ "commerce-order-unchanged:status" ],
          "value" : "checkout_complete"
        }
      }
    ],
    "DO" : [
      { "commerce_order_update_state" : { "commerce_order" : [ "commerce-order" ], "order_state" : "pending" } }
    ]
  }
}
pumpkinkid’s picture

I am also seeing this issue... This needs to be resolved as I have a few sites online using this module.

For now I have altered the view to show all orders, but it is confusing to the people in charge of processing the orders.

pumpkinkid’s picture

So what is the latest on this? is there a patch?

carn1x’s picture

@pumpkinkid the patch in #9 is working "good enough" for the mean time as it pushes orders to Checkout:Complete which as far as I can tell is not ambiguous unlike Checkout:Payment.

pumpkinkid’s picture

I see, so are we looking at anything else that needs to be done? Just wondering why it hasn't been rolled out yet.

If there is anything else that needs to be done I'd like to see if I can help. In the meantime I'll just test the patch on #9

courtney.mob’s picture

subscribe

carn1x’s picture

The only issue with Patch #9 as far as I can tell is that it only pushes the order to Checkout:Complete instead of Pending, despite the default rule for Commerce which should automatically push Orders from Checkout:Complete to Pending, so that may be an unrelated issue. As far as I can tell however this rule will fire successfully if the user already has an account (is logged in, or uses an email address that is tied to an existing user).

I'm not sure if this problem should be corrected here or if it's a separate issue?

carn1x’s picture

[deleted]

witchcraft’s picture

is there any alternate answer beside patch #9 ?
if this is the final answer we need more testers to roll it out .

guillaumev’s picture

@carn1x Are you sure that the fact the rule which is supposed to set the order to Pending on checkout complete is not firing is not caused by something else ? Because on my site I have absolutely no problem with this patch: after payment has completed, the order is set to pending, stocks are updated, emails are sent out etc... If you try out another payment system (such as for example the example payment module), do you have the same issue ?

carn1x’s picture

@guillaumev: Hmmm I'll test this some more and see whether the rule is firing for anything.

One certainty is that using the Example Payment module payment method pushes orders to Pending state. I'm also certain that before applying the patch in #9, all Paypal orders were pushing to Pending if the user returned to the site. I'm just not sure if any of this was caused by the rule or some other voodoo.

carn1x’s picture

Ok just to update, done further testing today and I've tried all 3 possibilities I can think of:

* Anonymous user with email address not associated to an existing user
* Anonymous user with email address associated to an existing user
* Logged in user

And all 3 now push the cart to Pending, can't get it to go to Checkout:Complete at all. Bearing in mind I am running 2 rules for pushing to Pending:

* On Checkout Complete, change status to Pending (default with Commerce module)
* On Existing Order Save, if status is Checkout:Complete and changed, change status to Pending (Custom)

The only remaining issue I can see with patch in #9 is that the url the user is returned to: [site:url]checkout/[order:order-id]/complete is now Page Not Found.

girimcarlos’s picture

I also was having problems with a client about this. Specially the orders if the buyer was not coming back.
Fixes that worked:

1) changing the "order views" sort to see all the orders
2) deleting the rules for the "update order status" and creating a new one to set checkout:payment when the checkout process was finished.

note: using lastest paypal (dev), commerce modules (1.0), rules (2.0)

;)

mowen3’s picture

subscribe

ryan.ryan’s picture

subscribe

just checking, should I be applying patch #9 to the module?

Joram’s picture

subscribe

superstar’s picture

Status: Needs work » Needs review

A recent commit to the most recent dev version should haved fixed this. Can someone please test.

UserFriendly’s picture

I've just updated to the most recent dev version and the issue is not fixed for me. I still have to return to the store after making payment for the order to be moved to pending and the notification email to be sent.

Looking at my Unfiltered Orders view, if I don't return to the store after making payment, the order is now left as Checkout: Review, whereas before it was ending up at Checkout: Payment - so we seem to have gone back a step.

I've also noticed that, for some orders with the Checkout: Payment status, clicking on the Payment tab shows the message "No payment methods available to add payments." while others show "The payment has completed." along with details of the transaction. However this has occured on orders placed before updating to the latest dev version.

EDIT: I should probably mention that I've only tested this with the PayPal Sandbox.

UserFriendly’s picture

Okay, just tested this with a couple of purchases using live PayPal accounts rather than using their Sandbox and it seems to have worked!

The Order was moved to Pending as soon as payment was made and the appropriate emails were sent. Clicking the return to store link took me to the Checkout complete page. All good.

Thanks :)

rszrama’s picture

Status: Needs review » Fixed

Ahh, sorry, I forgot there was an open issue for this. Yes, it is fixed, but you must be using Commerce 1.x-dev for it to work. Be sure to run update.php when you update or wait a day or two for the 1.1 release. : )

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

fahadurrehman’s picture

Status: Closed (fixed) » Active

I have applied the patch but its not working.

rszrama’s picture

Status: Active » Closed (fixed)

I'm not sure what patch you're talking about, but why not open a new issue instead of resurrecting this one? At least as of Drupal Commerce 1.1, this has been fixed with the latest dev version of PayPal - no patch required.

starsinmypockets’s picture

Sorry to keep hammering on this thread, but I'm experiencing the same issue. I'm using commerce_paypal 7.x-1.x-dev version with Commerce 1.1. After succesful redirect, acknowledgment of payment, and receipt of email, the order status remains 'Pending'.

superstar’s picture

Create a new issue.

rszrama’s picture

Pending is the status it's supposed to end in. : )

(This issue was about orders not moving to Pending. If you want it to go somewhere else, just change the default checkout completion rule or add another one that changes the status on the "When an order is first paid in full" event.)

starsinmypockets’s picture

My bad!

Amarjit’s picture

Came across this thread many times, as my 'Completed the checkout process' rules were not triggering.
Intermittently my Paypal checkouts were not creating users and sending e-mails out. Thus, I sussed that the rule was not triggering.

This may help some users: http://www.drupalcommerce.org/node/1150

Hope this helps someone before they spend many hours as I did!

Cheers,
Amarjit

vladimiraus’s picture

Might help some people.
I tried to recreate "Completing the checkout process" rule from scratch to add extra functionality and it didn't work.
When I cloned the original rule "Send an order notification e-mail" and modified it, it worked no problems.

mrfelton’s picture

Cross posting #1418030: Better support business e-mail address comparison / acceptance as the problem described in that issue can also lead to this situation, and the patch in that issue resolves under certain circumstances.

drugan’s picture

Hope it will be useful for you to review this post:
Add "Checkout complete page is viewed" event

phponwebsites’s picture

Issue summary: View changes

When the rule "Update the order status as completed on checkout completion if order paid in full" is running, event "commerce_order_update_state" is called. The callback of this event is followed:

function commerce_order_rules_update_state($order, $name) {
  $order_state = commerce_order_state_load($name);
  commerce_order_status_update($order, $order_state['default_status'], FALSE, NULL, t('Order state updated via Rules.'));
}

After the order status has been changed, when we view the transaction revisions the log message kept "Order state updated via Rules." .

I want to change this message as i want as without affecting directly. Is any other way to do this?

chriszz’s picture

The Patch somehow resolved the issue, but a new issue comes up: If a user after paying in PayPal clicks on the redirect link back to the shop, he arrives back on the page where he is send to PayPal - not on the confirmation page. Any ideas?