Conversation
Replace @SerialName-based serialization with a custom case-insensitive
serializer so both lowercase Stripe values ("trial") and uppercase Play
Store values ("TRIAL") deserialize correctly. Add missing CODE and
WINBACK variants to match iOS OfferType parity.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
@SerialName-based serialization onLatestPeriodTypewith a custom case-insensitive serializer, matching the existing pattern used byLatestSubscriptionStateSerializationExceptionwhen Stripe backend returns lowercaseofferTypevalues (e.g."trial") in subscription/entitlement responsesCODEandWINBACKvariants to reach parity with the iOSOfferTypeenumReceiptManager.determinePeriodType()to handle the two new variantsTest plan
"offerType": "trial"and confirm no exception is thrown"TRIAL"still deserialize correctlydeterminePeriodType()returns the expected string for allLatestPeriodTypevalues🤖 Generated with Claude Code
Greptile Summary
This PR successfully fixes the
SerializationExceptioncrashes caused by Stripe returning lowercaseofferTypevalues by implementing a custom case-insensitiveKSerializeronLatestPeriodType. The implementation correctly mirrors the deserialization pattern used in the codebase.Changes verified:
LatestPeriodType.kt: Custom deserializer with case-insensitive matching of enum values (handles "trial", "TRIAL", etc.)LatestPeriodType.kt: AddsCODEandWINBACKenum variants for parity with iOSReceiptManager.kt: All sixLatestPeriodTypevalues are handled indeterminePeriodType()with appropriate string mappingsThe fix correctly resolves the stated problem: lowercase values from Stripe now deserialize without exceptions, while maintaining backward compatibility with existing uppercase formats.
Confidence Score: 4/5
offerTypevalues from Stripe. The custom serializer correctly implements case-insensitive deserialization, the new enum variants are properly added, and all six values are handled in thedeterminePeriodType()method. The implementation follows established patterns in the codebase. Minor consideration: the serializer throws on truly unknown values (rather than returning a fallback), but this is not a demonstrated issue with current Stripe data and the test plan focuses on known values.Sequence Diagram
sequenceDiagram participant Stripe as Stripe Backend participant SDK as SDK (JSON Deserializer) participant Serializer as LatestPeriodTypeSerializer participant RM as ReceiptManager Stripe->>SDK: { "offerType": "trial" } (lowercase) SDK->>Serializer: decodeString("trial") Serializer->>Serializer: find entry where name.equals("trial", ignoreCase=true) alt Known value (TRIAL, CODE, SUBSCRIPTION, PROMOTIONAL, WINBACK, REVOKED) Serializer-->>SDK: LatestPeriodType.TRIAL SDK-->>RM: latestSubscriptionPeriodType = TRIAL RM->>RM: determinePeriodType() → "trial" else Unknown value (e.g. "new_type") Serializer-->>SDK: throws SerializationException endLast reviewed commit: 0843c57