Open
Description
We recently ran into a situation where the paid dates on several orders were being updated sometimes many months after the order was actually paid for. Here's the flow we have seen using WooCommerce, Subscriptions, and Stripe.
- A renewal order is created and paid for via the Stripe gateway.
- The customer files a dispute with their credit card company. The order's status is changed to
on-hold
while the dispute is investigated. - When the dispute is won, the order status is returned to its original state prior to the dispute. In this case, the updated status is
completed
. - At this point the paid date is also updated to the current date/time.
After digging into this for a bit, it appears the date is being updated in WC_Subscriptions_Renewal_Order::maybe_record_subscription_payment
. This method is hooked into the woocommerce_order_status_changed
action and is designed to only impact renewal orders.
Would it be possible to swap out the call to $order->set_date_paid()
for $order->maybe_set_date_paid()
? The latter method checks to see if the paid date is already set and only updates it if it hasn't been set already.
Thanks for your consideration.
Activity