diff --git a/src/SubscriptionUpdater.php b/src/SubscriptionUpdater.php index 883c0c4..bfdf9a7 100644 --- a/src/SubscriptionUpdater.php +++ b/src/SubscriptionUpdater.php @@ -77,9 +77,11 @@ public function update_pronamic_subscription() { $interval_spec = 'P' . $rcp_membership_level->get_trial_duration() . LengthUnit::to_core( $rcp_membership_level->get_trial_duration_unit() ); } + $initial_phase_start_date = new DateTimeImmutable( $rcp_membership->get_created_date( false ) ); + $initial_phase = new SubscriptionPhase( $pronamic_subscription, - new DateTimeImmutable( $rcp_membership->get_created_date( false ) ), + $initial_phase_start_date, new SubscriptionInterval( $interval_spec ), new Money( $rcp_membership->get_initial_amount(), $rcp_membership->get_currency() ) ); @@ -114,7 +116,12 @@ public function update_pronamic_subscription() { if ( false !== $expiration_timestamp ) { $next_payment_date = new DateTimeImmutable( '@' . $expiration_timestamp ); - $next_payment_date = $next_payment_date->setTime( 0, 0, 0 ); + + $next_payment_date = $next_payment_date->setTime( + (int) $initial_phase_start_date->format( 'H' ), + (int) $initial_phase_start_date->format( 'i' ), + (int) $initial_phase_start_date->format( 's' ) + ); } $pronamic_subscription->set_next_payment_date( $next_payment_date );