IAV-1053 : correct critical bugs in checkout and subscription handling
ISSUES FIXED:
-
Fix missing onFirstSubscriptionCompleted() call in checkout flow Previously, users purchased via checkout would not have referral codes created
-
Add null checks for subscription metadata to prevent NPE Map<String, String> metadata could be null in handleSubscriptionChange()
-
Enforce metadata validation in extra credit purchases Prevent silent failures when METADATA_CREDITS is missing
-
Improve exception handling with explicit error logs Change debug logs to warn logs in getSubscriptionIdFromInvoice() and getCustomerIdFromInvoice() for better production observability
-
Strengthen webhook idempotence createReferralForUser() now handles existing referrals gracefully
-
Add wallet existence check in saveSubscriptionCurrency() Log error if wallet not found instead of silently skipping
CHANGES:
- handleFirstSubscriptionFromCheckout: add onFirstSubscriptionCompleted() call
- processExtraCreditPurchase: add metadata null check
- handleSubscriptionChange: initialize metadata if null
- getSubscriptionIdFromInvoice/getCustomerIdFromInvoice: upgrade debug to warn logs
- createReferralForUser: handle existing referrals as non-error case
- saveSubscriptionCurrency: add wallet not found error logging
Closes IAV-1053