php – woocommerce subscriptions – get expiration date

By using the callback link, I can get the subscription information of any EXCEPT expiration date. Any thoughts on how to grab this. This is what I have:

function mmd_woointerface_ProcessOrder ($ order_id)
{
$ order = new WC_Order ($ order_id);
$ OrderNumber = $ order-> parent_id;
$ ParentOrder = new WC_Order ($ OrderNumber);
$ TransactionId = $ ParentOrder-> get_transaction_id ();

$ DatePaid = $ order-> date_created;
$ SubscriptionNumber = $ order-> get_order_number ();
$ PaymentDate = $ order-> get_date_created () -> format (& # 39; Y-m-d & # 39;);
$ ProductId = $ product-> get_product_id ();
$ subscriptions = wcs_get_users_subscriptions ($ UserId);
foreach ($ subscriptions as $ sub)
{
if ($ sub-> ID == $ SubscriptionNumber)
$ ExpireDate = $ sub-> get_expiration_date (& # 39; next_payment & # 39;); << NOT PRECISE
$ ExpireDate = WC_Subscriptions_Order :: get_next_payment_date ($ ParentOrder, $ ProductId); << the same problem
}
}

These calls:

    $ ExpireDate = $ sub-> get_expiration_date (& # 39; next_payment & # 39;);

$ ExpireDate = WC_Subscriptions_Order :: get_next_payment_date ($ ParentOrder, $ ProductId); 

they are not effective when you have a user who makes a manual advance payment. Simply return the next payment date, it is the actual expiration date stored