WoCommerce Subscriptions processes automatic renewal payments via the following flow:
- its scheduling system, Action Scheduler, will run every minute and find any
woocommerce_scheduled_subscription_payment
actions scheduled to run now or within the last minute - if there are
woocommerce_scheduled_subscription_payment
actions scheduled for anytime before now, Action Scheduler will grab a batch of those actions and begin processing them (which just means triggeringdo_action( 'scheduled_subscription_payment', $subscription_id )
for any 3rd party code to handle) - Subscriptions attaches two important functions as callbacks on the
'woocommerce_scheduled_subscription_payment'
hook to process renewal for that subscription when it is called: WC_Subscriptions_Manager::prepare_renewal()
, which is responsible for