Skip to content

Add extra error cases for web purchases redemptions#1899

Merged
tonidero merged 6 commits into
mainfrom
support-web-redemption-error-cases
Nov 8, 2024
Merged

Add extra error cases for web purchases redemptions#1899
tonidero merged 6 commits into
mainfrom
support-web-redemption-error-cases

Conversation

@tonidero

@tonidero tonidero commented Nov 4, 2024

Copy link
Copy Markdown
Contributor

Description

This adds some new result types to a web purchase redemption:

  • InvalidToken
  • AlreadyRedeemed
  • Expired. This one includes additional information like the obfuscated email where a new token was/will be sent and whether that email was sent.

This falls behind the experimental APIs introduced in #1889

Additionally, this renames parseAsDeepLink to parseAsWebPurchaseRedemption and removes the DeepLink type. This is a breaking change, but should be ok since the API is marked as experimental and not usable still by any customers.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't need separate error/success callbacks for this operation so had to change this. I could have moved that transformation outside, but it would mean we would need to be leaking the result body out of the backend class, so I thought this was a bit better...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These shouldn't really be used... But I added it so it fixes the compiler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Needed for some tests. I think it shouldn't hurt anything.

@tonidero tonidero requested review from a team November 4, 2024 16:40
@codecov

codecov Bot commented Nov 4, 2024

Copy link
Copy Markdown

Codecov Report

Attention: Patch coverage is 64.28571% with 20 lines in your changes missing coverage. Please review.

Project coverage is 82.07%. Comparing base (9f01e50) to head (78da650).
Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
.../kotlin/com/revenuecat/purchases/common/Backend.kt 57.14% 4 Missing and 5 partials ⚠️
...n/kotlin/com/revenuecat/purchases/common/errors.kt 57.14% 3 Missing ⚠️
...src/main/kotlin/com/revenuecat/purchases/errors.kt 66.66% 0 Missing and 3 partials ⚠️
.../purchases/interfaces/RedeemWebPurchaseListener.kt 50.00% 3 Missing ⚠️
...otlin/com/revenuecat/purchases/IntentExtensions.kt 0.00% 1 Missing ⚠️
...m/revenuecat/purchases/deeplinks/DeepLinkParser.kt 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1899      +/-   ##
==========================================
- Coverage   82.16%   82.07%   -0.10%     
==========================================
  Files         231      232       +1     
  Lines        8048     8088      +40     
  Branches     1132     1147      +15     
==========================================
+ Hits         6613     6638      +25     
- Misses        986      994       +8     
- Partials      449      456       +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@tonidero tonidero marked this pull request as ready for review November 7, 2024 09:39
@tonidero tonidero force-pushed the support-web-redemption-error-cases branch from a3ca925 to 5208298 Compare November 7, 2024 10:31
* might be sent if a new one wasn't already sent recently.
* The email where it will be sent is indicated by the [obfuscatedEmail].
*/
data class Expired(val obfuscatedEmail: String) : Result()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is obfuscated something like c*****ro@gmail.com?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, for example, t****@r*****.c**

*/
@ExperimentalPreviewRevenueCatPurchasesAPI
class WebPurchaseRedemption internal constructor(
internal val redemptionToken: String,

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this just be token?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm could be... It's internal so we can really change it whenever... I think it might be better to leave it as is so we know the type of token it is, not a strong opinion though

@tonidero

tonidero commented Nov 8, 2024

Copy link
Copy Markdown
Contributor Author

Will merge this. Everything is marked as experimental APIs and functionality hidden behind a feature flag right now.

@tonidero tonidero merged commit 4dc45a8 into main Nov 8, 2024
@tonidero tonidero deleted the support-web-redemption-error-cases branch November 8, 2024 08:21
tonidero pushed a commit that referenced this pull request Nov 8, 2024
**This is an automatic release.**

## RevenueCatUI SDK
### 🐞 Bugfixes
* Handle `IllegalArgumentException` when opening a Uri in the paywalls
(#1904) via Toni Rico (@tonidero)

### 🔄 Other Changes
* Create sample web purchase redemption app (#1908) via Toni Rico
(@tonidero)
* Add extra error cases for web purchases redemptions (#1899) via Toni
Rico (@tonidero)
* Use new web redemption endpoint (#1903) via Toni Rico (@tonidero)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants