After enabling the new default "Update order status on full payment" workflow, I see this in the order log after a successful paypal ipn payment ...
- PayPal payment for $10.00 entered by -.
- Order status changed from in_checkout to payment_received
- Checkout message sent to foo@...
and then the killer
- Order status changed from payment_received to pending
This all happened before I clicked to go back to the store from paypal so it's not related to the complete checkout return. The ipn code is doing all of this. The payment workflow is seeing balance zero and setting the appropriate status. But change to pending clobbers it. Here's the culprit in uc_cart.module line 1761:
// Move an order's status from "In Checkout" to "Pending"
if (uc_order_status_data($order->order_status, 'state') == 'in_checkout') {
uc_order_update_status($order->order_id, uc_order_state_default('post_checkout'));
}I have the new default uc_payment workflow installed which is doing its thing and then getting clobbered by the above code. The status check appears to be stale or bad since the status has already been changed to payment_received, but it still thinks it's in_checkout. The problem will be solved, I think, if the order status check was done directly against the database. The payment workflow is firing after an ipn comes in and then it updates the status, but it's not getting updated in the passed order object.
Changing this code slightly to this ugly hack:
$tmporder = uc_order_load($order->order_id);
// Move an order's status from "In Checkout" to "Pending"
if (uc_order_status_data($tmporder->order_status, 'state') == 'in_checkout') {
uc_order_update_status($order->order_id, uc_order_state_default('post_checkout'));
}seems to fix the race condition. Does uc have any sort of real-time order status api call?
This bug happens with the latest bazaar. Workflow and ipn affect other places in the code too! Some sort of api to check actual status should be used throughout.




(Fixed by wiping the cart_order session variable on a cart update or item add to cart; will commit before I leave today.)



Joined: 10/08/2007