Skip to content

Commit

Permalink
Merge pull request #25 from pronamic/24-next-payment-date-is-time-sen…
Browse files Browse the repository at this point in the history
…sitive

Set time of subscription next payment to membership time.
  • Loading branch information
rvdsteege authored Jul 31, 2024
2 parents b076fd1 + 4d9ba5f commit 2242a69
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/SubscriptionUpdater.php
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
);
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit 2242a69

Please sign in to comment.