Question

Purchases.purchasePackage() doesn't return


Userlevel 1
Badge +5

Hello,

I’m using purchases-flutter 4.1.2 (latest at the moment). I’ve set up the entitlements, offerings, products as well as packages as guided in https://docs.revenuecat.com/docs/ios-products

I can get the offerrings and display the packages correctly.

But when I make a call to `Purchases.purchasePackage()` to purchase a package, the call just hangs and doesn’t return at all.

Here’s my dependency list:

```

environment:
  sdk: ">=2.17.5 <3.0.0"

dependencies:
  another_flushbar: ^1.10.23
  awesome_notifications: ^0.6.21
  bloc: ^8.0.2
  cached_network_image: ^3.1.0
  cloud_firestore: ^3.4.4
  easy_localization: ^3.0.0
  easy_localization_loader: ^1.0.0
  equatable: ^2.0.3
  firebase_analytics: ^9.3.1
  firebase_auth: ^3.6.3
  firebase_core: ^1.20.1
  firebase_messaging: ^12.0.2
  flow_builder: ^0.0.2
  flutter:
    sdk: flutter
  flutter_bloc: ^8.0.1
  flutter_onboard: ^2.0.0
  flutter_platform_widgets: ^2.0.0
  flutter_svg: ^1.0.0
  flutter_typeahead: ^4.0.0
  formz: ^0.4.0
  google_fonts: ^3.0.1
  grouped_list: ^5.1.2
  hydrated_bloc: ^9.0.0-dev
  lint: ^1.0.0
  meta: ^1.7.0
  path_provider: ^2.0.2
  pattern_formatter: ^2.0.0
  provider: ^6.0.1
  rxdart: ^0.27.4
  scrollable_positioned_list: ^0.3.2
  shared_preferences: ^2.0.6
  synchronized: ^3.0.0
  toggle_switch: ^2.0.1
  crypto: ^3.0.2
  flutter_keyboard_visibility: ^5.3.0
  uuid: ^3.0.4
  intl: ^0.17.0
  characters: ^1.2.0
  sentry_flutter: ^6.1.2
  sign_in_with_apple: ^4.0.0
  flutter_slidable: ^1.1.0
  internet_connection_checker: ^0.0.1+3
  device_info_plus: ^4.0.0
  package_info_plus: ^1.3.0
  timeago: ^3.2.1
  local_auth: ^2.1.0
  secure_application: ^3.8.0
  purchases_flutter: ^4.1.2
  modal_progress_hud_nsn: ^0.3.0

dev_dependencies:
  bloc_test: ^9.0.2
  flutter_launcher_icons: "^0.9.2"
  flutter_lints: ^2.0.0
  flutter_test:
    sdk: flutter
  logger: null
  mocktail: ^0.3.0
```

 

And this is the debug log when I try to load the screen and trigger the purchasePackage function:

```

2022-08-22 19:49:37.665783+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Vending Offerings from cache

2022-08-22 19:49:37.669501+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679191+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679445+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679716+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.679962+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680299+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680496+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.680679+0700 Runner[8559:16612850] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

2022-08-22 19:49:37.682355+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground

2022-08-22 19:49:37.682468+0700 Runner[8559:16612850] [Purchases] - DEBUG: 😻 Offerings updated from network.

2022-08-22 19:49:37.683176+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Started

2022-08-22 19:49:37.683405+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ There are no requests currently running, starting request GET subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings

2022-08-22 19:49:37.685568+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ API request started: GET /v1/subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings

2022-08-22 19:49:38.627514+0700 Runner[8559:16776577] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics

2022-08-22 19:49:38.906210+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ API request completed: GET /v1/subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings 304

2022-08-22 19:49:38.908744+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ GetOfferingsOperation: Finished

2022-08-22 19:49:38.908827+0700 Runner[8559:16776577] [Purchases] - DEBUG: ℹ️ Skipping products request because products were already cached. products: ["myapp_45000_1m_1w0", "myapp_499000_1y_2w0"]

2022-08-22 19:49:38.909315+0700 Runner[8559:16770060] [Purchases] - DEBUG: ℹ️ Serial request done: GET subscribers/4R9IChuPBJMxLDVbIZfip7J5AV12/offerings, 0 requests left in the queue

2022-08-22 19:49:40.950981+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ Vending Offerings from cache

2022-08-22 19:49:40.951716+0700 Runner[8559:16612850] [Purchases] - INFO: 💰 Purchasing Product 'myapp_45000_1m_1w0' from package in Offering 'default'

2022-08-22 19:49:40.954935+0700 Runner[8559:16612850] [Purchases] - DEBUG: ℹ️ PaymentQueue updatedTransaction: myapp_45000_1m_1w0 0

2022-08-22 19:49:40.955110+0700 Runner[8559:16612850] [Purchases] - WARN: 🍎‼️ There is a problem with the SKPaymentTransaction missing a transaction date - this is an issue with the App Store. Unix Epoch will be used instead.

Transactions in the backend and in webhooks are unaffected and will have the correct timestamps. This is a bug in StoreKit 1. To prevent running into this issue on devices running iOS 15+, watchOS 8+, macOS 12+, and tvOS 15+, you can set `usesStoreKit2IfAvailable` to true when calling `configure`.

2022-08-22 19:49:40.955829+0700 Runner[8559:16612850] [Purchases] - WARN: 🍎‼️ There is a problem with the SKPaymentTransaction missing a transaction identifier - this is an issue with the App Store.Transactions in the backend and in webhooks are unaffected and will have the correct identifier. This is a bug in StoreKit 1. To prevent running into this issue on devices running iOS 15+, watchOS 8+, macOS 12+, and tvOS 15+, you can set `usesStoreKit2IfAvailable` to true when calling `configure`.

objc[8559]: Class _PathPoint is implemented in both /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x12e16ebb8) and /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x14c305210). One of the two will be used. Which one is undefined.

objc[8559]: Class _PointQueue is implemented in both /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/UIKitCore.framework/UIKitCore (0x12e16eb90) and /Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 15.2.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/TextInputUI.framework/TextInputUI (0x14c305238). One of the two will be used. Which one is undefined.

2022-08-22 19:51:30.917345+0700 Runner[8559:16778768] [boringssl] boringssl_metrics_log_metric_block_invoke(151) Failed to log metrics

```


32 replies

Userlevel 1
Badge +3

Any update on this? I’m getting this error with the latest SDK with React Native

Badge +3

I’m also getting “

WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.”

 

 

Warning repeatedly in the console on one of my projects, I’m using 5.16

Badge +3

Yes same warnings with React Native on Xcode debug log, building in release mode.

using react-native-purchases : 5.14.0 (updating from 4.4.1 who has no warning)

 

2023-05-05 11:20:45.154377+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154609+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154706+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154791+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154908+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155013+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155075+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155140+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

Badge +1

Yes same warnings with React Native on Xcode debug log, building in release mode.

using react-native-purchases : 5.14.0 (updating from 4.4.1 who has no warning)

 

2023-05-05 11:20:45.154377+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154609+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154706+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154791+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.154908+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155013+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155075+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
2023-05-05 11:20:45.155140+0200 Cookomix[1507:635477] [Purchases] - WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

I too am getting this on my flutter project

Badge +1

I used purchases_flutter: 5.2.3 and the same issue

[store_kit] WARN: ⚠️ This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

People, let's improve our contact with the tool here. Haven't solved this problem yet?

Badge +1

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
Still saw on purchases_flutter: 5.4.0

Purchases.purchasePackage() call doesn’t return for me either.

I use the capacitor plugin version 7.0.0.

I tried to place a breakpoint on the API methods. All of these work fine: setLogLevel, configure, getCustomerInfo.

But purchasePackage doesn’t get executed at all. It seems the problem is somewhere in the capacitor plugin.

Badge +1

 

Hi Cesar, I haven’t tested on simulator as you said (using storekit config file) yet. Other than that the function does return on real iphones after setting Appstore shared secret.

 

Hi @Thanh, when you tried this on physical device, are you using sandbox tester account or the real apple account ?

Userlevel 1
Badge +5

Hi @Cesar do you need more information to reproduce this?

Userlevel 1
Badge +5

Hi @Chaitanya 

I tested with a sandbox account. 
Also tried with a real apple account and it was good.

Userlevel 3
Badge +3

Hi @Thanh !

We are trying to reproduce the issue. As @Andy suggested in the GitHub issue, we're currently preparing release 4.2.0, which will get rid of the warnings you see on the console and might also fix the issues, since it uses StoreKit 2 APIs under the hood, and they seem to be more reliable.

Are you also handling errors? Do you see any PlaformException at all?

 

Userlevel 1
Badge +5

My mistake, I didn’t add the Appstore shared secret to Revenuecat. After I did, the function doesn’t hang on my real iPhone, but it still hangs on the iOS simulator.

Userlevel 1
Badge +5

@Cesar Thank you for the update. I’m eager to try out the new release ^^

Are you also handling errors? Do you see any PlaformException at all?

 

Yes I have try & catch block to handle the exception but there’s no exception thrown at all because the function purchasePackage doesn’t return.

Here’s my code:

                              try {
final CustomerInfo customerInfo = await Purchases.purchasePackage(packages![selectedPackageIndex!]);
final isPremium = customerInfo.entitlements.all[REVENUE_CAT_DEFAULT_ENTITLEMENT]?.isActive ?? false;
if (isPremium) {
// Display flashbar and go back
}
} on PlatformException catch (e) {
final errorCode = PurchasesErrorHelper.getErrorCode(e);
if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
print(e);
}
await showDialog(
context: context,
builder: (context) => AlertDialog(
title: const Text("Error"),
content: SingleChildScrollView(
child: ListBody(
children: [
Text(e.message.toString()),
],
),
),
actions: <Widget>[
TextButton(
child: const Text('Ok'),
onPressed: () {
Navigator.of(context).pop();
},
),
],
),
);
}
setState(() {
isLoading = false;
});
}

 

Userlevel 3
Badge +3

but it still hangs on the iOS simulator.

 

That’s probably because iOS simulators require a special configuration using StoreKit config files. You can read more about that in this article in our docs https://docs.revenuecat.com/docs/apple-app-store#ios-14-only-testing-on-the-simulator

Do you mind giving that a try and report back?

The fact that purchasePackage doesn’t return is indeed a weird one, because I would expect it would throw an error indicating there’s a problem with your configuration in RevenueCat. We’ll look into that

Badge +4

Purchases.purchasePackage() call doesn’t return for me either.

I use the capacitor plugin version 7.0.0.

I tried to place a breakpoint on the API methods. All of these work fine: setLogLevel, configure, getCustomerInfo.

But purchasePackage doesn’t get executed at all. It seems the problem is somewhere in the capacitor plugin.

Figured out it was reactivity issue in Vue.js, I thought that .toRaw() is reactive object method, but it is vue utility that you need to use on object.

Badge +3

Hi there,

 

I’m using the react native package with Expo and I’ve got the same issue. It appears on Android / iPhone.

If I cancel the payment then the catch function is triggered and I can handle the situation.

 

But if the payment processes, I’ve got the tick from the Apple / Android payment popup. Subscription is created in revenuecat but the function never returns anything.

I’ve a “console.log(“Payment ok”); right after but it’s never executed. Neither any other code.

 

I’ve even tried on a new project with no other library installed, only revenuecat and the issue is here too.

@Cesar  do you have any idea?

 

Thanks!

 

Regards,
Alex

Badge +2

I get the same warning:

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.
 

purchases_flutter: 5.4.0

Badge +2

@Cesar could you please support us here?

Badge +2

In my case this issue appears only on iOS. On Android everything seems to work fine. Now on iOS, I have two subscriptions. An annual and a monthly. The annual one, works fine. But when a user chooses the monthly, I’m getting the following warning:

This StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

 

Userlevel 3
Badge +3

Does your `purchasePackage` function also not return? Is anything not working?

Those warnings are just indicating that the product’s productType will be `nonConsumable` because it can’t be determined and that should be accessing `productCategory` instead, so they should be safe to ignore. I think we will probably update that log since it’s clear it’s too noisy.

Badge +2

Hello,

 

I am using purchases_flutter: ^5.5.0.

Testing on iOS real device + Sandbox account. The function doesn't return in my case as well.

Everything seems to work smoothly, the log goes up to "PostReceiptDataOperation: Finished". But I can't seem to get the return value of ```await Purchases.purchasePackage(package);```

 

I checked the config so all keys are correctly set in RevenueCat.

 

Do you guys have any information about that ?

Userlevel 3
Badge +3

@Thanh Did you figure this out? We couldn’t reproduce purchasePackage not returning. We have identified an issue with purchaseProduct, but that seems unrelated

Userlevel 1
Badge +5

Hi Cesar, I haven’t tested on simulator as you said (using storekit config file) yet. Other than that the function does return on real iphones after setting Appstore shared secret.

 

 

I’m using flutter and had the following code:

await Purchases.setup("blahblahblah",    appUserId: LoginUser.userUid);

which was showing as deprecated.

So I updated to the new format found on the revenuecat website:

 await Purchases.configure(     PurchasesConfiguration("blahblahblah")       ..appUserID = LoginUser.userUid

and got the above error. 

Reverted back to the deprecated code and its working ok.



the deprated setup trick not solving this issue for the latest plugin purchases_flutter: ^5.6.5

still get error logs

StoreProduct represents an SK1 product, the type of product cannot be determined, the value will be undefined. Use `StoreProduct.productCategory` instead.

but deprecated usesStoreKit2IfAvailable setter did resolve the issue.

 

final PurchasesConfiguration purchasesConfiguration = PurchasesConfiguration("apikey");
purchasesConfiguration.usesStoreKit2IfAvailable = true;

 

Reply