pronamic / wp-pronamic-pay-memberpress

MemberPress driver for the WordPress payment processing library.
http://www.wp-pay.org/extensions/memberpress/
4 stars 1 forks source link

Lifetime subscription expires after last payment #2

Closed rvdsteege closed 2 years ago

rvdsteege commented 2 years ago

From customer:

Onze cursus is in Memberpress ingesteld als 10 maandelijkse termijnen van 39 euro, met daarna onbeperkt toegang. Nu is het de laatste maanden zo dat members op inactief komen te staan in Memberpress, nadat de laatste termijn geweest is.

It seems we're always setting the expires_at date in the transaction if the payment periods contains a valid period, but should leave it empty if the transaction is the last transaction for the membership:

Schermafbeelding 2022-02-28 om 16 41 47

https://github.com/pronamic/wp-pronamic-pay-memberpress/blob/4.0.1/src/Extension.php#L281-L304

I tried using $period->get_phase()->get_subscription()->get_current_phase()->get_next_date() there, which will be null if there are no future follow-up payments, but it's not yet updated to the next date at this point in the payment flow.

Internal Help Scout ticket: https://secure.helpscout.net/conversation/1794147711/23568

remcotolsma commented 2 years ago

@rvdsteege Shouldn't we also consider the "Access After Last Cycle" here?

Schermafbeelding 2022-03-01 om 10 47 47

I noticed that other gateways don't set the expires_at value at all in the record_subscription_payment() function. They let MemberPress figure this out in the MeprTransaction->store()MeprTransaction::create( $txn ) function. As soon as a gateway (PayPal / Stripe) sends an expire notification they call MeprSubscription->limit_reached_actions()? Since we don't get a notification from Mollie we have to figure out if it's the last payment / transaction for the MemberPress subscription?

if ( $pronamic_subscription->all_periods_created() ) {
    $memberpress_subscription->limit_reached_actions();
}

https://github.com/wp-premium/memberpress/blob/main/app/models/MeprSubscription.php#L894-L931