The latest release in the 6.x branch (2.7) all of a sudden causes email to be sent out when a payment is entered.
The reason is the function uc_payment_enter now calls uc_cart_complete_sale($order), which it did not do before.
Not only is this behavior unwanted from the point of view of a customer (who now gets email whenever a payment is entered), it also breaks the UberPOS module if the default (non-development) version of the UC Adresses module is installed. Orders in UberPOS are for the most part made for anonymous users. If the uc_cart_complete_sale function is called when a payment is entered, the uc_checkout_complete hook is invoked, which causes the uc_addresses module to attempt to save an address for an anonymous user, which it can't do, causing an error.
My question is why entering a payment now calls uc_cart_complete. To me it seems these two things are separate, no?
If it isn't absolutely necessary, could this change be reverted? It would be nice if UberPOS keeps working the way it always has, without errors in uc_addresses and without sending email when a payment is entered.
Comments
Comment #1
longwaveThis was done to streamline the order completion process and ensure that user accounts were created before the "payment received" trigger was fired, so roles, file downloads, etc are triggered correctly for anonymous users, and also to help fix the longstanding duplicate emails issue with PayPal.
It is true that the checkout process should be "completed" before any payment is logged against the order, but perhaps we need a separate way of dealing with this for anonymous orders that do not go through the standard checkout process.
Patches or suggestions are welcome, but they must pass the recently added tests which ensure duplicates are not sent.
Comment #2
rhmtts commentedI'm well aware that "UberPOS sending out emails" and "UberPOS crashing with uc_addresses" are of limited importance within the greater scope of Ubercart. To get a clearer understanding of the problem, could you answer these questions please?
- What is the reason PayPal sent out duplicate emails? Can this not be fixed in the PayPal module itself?
- How many modules (that you know of) depend on the payment received trigger never firing for anonymous users?
- If the uc_payment_enter function would simply get an extra parameter for disabling completion of the sale, would that be a problem?
(my personal preference would be, however, to give it an extra parameter for completing the sale upon payment, as that was the default behavior pre-2.6, but if that can't be done, so be it).
Comment #3
vasrush commentedThis change seems to break uc_free_order module too.
http://drupal.org/node/1371760#comment-5446736
Adding an if statement fix it for my occassion
Comment #4
longwave#1669968: hook_uc_checkout_complete() is called outside of checkout process (when payment is entered) has a better analysis and some suggestions for fixing this issue.