I have Woocommerce orders that are pending payment. At the moment when an order hits the automatic retry payment schedule it pulls the payment information from the subscription, which works great as the customer may have corrected their wrong details by then.
But in some cases, we need to manually retry the payment. When this is done, it doesn't pull the payment information from the subscription (as the customer may have corrected their details for it to go through).
Is there a hook/action that I can use to fire the following code? woocommerce_subscriptions_before_payment_retry
doesn't seem to work.
add_action('woocommerce_subscriptions_before_payment_retry', 'remove_payment_details', 10, 2 );
function remove_payment_details( $order_id ){
$order = wc_get_order( $order_id ); // Order Object
$subscriptions = wcs_get_subscriptions_for_order( $order_id, array( 'order_type' => 'any' ) ); // Array of subscriptions Objects
foreach( $subscriptions as $subscription_id => $subscription ){
$stripe_cust_id = $subscription->get_meta( '_stripe_customer_id');
$stripe_src_id = $subscription->get_meta( '_stripe_source_id' );
$order->update_meta_data( '_stripe_customer_id', $stripe_cust_id );
$order->update_meta_data( '_stripe_source_id', $stripe_src_id );
$order->save();
}
}