Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/2305 #2312

Draft
wants to merge 11 commits into
base: dev
Choose a base branch
from
Draft

Issue/2305 #2312

wants to merge 11 commits into from

Conversation

eri-trabiccolo
Copy link
Collaborator

@eri-trabiccolo eri-trabiccolo commented Dec 13, 2022

Description

Fixes #2305 for the part that regards to LifterLMS core.
Basically makes sure that if there's a trial transaction yet to be paid, when switching source, the trial price rather than the recurring payments price is displayed.
This is a minor fix, the important fix must be made on each payment gateway.

While there I also added some minor performance improvements by using the so called silver bullet no_found_rows when retrieving transactions without the need of pagination information, or total count.

How has this been tested?

manually and new unit tests

Screenshots

Types of changes

Bug fix (non-breaking change which fixes an issue)

Checklist:

  • My code has been tested.
  • My code passes all existing automated tests.
  • My code follows the LifterLMS Coding & Documentation Standards.

@eri-trabiccolo eri-trabiccolo marked this pull request as ready for review December 15, 2022 16:14
@eri-trabiccolo eri-trabiccolo self-assigned this Dec 15, 2022
@eri-trabiccolo eri-trabiccolo requested review from a team and removed request for thomasplevy December 30, 2022 09:31
@eri-trabiccolo
Copy link
Collaborator Author

eri-trabiccolo commented Jan 12, 2023

I'm realizing the trials require some additional analysis to be made, e.g. what happens to the first recurring payment when the trial has not been paid? Use case:

  • Buy a course with a trial of 1 year at 1$ and 10 months of recurring payments of 10$ each
  • Select the manual payment as gateway and complete the order
  • Never actually pay the fee
  • After one year the trial ends, you never paid for it, the order is still in pending payment
    You can potentially still go to your account to switch the source, but what should you be pay now? Ideally both the trial and the first recurring payment? But no it's not how it works right now, only the first recurring payment fee will be displayed, and with this PR only the trial fee instead will be displayed.

When you switch the source, because of the issue #2305, all the gateways, as of now, will ask you to pay the first recurring payment, basically skipping the payment of the trial, and the next recurring payment will be calculated based on the recurring payment rule, so 1 month starting from:

  • if the trial has not ended yet: from the trial end date .
  • if the trial has ended: from the last successful transaction (the one you just paid) if the stored next payment date for the order is passed (as in the case, because the stored next payment date is the first recurring payment date which is the trial end date).

I'm thinking that when the trial ends if you haven't paid it no recurring payment should ever be requested and the order should go to "failed" status, or at least you shouldn't be able to switch the source at all. I think that we should prevent source switching for orders with unpaid trials when the trial ended, and we'll be fine.

I'm turning this PR to a draft while we think to a better solution.

I'm going extrapolate the performance improvements from this and turn that part into a new PR.

@eri-trabiccolo eri-trabiccolo removed the request for review from a team January 12, 2023 10:56
@eri-trabiccolo eri-trabiccolo marked this pull request as draft January 12, 2023 10:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: To do
Development

Successfully merging this pull request may close these issues.

None yet

1 participant