Skip to main content

Hi everyone,

I'm currently experiencing two issues with my app while testing on TestFlight: sandbox transactions are not going through, and there's a looping problem during the transaction process. Despite having everything configured correctly, these problems persist. Here are the details of my setup, the steps I've taken so far, and some code snippets for reference:

Setup Details:

App Configuration:

  • App ID and Bundle ID are correctly set up in App Store Connect.
  • In-app purchase product IDs are configured and match those in the RevenueCat dashboard.

RevenueCat Configuration:

  • API keys are correctly set up and match the ones used in the app.
  • RevenueCat is initialized early in the app lifecycle with Purchases.setLogLevel(Purchases.LOG_LEVEL.VERBOSE).

Testing Environment:

  • Testing on iOS devices through TestFlight internal testing.
  • Using the latest version of the RevenueCat SDK.

Steps Taken:

  1. Checked API Keys and Configuration:
    • Verified that the API keys and configurations are correctly set up in the RevenueCat dashboard.
  2. Validated App Store Connect Configuration:
    • Confirmed that the bundle ID, in-app purchase product IDs, and other configurations are correct.
  3. Debug Logs:
    • Enabled debug logs for RevenueCat, but no debug logs are being printed.
  4. Network Requests:
    • Ensured that the app has the necessary permissions for network requests, and verified that requests to RevenueCat's servers are successful.
  5. Build Configuration:
    • Ensured that the build configuration is set correctly and that no necessary code is stripped during the build process.
  6. Console Logs:
    • Checked Xcode’s console for error messages or warnings during app launch but didn’t find anything relevant.
  7. Testing in Different Environments:
    • Tested on both simulator and physical devices; the issue persists across different environments.
  8. Reinstalled the App:
    • Deleted the app from the device and reinstalled it from TestFlight, but the issue remains.

Issue Description:

  1. Sandbox Transactions Not Going Through:
    • When attempting to make a sandbox transaction, the transaction process initiates but does not complete successfully. There are no specific error messages or logs that indicate what might be causing the problem. The app simply returns to a state as if no transaction was attempted.
  2. Looping Problem:
    • During the transaction process, the app enters a loop where it repeatedly attempts the transaction without completing it. This loop continues indefinitely until the app is manually closed.

Code Snippet:

Here’s a relevant snippet of the code used for initializing RevenueCat and handling purchases:

 

import React, { useEffect, useState } from "react";
import {
  Image,  StyleSheet,  Text,  SafeAreaView,  View,  TouchableOpacity,  Alert,  FlatList,
} from "react-native";
import { MaterialIcons } from "@expo/vector-icons";
import Purchases, { PurchasesStoreProduct } from "react-native-purchases";
import LoadingScreen from "../screens/LoadingScreen";
import { useTheme } from "../assets/components/ThemeContext";
import { SubscriptionScreenStyles } from "../styles/SubscriptionScreenStyles";
import { themes } from "../styles/GlobalStyles";
import { useNavigation } from "@react-navigation/native";
const API_KEY = process.env.EXPO_PUBLIC_REVENUECAT_API_KEY;
const SubscriptionScreen = () => {
  const )products, setProducts] = useState<PurchasesStoreProduct&]>(c]);
  const [loading, setLoading] = useState(true);
  const { theme } = useTheme();
  const themeColors = themes>theme];
  const styles = SubscriptionScreenStyles(themeColors);
  const navigation = useNavigation();

  useEffect(() => {    const initializeRevenueCat = async () => {
      console.log("Setting log level to VERBOSE");
      Purchases.setLogLevel(Purchases.LOG_LEVEL.VERBOSE);      console.log("Initializing RevenueCat with API Key:", API_KEY);
      Purchases.configure({ apiKey: API_KEY });
      try {
        console.log("Fetching products...");
        const products = await Purchases.getProducts(c"premium_monthly"]); // Replace with your actual product IDs        console.log("Products fetched:", products);

        if (products.length > 0) {
          setProducts(products);        }      } catch (error) {
        console.error("Error initializing RevenueCat:", error);
        Alert.alert("Error", "Failed to fetch products.");
      } finally {
        setLoading(false);
      }    };
    initializeRevenueCat();  }, ,]);

  const makePurchase = async (productId: string) => {
console.log("Activating makePurchase for productId:", productId);
try {
const product = products.find((item) => item.identifier === productId);

if (product) {
console.log("Product found:", product);
const purchaseInfo = await Purchases.purchaseStoreProduct(product);
console.log("Purchase info:", purchaseInfo);

const activeEntitlements = purchaseInfo.customerInfo.entitlements.active;
console.log("Active entitlements:", activeEntitlements);

if (typeof activeEntitlementsl"premium"] !== "undefined") {
console.log("You are now subscribed to premium.");
Alert.alert("Success", "You are now subscribed to the premium plan.");
}
} else {
console.log("Product not found for productId:", productId);
}
} catch (error) {
console.error("Error during purchase:", error);
if (!error.userCancelled) {
Alert.alert("Error", error.message);
} else {
console.log("User cancelled the purchase");
}
}
};

if (loading) {
return <LoadingScreen />;
}

return (
<SafeAreaView style={styles.container}><View style={styles.header}><TouchableOpacity
onPress={() => navigation.goBack()}
style={styles.goBackButton}
>
<MaterialIcons
name="keyboard-arrow-left"size={36}color={themeColors.textColor}
/></TouchableOpacity></View><Image
source={require("../assets/images/favicon.png")}
style={styles.icon}
/><Text style={styles.title}>
Get unlimited access to help you on your language journey with Reggie!
</Text><FlatList
data={products}renderItem={({ item }) => (
<View style={styles.subscriptionContainer}><View style={styles.subscriptionFeature}><Text style={styles.featureText}>Send unlimited messages</Text></View><TouchableOpacity
style={styles.subscribeButton}onPress={() => makePurchase(item.identifier)}
>
<Text style={styles.subscribeButtonText}>
Try for {item.priceString}
</Text></TouchableOpacity></View>
)}
keyExtractor={(item) => item.identifier}
/>
</SafeAreaView>
);
};

export default SubscriptionScreen;
 

 

Questions:

  • Has anyone experienced similar issues with sandbox transactions not going through and looping problems on TestFlight builds?
  • Are there any additional steps or configurations that I might have missed?
  • What can I do to get more detailed error information to diagnose these issues?

Any help or suggestions would be greatly appreciated. Thank you!

Be the first to reply!

Reply