在处理Woocommerce订阅中的订单之前更新续订金额的钩子是什么?

Is it possible to prorate the charge to be paid for the last renewal order before the end date of a subscription? For example, if the last renewal order would be created within 30 days or less of the end date of the subscription, it won't charge the full amount of the subscription but instead only charge for the period between the last order and the end date. For example,

  • monthly subscription costs 19.99/month
  • customer purchases a subscription
  • customer pays for it monthly
  • subscription is set up to end on april 30, 2019. last order date before this date would be april 12, 2019

for the scenario above, on april 12, 2019, the existing behavior would charge 19.99 even if the remaining time isn't a full month.

we were wondering if it's possible to prorate this so that the charge would only be for the remaining 18 days. so instead of 19.99, the charge would be 11.994 or ~12. we were informed before that there's currently no option for this in WooCommerce.

But we found in "Programmer's guide for woocommerce subscriptions - Action-reference section" a hook named woocommerce_scheduled_subscription_payment_{$gateway_id} for the payment to be processed including the amount to be paid.

Could this be used for a custom payment proration code?

I found this guide for the subscription renewal process as well.

And based on all this, woocommerce_scheduled_subscription_payment_{$gateway_id} action hook seems to be the most logical place to do a filter for to change the amount although, we're not sure if this is correct or is possible to do.

if it is, where could we get the gateway_id since we use both Stripe and Paypal.

Also, assuming it's possible, from the order, is it possible to get the attached subscription for it so we could get the subscription charge and the payment interval (per month or per year).