react-native-iap icon indicating copy to clipboard operation
react-native-iap copied to clipboard

TestFlight not working with In-app purchases

Open G2Patrik opened this issue 1 year ago • 3 comments

Environment react-native-iap: 12.12.2 react-native: 0.72.12 Platforms (physical & simulator): iPhone 11 - OS version 17.4 /// iOS Simulator iPhone 15 Pro Max - OS version 17.4

Description Hello, I am trying to test the purchase of a subscription and an in-app purchase within my react native app. I have setup the necessary Sandbox account in App Store Connect, created a Store kit file in Xcode that I also synced with the products I created in the App Store Connect dashboard.

If I use Xcode to run the app on a physical device (after logging into the sandbox account), I am able to purchase a subscription/in-app product without any issues. If I purchased a subscription on the physical phone I can go into Settings > App Store > Sandbox Account Management and see the purchased subscription, change renewal rate, clear purchase history etc..

If I use the TestFlight build with a physical phone (logging in with the sandbox account) the in app purchases stop working correctly. After purchasing a subscription it is not shown in the Sandbox Account Management, so I am unable to cancel it. Upon trying to purchase another subscription the apple service keeps returning the same exact subscription that I "originally" purchased. How am I supposed to cancel that subscription if it not shown in the sandbox account subscription list? Adding a different sandbox account does not help either, trying to purchase another subscription returns the same subscription that I am unable to cancel. Is there a step in the TestFlight environment that I am missing on setup?

Expected Behavior Upon purchasing a subscription in the TestFlight environment on a physical device I should be able to cancel that subscription.

const product = { productId: 'example_monthly_subscription' };
subscribe(product.productId);

Any help would be appreciated.

G2Patrik avatar Jun 12 '24 16:06 G2Patrik

I have the same problem

Kavosh-m avatar Jun 13 '24 10:06 Kavosh-m

Debugging this issue is a bit challenging for me at the moment. However, I asked ChatGPT for assistance, and this is the response I received. Could this be helpful?

Response from ChatGPT:

The issue you're experiencing with in-app purchases in the TestFlight environment is likely due to some specific behaviors and limitations associated with TestFlight and Sandbox environments. Here are some steps and checks you can perform to troubleshoot and potentially resolve the issue:

  1. Ensure Correct Sandbox Account Usage:

    • Double-check that you are logged into the correct Sandbox account on your physical device when using the TestFlight build.
    • Go to Settings > App Store > Sandbox Account Management to verify the account details.
  2. Reset Sandbox Account Data:

    • Sometimes, Sandbox account data can become corrupted. To reset it:
      1. Log out of the Sandbox account on the device.
      2. Restart the device.
      3. Log back into the Sandbox account and try the purchase again.
  3. Check App Store Connect Configurations:

    • Ensure that your in-app purchase products are correctly configured and approved in App Store Connect.
    • Verify that the StoreKit configuration file in Xcode matches the product IDs configured in App Store Connect.
  4. Review Subscription Handling Code:

    • Ensure your subscription handling logic is correctly implemented in the app. Pay attention to how you handle the purchase response and the state of the subscription.
  5. Clear TestFlight Cache:

    • Sometimes TestFlight builds can cache old data. Reinstalling the app from TestFlight can help:
      1. Delete the app from the device.
      2. Reinstall the app from TestFlight.
      3. Log into the Sandbox account and attempt the purchase again.
  6. Check for Known Issues:

Additional Debugging Steps:

  1. Review Apple Documentation:

  2. Apple Developer Forums:

    • Consider posting your issue on the Apple Developer Forums for additional insights and potential solutions from the developer community.

By following these steps, you should be able to identify and resolve the issue with in-app purchases not working correctly in the TestFlight environment. If the issue persists, providing detailed logs and steps you've taken when reaching out for support will be helpful.

hyochan avatar Jun 15 '24 05:06 hyochan

I had the same issue while debugging, and this was a solution:

  1. Log out of the sandbox user in settings.
  2. Download the app using TestFlight.
  3. Log out of the Apple ID logged in through the App Store (this is the most crucial step).
  4. Open the app and proceed to make an in-app purchase; at this point, the app will prompt you to log in. Use your sandbox user account to log in.

reference: https://developer.apple.com/forums/thread/691853?login=true

somangoi avatar Jul 22 '24 02:07 somangoi

I’m closing all issues reported in versions below 14, as the library now supports the new architecture with NitroModules and has been completely revamped.

hyochan avatar Sep 30 '25 18:09 hyochan