I want to get the updated subscription expiration date when a user successfully completes renewal payment or his card gets charged when trial ends. Is there a way to get the updated date in woocommerce_subscription_renewal_payment_complete hook or in any other hook? I need to tell a third party service that subscription has been updated so that it should update its renewal date that code should supply. So for I have come with below code but I am not able get the updated subscription expiration date.
function cp_subscription_updated($subscription,$last_order ){
//print_R($last_order);
$last_order->update_status( 'completed' );
$sub_date = WC_Subscriptions_Order::get_next_payment_date ( $last_order, $subscription->get_id() );
update_user_meta($subscription->get_id(),'sub_date',$sub_date);
$userData= array('subscription_id' => $cp_sub_id ,'increase_date' =>date('m/d/Y',$sub_date));
reg_api_register($userData,API_ENDPOINT_UPDATE_SUBS);
return $last_order;
}
add_action('woocommerce_subscription_renewal_payment_complete','cp_subscription_updated',10,2);