SDK error · code 42

testStoreSimulatedPurchaseError (error code 42): Test Store simulated purchase error

What it means

testStoreSimulatedPurchaseError (code 42) is raised on purpose when you tap "Test failed purchase" in the Test Store purchase dialog. It lets you test your failure handling without a real store. It is not a bug and it cannot happen in production. Tap "Test valid purchase" to complete a test purchase instead.

Code

42

iOS (Swift)

ErrorCode.testStoreSimulatedPurchaseError

Android (Kotlin)

PurchasesErrorCode.TestStoreSimulatedPurchaseError

Causes

Why the SDK returns testStoreSimulatedPurchaseError

  • The SDK is configured with a Test Store key (test_), and the Test Store dialog's failure button was tapped (SimulatedStorePurchaseHandler.swift).
  • On Android, the same button is labeled "Test failed purchase", and it sends the error to the purchase callback (SimulatedStoreBillingWrapper.kt).
  • The SDK's description is "Purchase failure simulated successfully in Test Store". That is the success message for this error.

Fix

How to fix testStoreSimulatedPurchaseError

  1. 01

    Use it to test your error UI

    Tap the failure button to check that your app shows a sensible message and leaves the paywall usable.

  2. 02

    Complete a test purchase instead

    Tap "Test valid purchase" to run the success path. The SDK then posts a test_ token to the server.

  3. 03

    Keep Test Store keys out of releases

    Ship store keys (appl_, goog_) in release builds, and use test_ keys only in development builds.

  4. 04

    Handle it like a normal failure

    Your code does not need a special case. Treat it as a failed purchase.

In your app

How to handle it in code

  • Do not retry for the tester. They chose the failure.
  • Show the same failure message you show for real purchase errors, to test it.
  • Do not grant access. No purchase happened.
Match the errorSwift · Kotlin
// Swift
do {
  let result = try await Purchases.shared.purchase(package: package)
} catch let error as ErrorCode where error == .testStoreSimulatedPurchaseError {
  // handle test store simulated purchase error
}

// Kotlin
if (error.code == PurchasesErrorCode.TestStoreSimulatedPurchaseError) { /* ... */ }

On RevenueDot: RevenueDot never sees this error: no receipt is posted for a failed Test Store purchase. A successful Test Store purchase posts a test_<ms>_<id> token to POST /v1/receipts, and the purchase is always stored as sandbox. See Test Store and how to test purchases without real money.

FAQ

testStoreSimulatedPurchaseError: questions people ask

What is the Test Store?

A built-in store for development. Its dialog lets you complete a test purchase or simulate a failure without a store account. RevenueDot supports it with test_ keys.

Can testStoreSimulatedPurchaseError happen in production?

No. It appears only when the SDK uses a Test Store key and you tap the failure button in the dialog.

How do I check for testStoreSimulatedPurchaseError in React Native and Flutter?

In React Native, compare error.code with PURCHASES_ERROR_CODE.TEST_STORE_SIMULATED_PURCHASE_ERROR. In Flutter, convert the PlatformException with PurchasesErrorHelper.getErrorCode(e) and compare the result with PurchasesErrorCode.testStoreSimulatedPurchaseError.

Get started

Keep the RevenueCat SDK. Change the backend.

RevenueDot answers the same SDK calls with the same error codes. Start free on RevenueDot Cloud, free up to $10,000 a month in tracked revenue.

Already have an account? Sign in · Prefer your own servers? Self-host free