Closed fire-at-will closed 3 days ago
@MarkVillacampa thanks for the review! 🙌 I've made the following changes:
ConfigureStrings.swift
as mentioned in your review notesCustomerInfoHandler.swift
:
private let isDebug
property from () -> Void
to Bool
isDebug
in the constructor a Bool
and made the default closure value auto complete
Motivation
Making purchases with Store Kit 2 requires developers to upload an In App Purchase Key to RevenueCat. Currently, we log a warning when a developer tries to make a purchase with an invalid In App Purchase Key, but the problem can easily be missed because the purchase still completes, and if offline entitlements are enabled, entitlements can be unlocked, but the RevenueCat backend will never be able to validate and register the purchase because we can't verify the purchase with Apple.
Ultimately, this could lead to developers upgrading from SDK version 4.X to 5.X, not realize that they need to upload their in app purchase key, and ship a build to production that can't properly make purchases.
Description
This PR modifies the
purchase()
function to throw an error if the app is running in a DEBUG build and the RevenueCat backend returns an error response because the developer has an invalid or missing In App Purchase Key. When it throws an exception, the following error message is logged with thewarn
level:The PR accomplishes this behavior by modifying the
CustomerInfoResponseHandler
class. To ensure that the error is only thrown forPOST /receipt
calls and notGET /subscriber
calls, a new initializer parameterfailIfInvalidSubscriptionKeyDetectedInDebug
has been introduced to control the throwing behavior when the error is received from the backend.