Skip to content

Commit 8004004

Browse files
Fix the expiration date extension logic
1 parent c0f9aff commit 8004004

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

contracts/src/core/AggregationModePaymentService.sol

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,13 @@ contract AggregationModePaymentService is Initializable, UUPSUpgradeable, Access
222222
revert SubscriptionLimitReached(monthlySubscriptionLimit);
223223
}
224224

225-
subscribedAddresses[msg.sender] = block.timestamp + paymentExpirationTimeSeconds;
225+
if (subscribedAddresses[msg.sender] < block.timestamp) {
226+
// If user has not an active subscription, the next expiration date is the current time plus the expiration window
227+
subscribedAddresses[msg.sender] = block.timestamp + paymentExpirationTimeSeconds;
228+
} else {
229+
// If user has already an active subscription, the next expiration date is the user expiration deadline plus the expiration window
230+
subscribedAddresses[msg.sender] = subscribedAddresses[msg.sender] + paymentExpirationTimeSeconds;
231+
}
226232

227233
uint256 newExpiration = subscribedAddresses[msg.sender];
228234

0 commit comments

Comments
 (0)