pronamic / wp-pay-core

Core components for the WordPress payment processing library. This library is used in the WordPress plugin Pronamic Pay: https://www.pronamicpay.com/, but also allows other plugin developers to set up a payment plugin.
https://www.wp-pay.org/
GNU General Public License v3.0
27 stars 3 forks source link

Subscription phase alignment issue for subscriptions with end date #182

Closed remcotolsma closed 2 months ago

remcotolsma commented 2 months ago

Through a customer we discovered a problem with subscription phase alignment for subscriptions with an end date.

Internal HelpScout tickets:

Discussed with @rvdsteege at @Pronamic HQ, the solution consists of 3 parts.

Allow partial periods in subscription phase period creation

Related code:

https://github.com/pronamic/wp-pay-core/blob/b0a6a19963b5615996ef11cadcfc50b7e8a1b494/src/Subscriptions/SubscriptionPhase.php#L487-L491

    if ( null !== $this->end_date && $end_date > $this->end_date ) {
        // Should we check if start date is before $this->end_date?
        $end_date = $this->end_date;
    }

No longer use total periods in subscription alignment

Related code:

https://github.com/pronamic/wp-pay-core/blob/b0a6a19963b5615996ef11cadcfc50b7e8a1b494/src/Subscriptions/SubscriptionPhase.php#L674-L694

It would be easier to understand if we extend a possible regular phase end date with the alignment period/interval?

Improve user interface in Gravity Forms subscription alignment settings

Related code:

https://github.com/pronamic/wp-pronamic-pay-gravityforms/blob/325d139b0c88ae43647d639159e3c64551143369/views/html-admin-feed-settings.php#L805-L985

Scherm­afbeelding 2024-06-05 om 13 17 21

Suggested change in Dutch:

Betalingsdatum uitlijnen ☑️ Betalingsdatum uitlijnen inschakelen Het is mogelijk om de eerst volgende betalingsdatum uit te lijnen op een vaste dag van de week, maand of jaar. Hiervoor wordt er een extra abonnementsfase toegevoegd aan het begin van het abonnement. Als het aantal perioden vast staat ingesteld krijg je er dus altijd 1 extra periode bij. Het af te rekenen bedrag voor deze uitlijningsfase kan naar rato worden berekend.

remcotolsma commented 2 months ago

⚠️ 🚨 Another important addition: In the screenshot, the fixed periods settings is set to 2, which currently results in 1 period in the alignment phase and 1 period in the regular phase. After the proposed change it will result in 1 period in the alignment phase and 2 periods in the regular phase. This because we believe that this makes more sense? Otherwise the following entry/payment would result in only one alignment period:

Interval: 1 year Fixed periods: 1 Alignment date: January 1 Entry date: December 15, 2024

This would make more sense?

  1. Alignment period: December 15, 2024 - December 31, 2024
  2. Regular period: January 1, 2025 - December 31, 2025

For this client we can change the fixed periods setting from 2 to 1, for other clients a changelog note?

rvdsteege commented 2 months ago

Re-opening for "Improve user interface in Gravity Forms subscription alignment settings".

The name and description of the setting are already updated in https://github.com/pronamic/wp-pronamic-pay-gravityforms/commit/df49d2d9a370ab0515f309914dbc1c506dfaa7c1.

Scherm­afbeelding 2024-06-05 om 16 58 34
remcotolsma commented 2 months ago

Closing this issue, moved the open task to the Pronamic Pay Gravity Forms repository: