I have a site that creates a subscription and sets up a direct debit on GoCardless it also raises invoices on Xero which all works perfectly.
The issue is on the renewal of the subscription. WooCommerce raises a payment request with GoCardless and Xero also raises a request for the invoice generated. Due to some complexities with Xero I need WooCommerce to only raise invocies for renewal orders and not collect payments via GoCardless (Xero will do this).
I have had a look and the following code should set the payment method to Manaul and payment type to Manual when a subscription becomes active.
add_action( 'woocommerce_subscription_status_updated', 'active_subscription_change_user_role', 100, 3 );
function active_subscription_change_user_role( $subscription, $new_status, $old_status ) {
// When subscrition status is updated to "active"
if ( $new_status === 'active' ) {
// Get the WC_Order Object from subscription
$subscription->set_requires_manual_renewal( true );
$subscription->set_payment_method( 'manual' );
}
}
I have the code running and have tested this with emails getting sent when an subscription status changes, however, the payment method for a subscription does not change when the subscription is changed to active.