Closed davdebcom closed 2 years ago
This is indeed needed for subscriptions based businesses. Customers who chose to pay with SEPA are charged each month, but see their subscription put on hold until the payment is completed, which currently force shop owners to manually reactivate accounts each times it happens.
This is not scalable at all and very bad UX from the end user point of view.
More broadly, the order status & subscription status should not be changed when the renewal order is issued, but only when the payment gateway send a response.
This is not scalable at all and very bad UX from the end user point of view.
We can argue about that, but this was changed because other merchants argued that it's not correct to have users with an 'On-hold' subscription when their renewal payment is still pending, they argued it should be 'Active' until the renewal order fails. And that's why we will make it optional, so merchants can choose the option that fits their needs.
But this only refers to renewal orders, are you aware of that? Subscriptions already should be 'Active', even when the payment method is SEPA Direct Debit and the renewal order is not paid yet. Please check if this is the case for you. If this doesn't happen for you, please contact me on mollie@paytium.nl.
I don't agree with setting the order status to processing
for renewal orders. This works fine the way it is. Many businesses have e.g. invoicing plugin that is dependent on the woo statuses. Its not recommended to change this, it would certainly break their functionality for my clients.
I do agree with:
More broadly, the order status & subscription status should not be changed when the renewal order is issued, but only when the payment gateway send a response.
Thus, I wrote this as a solution to above comment but haven't tested it yet:
add_action( 'updated_users_subscriptions_for_order', 'wc_subs_active_on_directdebit' );
function wc_subs_active_on_directdebit( $order ) {
if ( ! is_object( $order ) ) {
$order = new WC_Order( $order );
}
foreach ( WC_Subscriptions_Order::get_recurring_items( $order ) as $order_item ) {
$subscription_key = WC_Subscriptions_Manager::get_subscription_key( $order->id, WC_Subscriptions_Order::get_items_product_id( $order_item ) );
$payment_gateways = WC()->payment_gateways->payment_gateways();
$payment_gateway = isset( $payment_gateways[ $order->recurring_payment_method ] ) ? $payment_gateways[ $order->recurring_payment_method ] : '';
if ( $payment_gateway->id == 'directdebit' && $order->get_status() == 'failed' ) {
WC_Subscriptions_Manager::reactivate_subscription( $order->user_id, $subscription_key );
}
}
}
Requested by @ndijkstra, see email 'Feature request' of 2018-02-12. Users want to be able to set the status for renewal orders that use SEPA direct Debit as payment method. They want to immediately have the order status be set to 'Processing' when the renewal order is created, even when SEPA Direct Debit payment is not yet completed. Current order status should stay as default.