plugins – Woocommerece subscription retry fail payment


I need help understanding. How i need to approach the payment retry process for fail payments. For the moment i will just using.

add_action( 'woocommerce_scheduled_subscription_payment_'.$this->id, array( $this, 'scheduled_subscription_payment' ), 10, 2 )

Which call my payment gateway and process the payment. and based on response i will update the order status.

If success payment

$renewal_order->update_status( 'wc-completed');

if payment fails

renewal_order->update_status( 'wc-cancelled'); 

if payment require authentication

renewal_order->update_status( 'wc-pending'); 

I was plan to integration fail payment retry process to current integration. I was going through this documentation. But I still not able to figure out how to setup this retry process. If any one send me some heads up would be great.