Skip to content

Conversation

ajpallares
Copy link
Member

This is the first PR of a series to add support for the Test Store in the SDK.

Checklist

  • If applicable, unit tests
  • If applicable, create follow-up issues for purchases-android and hybrids

Motivation

The SDK has to identify API keys for the Test Store to modify its behavior accordingly

Description

Adds the validation of the Test Store API keys under the TEST_STORE compiler flag

@ajpallares ajpallares requested a review from a team July 16, 2025 10:57
Comment on lines +385 to +390
#if TEST_STORE
if apiKey.hasPrefix(testStoreKeyPrefix) {
// Test Store key format: "test_CtDdmbdWBySmqJeeQUTyrNxETUVkajsJ"
return .testStore
}
#endif // TEST_STORE
Copy link
Member Author

@ajpallares ajpallares Jul 16, 2025

Choose a reason for hiding this comment

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

Having only this under the TEST_STORE flag is enough, since the APIKeyValidationResult enum is an internal API

Copy link

emerge-tools bot commented Jul 16, 2025

📸 Snapshot Test

1 modified, 704 unchanged

Name Added Removed Modified Renamed Unchanged Errored Approval
RevenueCat
com.revenuecat.PaywallsTester
0 0 0 0 235 0 N/A
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-optimized-for-mac
0 0 1 0 234 0 ✅ Approved
RevenueCat
com.revenuecat.PaywallsTester.mac-catalyst-scaled-to-match-ipad
0 0 0 0 235 0 N/A

🛸 Powered by Emerge Tools

@@ -396,12 +404,14 @@ extension Configuration {
fileprivate static func verify(apiKey: String) {
switch self.validate(apiKey: apiKey) {
case .validApplePlatform: break
case .testStore: Logger.warn(Strings.configure.testStoreAPIKey)
Copy link
Member Author

Choose a reason for hiding this comment

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

I wasn't sure about this being a warning or just a debug log. I think making it a warning doesn't harm and serves as a constant reminder that the Test Store API key will eventually need to change. Lmk if you think otherwise!

Copy link
Contributor

@tonidero tonidero left a comment

Choose a reason for hiding this comment

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

Looks great! Just a small comment but not blocking

case .legacy: Logger.debug(Strings.configure.legacyAPIKey)
case .otherPlatforms: Logger.error(Strings.configure.invalidAPIKey)
}
}

private static let applePlatformKeyPrefixes: Set<String> = ["appl_", "mac_"]
private static let testStoreKeyPrefix = "test_"
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering should we make it a bit more explicit? Something like rc_test_? Not sure if we discussed this in the past though 😅

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, that's a very good point. I don't have a strong opinion in favor or against it, but, for sure, it's something that we can change anytime as long as we have the TEST_STORE compiler flag ON

@ajpallares ajpallares merged commit 3855383 into main Jul 17, 2025
12 checks passed
@ajpallares ajpallares deleted the test-store/add-test-store-api-key-validation branch July 17, 2025 14:24
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