Skip to content

Conversation

@akDeveloper
Copy link
Member

No description provided.

Resolved Issues:
- Null Pointer Risk in receivePayment()
  Fixed by adding null coalescing assignment to initialize paidThrough
  if null before modification: $this->paidThrough ??= new DateTime('today');

- DateTime Mutation in receivePayment() (Removed)
  Determined to be working as designed - mutation is intentional with DateTime
Add defensive null check for paidThrough in getRemainingDays() method.
Returns 0 for free plans which don't have a paidThrough date, preventing
null pointer exceptions when calculating remaining days.
- Add status reset to ACTIVE in receivePayment() method
  When a subscription receives payment, the status is now properly reset
  to ACTIVE, fixing the issue where subscriptions remained in PAST_DUE
  status after successful payment recovery.

- Fix DateTime mutation in expireAfterGrace() method
  Cloned the DateTime object before modification to prevent unintended
  side effects on the paidThrough date when calculating grace period.

- Fix coupon sorting inconsistency
  Replaced incomplete comparison with spaceship operator (<=>) to ensure
  stable and deterministic sorting when multiple coupons have the same
  discount value.

- Fix null return type in Freemium::getExpiredPlan()
  Updated return type annotation to ?SubscriptionPlan to accurately
  reflect that the method can return null.
- Fix potential division by zero in CreditRemainingValueCalculator
  Added check for zero daily rate before division to prevent fatal error
  when calculating credit for plan changes involving free plans. When
  daily rate is zero, the paidThrough date is set to today and the
  calculation is skipped.

- Add validation in setSubscriptionPlan() to prevent unnecessary changes
  Skip plan change processing if the new plan is the same as the current
  plan, preventing unnecessary audit trail entries and subscription change
  records.
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

Successfully merging this pull request may close these issues.

2 participants