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

Downgrading doesn't check for failed/missed payments #9

Open
dparker1005 opened this issue Sep 30, 2019 · 0 comments
Open

Downgrading doesn't check for failed/missed payments #9

dparker1005 opened this issue Sep 30, 2019 · 0 comments

Comments

@dparker1005
Copy link
Member

dparker1005 commented Sep 30, 2019

To re-create:

  1. Payment fails at the gateway.
  2. Member notified of the failed payment.
  3. Member logs in and clicks the downgraded member level.
  4. They’re shown the correct price and enter their new credit card details.
  5. Amount charged on receipt shows $0.

Downgrading the membership level should first check that they have paid until the current date, just as the code for memberships with the same payment periods do below:

$payment_date = pmprorate_trim_timestamp( $morder->timestamp );
$next_payment_date = pmprorate_trim_timestamp( pmpro_next_payment( $current_user->ID ) );
$today = pmprorate_trim_timestamp( current_time( 'timestamp' ) );
$days_in_period = ceil( ( $next_payment_date - $payment_date ) / 3600 / 24 );
//if no days in period (next payment should have happened already) return level with no change to avoid divide by 0
if ( $days_in_period <= 0 ) {
return $level;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant