When updating a subscription with offline payment, user groups are no longer set

  • Aicha Vack
  • Topic Author
  • Offline
  • New Member
  • New Member
More
3 months 3 weeks ago #175955 by Aicha Vack
Dear MemberShip Pro Team,

We have been using Membership Pro for several years now to sell subscriptions.
The subscription period is one year.
We offer PayPal and offline payment as payment methods.
Offline payment is rarely used.

Users with active subscriptions are assigned to a separate Joomla user group.
When the subscription expires, the user is removed from the user group.

We have now noticed that this mechanism no longer works correctly when
a user renews a subscription,
selects the offline payment method,
and the renewal payment is made before the old subscription expires.

The problem likely started with a Membership Pro update a few months ago.
Because we have so few offline payments, it was only noticed now.
Setting user groups worked correctly in version up to 4.0.0.
It doesn't work in the current version 4.4.1, but probably hasn't worked since version 4.3 or even earlier.

The problem seems to be caused by a changes to the file administrator/components/com_osmembership/model/subscription.php.
The following code has been newly added to the publish() function.
Code:
if (str_starts_with($row->payment_method ?? '', 'os_offline')     && !(int) $rowPlan->expired_date) {     $this->reCalculateSubscriptionDuration($row); }

When a subscription is updated, the start date and time are adjusted when the subscription record is created so that the new subscription starts on the same day the old one expires.
If the offline payment is made before the old subscription expires but after the new subscription is ordered,
then the reCalculateSubscriptionDuration function shifts the start date of the new subscription forward by the number of days the payment is made after the order date.

At the same time, the new subscription is activated.
When the old subscription expires, the user is removed from the user group.
However, since the new subscription is already active, the user is not re-added to the correct user group.
This results in people having an active subscription but still not having access to the areas they should be allowed with that subscription.

Similar code for `reCalculateSubscriptionDuration` was also added to the file `administrator/components/com_osmembership/libraries/mpf/payment/common.php`.

I cannot determine whether the solution to the problem lies in revising the code that sets and removes user groups or in revising the `reCalculateSubscriptionDuration` function.

In any case, the assignment of user groups no longer works correctly when using the offline payment method and manually activating a subscription after the payment was recieved (some days later).

Regards and thanks for your nice extension,
Aicha

Please Log in or Create an account to join the conversation.

More
3 months 3 weeks ago #175958 by Tuan Pham Ngoc
Thanks Aicha for your feedback. I will check and correct it if the issue is valid, sometime next week

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Aicha Vack
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 4 days ago #177381 by Aicha Vack
Hi Tuan,

were you able to check into this?

Regards,
Aicha

Please Log in or Create an account to join the conversation.

More
2 weeks 3 days ago #177387 by Tuan Pham Ngoc
Hi Aicha

I forgot about this issue, sorry. Is it OK for you to give me access to your site, then tell me step by step what I need to do to see the issue you mentioned ?

Or tell me exactly step by step what I need to do to replicate the issue on my local computer. I will then check and get it sorted

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Aicha Vack
  • Topic Author
  • Offline
  • New Member
  • New Member
More
2 weeks 3 days ago #177410 by Aicha Vack
Hello Tuan,

sadly I cannot give you access to our site but I gladly provide a instruction on how to reproduce the problem.

Steps to reproduce the problem
(I've only listed the steps and configration settings, which I think are relevant for reproducing the problem)

1. create a user group which is exclusively used for this reproduction. Parent user group is registerd.
2. enable the Membership Pro (MP) offline payment plugin
3. MP General Settings
    a. Registration Integration: Yes
3. create a MP Subscription Plan with the following settings
    a. Subscription Length 7 Days
    b. Enable Reneval: Yes
    c. Payment Options: All Payment Methods
    d. Subscription Start Date Option: 'Register Date'
    e. Joomla Group Settings:
        i. When Subscription Active: Assign To Joomla Groups (select the user group which you have created in step 1)
        ii. When Subscription Expired: Remove From Joomla Groups (select the user group which you have created in step 1)
4. Create a Menu Item of type 'Membership Pro >> Pricing Table Layout'
    a. On the 'Options' tab, in the listbox 'Plans', select the plan, which you have create in Step 3.
5. In the frontend, go to the Menu Item, which you have created in step 4 and subscribe
    a. Make sure that this item is set as payed immediately (set to status active).
    b. Note: User is added to the user group which you have created in step 1
6. In the frontend, go to the Menu Item, which you have created in step 4 and subscribe a second time with the same user.
    a. Make sure you have selected the payment method 'Offline Payment' this time and do not active the item immediately
    b. Note: The start and end date for this item are set correctly, so that the new item will start immediately after the first one expires.
7. Wait 2 days
8. Set the subscription second item which you have create in step 6 to payed (status active)
    a. Note: The start and end date are shifted two days in the future, compared to 6.b.
       There is now a gap between the end date of the first item (created in step 5) and the start date of the second item (created in step 6)
9. Wait 5 more days (until first item is expired and unpublished automatically).
    a. Note: User is removed from the user group, which you have created in step 1
10. Wait 2 more days (actual until start date of second item is reached)
    a. Note: User is not added again to the user group, which you have created in step 1

Expected result.
- first subscription item is deaktived
- second subscription item is activated
- start date of second item should be immedately after the end date of the first item
- user is member of the user group created in step 1
- user has access to the content which user of the group created in step 1 can access

Acual result:
- first subscription item is deaktived
- second subscription item is activated
- there is a 2 days gap between the start date of second item and the end date of the first item
- user is removed from the user group created in step 1 and never added again
- user has no access to the contnet which user of the group created in step 1 can access

Regards,
Aicha
 

Please Log in or Create an account to join the conversation.

More
2 weeks 2 days ago #177412 by Tuan Pham Ngoc
Hi Aicha

I believe I found the reason of the error and got the issue fixed. Please access to My Downloads menu item, download latest package, update it to your site, then check it again. The error should be gone

Regards,

Tuan

Please Log in or Create an account to join the conversation.

  • Aicha Vack
  • Topic Author
  • Offline
  • New Member
  • New Member
More
1 week 3 days ago #177540 by Aicha Vack
Hi Tuan,

Thanks a lot!

I've downlaoded and installed the new version.
I will let you know if it works, as soon as I have the next renewal with offline payment.

Regards,
Aicha

 

Please Log in or Create an account to join the conversation.

More
1 week 2 days ago #177548 by Tuan Pham Ngoc
OK. Thanks Aicha

Please Log in or Create an account to join the conversation.

Moderators: Tuan Pham Ngoc