I'm writing a payment gateway that handles WooCommerce subscriptions. Here is the sample code that handles the renewal:
public function mcc_subscription_renewal($amount, $order) {
$tid = 123;
$order->payment_complete( $tid );
$order->update_status( 'completed' );
WC_Subscriptions_Manager::process_subscription_payments_on_order( $order );
}
This is for a simple subscription that charges the customer a fixed fee every year. When I manually run the renewal process, a new order and scheduled action are created successfully, but the date isn't updated to the next year. What am I missing? Why isn't a successfully completed renewal order updating the expiry date of a subscription?