Skip to content

Conversation

tonidero
Copy link
Contributor

Description

This is the first of a series of PRs to support a test store in purchases-android.

In this one, we add support for a new test API key and expose the API key validation result to the billing factory, so we can in future PRs create a billing implementation for this test store.

@tonidero tonidero marked this pull request as ready for review July 17, 2025 08:53
@tonidero tonidero requested a review from a team July 17, 2025 08:53
Copy link
Member

@JayShortway JayShortway left a comment

Choose a reason for hiding this comment

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

Looks good! Just a question.

Comment on lines +27 to 30
if (apiKeyValidationResult == APIKeyValidator.ValidationResult.TEST_STORE) {
// WIP: Implement a test store billing provider
errorLog { "Using test API key is not yet supported. Assuming non test store." }
}
Copy link
Member

Choose a reason for hiding this comment

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

I'm curious why we need the ValidationResult now, instead of just the Store?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Well... we could change the store in the PurchasesFactory to a new "test store" when the validation result is a test store... However, that would mean changing the Store enum which is public. I preferred to keep the changes internal for now... We might want to add a test store to the Store enum, but I think that should be added later. Lmk if you think otherwise!

Copy link
Member

Choose a reason for hiding this comment

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

Oh yes, keeping Store the same for now makes all the sense. Thanks for the context!

const val TEST_STORE_API_KEY = "Using a Test Store API key.\n" +
"The Test Store is for development only. Never use a Test Store API key in production. " +
"Test Store purchases are simulated, do not use Google Play or Amazon store, and generate no revenue. " +
"Apps submitted with a Test Store API key will be rejected during App Review."
Copy link
Member

Choose a reason for hiding this comment

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

😚👌

Comment on lines 26 to 29
const val TEST_STORE_API_KEY = "Using a Test Store API key.\n" +
"The Test Store is for development only. Never use a Test Store API key in production. " +
"Test Store purchases are simulated, do not use Google Play or Amazon store, and generate no revenue. " +
"Apps submitted with a Test Store API key will be rejected during App Review."
Copy link
Member

Choose a reason for hiding this comment

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

I'd say we should also crash in release builds (can be a separate PR), so maybe we should mention that here too?

Copy link
Member

Choose a reason for hiding this comment

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

Is this possible on Android? I thought about this for iOS, but I don't think it's possible to differentiate between debug vs release builds from the SDK 😞

Copy link
Member

Choose a reason for hiding this comment

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

Sure is 😄 Can be read from AppConfig.isDebugBuild, determined by DefaultIsDebugBuildProvider, implemented in #1873.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, thank you for pointing that! I'm seeing the same in iOS here

    var isDebugBuild: Bool {
#if DEBUG
        return true
#else
        return false
#endif
    }

But I think this doesn't work reliably in iOS. For developers integrating the XCFramework, since we build it for distribution (if I'm not wrong), the binary is created without the DEBUG compiler flag, i.e., the code inside the #else clause is included in the binary. Therefore, even if the developer is testing/debugging (i.e. using the DEBUG compiler flag for their project), the SDK's isDebugBuild will be returning false

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added mention in cc3b961

Copy link

codecov bot commented Jul 17, 2025

Codecov Report

Attention: Patch coverage is 82.05128% with 7 lines in your changes missing coverage. Please review.

Project coverage is 78.26%. Comparing base (e2dd48a) to head (9bd5a0e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
.../kotlin/com/revenuecat/purchases/BillingFactory.kt 69.56% 6 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2542      +/-   ##
==========================================
+ Coverage   78.23%   78.26%   +0.02%     
==========================================
  Files         291      291              
  Lines       10772    10782      +10     
  Branches     1504     1507       +3     
==========================================
+ Hits         8428     8439      +11     
+ Misses       1692     1691       -1     
  Partials      652      652              

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

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copy link
Member

@ajpallares ajpallares left a comment

Choose a reason for hiding this comment

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

Looking great! 💪

@tonidero tonidero enabled auto-merge July 17, 2025 10:41
@tonidero tonidero added this pull request to the merge queue Jul 17, 2025
Merged via the queue into main with commit 9118fcd Jul 17, 2025
14 checks passed
@tonidero tonidero deleted the expose-api-key-validation-result-to-billing-abstract branch July 17, 2025 11:52
This was referenced Jul 17, 2025
github-merge-queue bot pushed a commit that referenced this pull request Jul 17, 2025
**This is an automatic release.**

### 🔄 Other Changes
* [AUTOMATIC][Paywalls V2] Updates paywall-preview-resources submodule
(#2544) via RevenueCat Git Bot (@RCGitBot)
* Expose Virtual Currency Constructors with @InternalRevenueCatAPI
(#2543) via Will Taylor (@fire-at-will)
* Expose API key validation result to BillingFactory (#2542) via Toni
Rico (@tonidero)

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
tonidero added a commit that referenced this pull request Aug 25, 2025
### Description
This is the first of a series of PRs to support a test store in
purchases-android.

In this one, we add support for a new test API key and expose the API
key validation result to the billing factory, so we can in future PRs
create a billing implementation for this test store.
@tonidero tonidero mentioned this pull request Aug 25, 2025
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.

3 participants