Flutter Purchases.purchasePackage() Doesn't Return

  • 16 September 2023
  • 2 replies
  • 361 views

Badge +3

Hi,

I’m using purchases_flutter(5.4.0). 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. Android works without any problems. I tried it with sandbox and real icloud accounts, the result is still the same..The problem is only on IOS. It has been working flawlessly for about 40 days, with over 300 subscription purchases made, but for the past 3-4 days, I've been encountering this problem. When I check the RevenueCat dashboard, I can see the purchases, but there is no response from the 'purchasePackage' method in the app. I also tried upgrading the Purchases_flutter library to version 5.6.5 with the same result. You can see that the purchase is successfully made in the logs. I have also looked into other topics experiencing the same error but couldn't find a solution.

Thanks.

//SDK INIT
await Purchases.setLogLevel(LogLevel.verbose);
PurchasesConfiguration configuration;
configuration = PurchasesConfiguration(AppConstants.revenueCatAppleApiKey)
..appUserID = loginUserId
..observerMode = false;
await Purchases.configure(configuration);
await Purchases.logIn(loginUserId);
   CustomerInfo purchaserInfo;
if (Config.isAndroid) {
String? oldProduct;
var entitlements = customerInfo.entitlements.all[entitlementsID];
if (entitlements != null && entitlements.isActive) {
oldProduct = entitlements.productIdentifier;
}

if (oldProduct != null) {
//Android Upgrade & Downgrade
purchaserInfo = await Purchases.purchasePackage(currentItem,
googleProductChangeInfo: GoogleProductChangeInfo(oldProduct));
}
else {
//Android Purchase
purchaserInfo = await Purchases.purchasePackage(currentItem);
}
} else {
//IOS Purchase
purchaserInfo = await Purchases.purchasePackage(currentItem);
}

//*****
if (purchaserInfo.entitlements.all[entitlementsID] != null &&
purchaserInfo.entitlements.all[entitlementsID]!.isActive) {

//...
}

 

[configure] INFO: ℹ️ Purchases instance already set. Did you mean to configure two Purchases objects?
[configure] DEBUG: ℹ️ Configuring SDK using RevenueCat's UserDefaults suite.
[purchases] VERBOSE: DeviceCache.init: DeviceCache (0x0000000283f4f2a0)
[purchases] VERBOSE: StoreKit1Wrapper.init: StoreKit1Wrapper (0x0000000283f4d320)
[identity] DEBUG: 👤 Identifying App User ID
[purchases] VERBOSE: PurchasesOrchestrator.init: PurchasesOrchestrator (0x000000010485f550)
[configure] DEBUG: ℹ️ Debug logging enabled
[configure] DEBUG: ℹ️ SDK Version - 4.25.9
[configure] DEBUG: ℹ️ Bundle ID - com.fzfz.fz
[configure] DEBUG: ℹ️ System Version - Version 15.4.1 (Build 19E258)
[configure] DEBUG: ℹ️ Not using a simulator.
[configure] DEBUG: 👤 Initial App User ID set
[configure] DEBUG: ℹ️ Purchases is configured with response verification disabled
[configure] VERBOSE: Purchases.init: created new Purchases instance: Purchases (0x00000001341d6f90)
StoreKit Wrapper: left(<RevenueCat.StoreKit1Wrapper: 0x283f4d320>)
[configure] VERBOSE: Purchases.deinit: Purchases (0x00000001048e8460)
[purchases] VERBOSE: PurchasesOrchestrator.deinit: PurchasesOrchestrator (0x00000001341583f0)
[purchases] VERBOSE: DeviceCache.deinit: DeviceCache (0x0000000283f33a80)
[purchases] VERBOSE: StoreKit1Wrapper.deinit: StoreKit1Wrapper (0x0000000283f31980)
[configure] DEBUG: ℹ️ Delegate set
[purchases] VERBOSE: Updating all caches
[offering] DEBUG: ℹ️ Offerings cache is stale, updating from network in foreground
[network] VERBOSE: Enqueing network operation 'GetOfferingsOperation' with cache key: 'GetOfferingsOperation 08ead447-276d-49c7-ba55-2f2f56e9602c'
[network] DEBUG: ℹ️ GetOfferingsOperation: Started
[network] DEBUG: ℹ️ There are no requests currently running, starting request GET /v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings
[etags] VERBOSE: Using etag '77b713b0527f3bfe' for request to 'https://api.revenuecat.com/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings'. Validation time: 2023-09-16 16:55:15 +0000
[network] DEBUG: ℹ️ API request started: GET '/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings'
[network] VERBOSE: Enqueing network operation 'GetCustomerInfoOperation' with cache key: 'GetCustomerInfoOperation 08ead447-276d-49c7-ba55-2f2f56e9602c'
[identity] WARN: ⚠️ The appUserID passed to logIn is the same as the one already cached. No action will be taken.
[customer] DEBUG: ℹ️ Vending CustomerInfo from cache.
[network] DEBUG: ℹ️ Network operation 'GetOfferingsOperation' found with the same cache key 'GetOfferingsOperation 08ead447-276d-49c7-ba55-2f2f56e9602c'. Skipping request.
[attribution] DEBUG: ℹ️ setting reserved attribute: $displayName
[etags] VERBOSE: Storing etag '77b713b0527f3bfe' for request to 'https://api.revenuecat.com/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings' (success)
[network] DEBUG: ℹ️ API request completed: GET '/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings' (304)
[store_kit] DEBUG: ℹ️ No existing products cached, starting store products request for: ["com.fz.boosterpack_1month", "com.fz.boosterpack_1year"]
[offering] DEBUG: ℹ️ Found an existing request for products: ["com.fz.boosterpack_1month", "com.fz.boosterpack_1year"], appending to completion
[network] DEBUG: ℹ️ GetOfferingsOperation: Finished
[network] DEBUG: ℹ️ GetCustomerInfoOperation: Started
[network] DEBUG: ℹ️ Serial request done: GET /v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c/offerings, 0 requests left in the queue
[network] DEBUG: ℹ️ There are no requests currently running, starting request GET /v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c
[etags] VERBOSE: Using etag 'ae3d2ff24c65ce6d' for request to 'https://api.revenuecat.com/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c'. Validation time: 2023-09-16 16:55:15 +0000
[network] DEBUG: ℹ️ API request started: GET '/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c'
[store_kit] DEBUG: 😻 Store products request finished
[store_kit] DEBUG: 😻 Store products request received response
[offering] WARN: ⚠️ There's a problem with your configuration. No packages could be found for offering with identifier turkeyleague. This could be due to Products not being configured correctly in the RevenueCat dashboard, App Store Connect (or the StoreKit Configuration file if one is being used).
To configure products, follow the instructions in https://rev.cat/how-to-configure-offerings.
More information: https://rev.cat/why-are-offerings-empty
[offering] WARN: ⚠️ There's a problem with your configuration. No packages could be found for offering with identifier default. This could be due to Products not being configured correctly in the RevenueCat dashboard, App Store Connect (or the StoreKit Configuration file if one is being used).
To configure products, follow the instructions in https://rev.cat/how-to-configure-offerings.
More information: https://rev.cat/why-are-offerings-empty
[offering] DEBUG: 😻 Offerings updated from network.
[offering] WARN: ⚠️ There's a problem with your configuration. No packages could be found for offering with identifier turkeyleague. This could be due to Products not being configured correctly in the RevenueCat dashboard, App Store Connect (or the StoreKit Configuration file if one is being used).
To configure products, follow the instructions in https://rev.cat/how-to-configure-offerings.
More information: https://rev.cat/why-are-offerings-empty
[offering] WARN: ⚠️ There's a problem with your configuration. No packages could be found for offering with identifier default. This could be due to Products not being configured correctly in the RevenueCat dashboard, App Store Connect (or the StoreKit Configuration file if one is being used).
To configure products, follow the instructions in https://rev.cat/how-to-configure-offerings.
More information: https://rev.cat/why-are-offerings-empty
[offering] DEBUG: 😻 Offerings updated from network.
[etags] VERBOSE: Storing etag 'ae3d2ff24c65ce6d' for request to 'https://api.revenuecat.com/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c' (success)
[network] DEBUG: ℹ️ API request completed: GET '/v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c' (304)
[customer] VERBOSE: Updating CustomerInfo '08ead447-276d-49c7-ba55-2f2f56e9602c' request date: 2023-09-16 16:56:31 +0000
[customer] DEBUG: 😻 CustomerInfo updated from network.
[network] DEBUG: ℹ️ GetCustomerInfoOperation: Finished
[network] DEBUG: ℹ️ Serial request done: GET /v1/subscribers/08ead447-276d-49c7-ba55-2f2f56e9602c, 0 requests left in the queue

 

#2

[purchases] DEBUG: ℹ️ StoreKit1Wrapper (0x0000000283f25e60) updatedTransaction: com.fz.boosterpack_1year 2000000415082617 1
[attribution] DEBUG: ℹ️ Found 0 unsynced attributes for App User ID: 08ead447-276d-49c7-ba55-2f2f56e9602c
[purchases] DEBUG: ℹ️ TransactionPoster: handling transaction '2000000415082617' for product 'com.fz.boosterpack_1year' (date: 2023-09-16 16:50:09 +0000) in Offering 'booster'
[receipt] DEBUG: ℹ️ Loaded receipt from url file:///private/var/mobile/Containers/Data/Application/3632F651-6CFC-4835-87A2-6B5A13982D92/StoreKit/sandboxReceipt
[offering] DEBUG: ℹ️ Skipping products request for these products because they were already cached: ["com.fz.boosterpack_1year"]
[network] VERBOSE: Enqueing network operation 'PostReceiptDataOperation' with cache key: 'PostReceiptDataOperation 08ead447-276d-49c7-ba55-2f2f56e9602c-false-13f0c8842e1c6fe4ce8b5aa1c59fcfa989d1d9891765b79ae606953b5b41682b
-com.fz.boosterpack_1year-229.99-TRY-TUR--1-0-21367882-P1Y---1
-booster-false
-["$attConsentStatus": [SubscriberAttribute] key: $attConsentStatus value: restricted setTime: 2023-09-16 16:50:19 +0000]'
[network] DEBUG: ℹ️ PostReceiptDataOperation: Started
[receipt] INFO: ℹ️ Parsing receipt
[receipt] INFO: ℹ️ Receipt parsed successfully
[network] DEBUG: ℹ️ PostReceiptDataOperation: Posting receipt (source: 'purchase') (note: the contents might not be up-to-date, but it will be refreshed with Apple's servers):
{"opaque_value":"wUQaPsSBdGg6Ch9MSnHPNA==","original_application_version":"1.0","bundle_id":"com.fzfz.fz","sha1_hash":"L8C2GQxmsSpPqQVkc4F4Ch4IfTI=","application_version":"232","creation_date":"2023-09-16T16:50:15Z","in_app_purchases":[{"product_id":"com.fz.boosterpack_1year","quantity":1,"transaction_id":"2000000415082617","is_in_trial_period":false,"is_in_intro_offer_period":false,"expires_date":"2023-09-16T17:50:09Z","web_order_line_item_id":2000000037084070,"original_purchase_date":"2023-09-16T16:50:14Z","original_transaction_id":"2000000415082617","product_type":3,"purchase_date":"2023-09-16T16:50:09Z"}]}
[network] DEBUG: ℹ️ There are no requests currently running, starting request POST /v1/receipts
[etags] VERBOSE: Found no etag for request to 'https://api.revenuecat.com/v1/receipts'
[network] DEBUG: ℹ️ API request started: POST '/v1/receipts'
[purchases] DEBUG: ℹ️ StoreKit1Wrapper (0x0000000283f25e60) removedTransaction: com.fz.boosterpack_1year 2000000415082617 1
[purchases] DEBUG: ℹ️ StoreKit1Wrapper (0x0000000283f25e60) removedTransaction for com.fz.boosterpack_1year but no callbacks to notify
[etags] VERBOSE: Storing etag '4c6a9148d46bda6b' for request to 'https://api.revenuecat.com/v1/receipts' (success)
[network] DEBUG: ℹ️ API request completed: POST '/v1/receipts' (200)
[customer] VERBOSE: Updating CustomerInfo '08ead447-276d-49c7-ba55-2f2f56e9602c' request date: 2023-09-16 16:50:20 +0000
[network] DEBUG: ℹ️ PostReceiptDataOperation: Finished
[network] DEBUG: ℹ️ Serial request done: POST /v1/receipts, 0 requests left in the queue
[purchases] INFO: 💰 Finishing transaction '2000000415082617' for product 'com.fz.boosterpack_1year'

 


2 replies

Badge +3

I'm sorry, this was my mistake. When the purchase window was opened, the setState method was triggered in the background. Inside setState, I had my CupertinoAlertDialog Loading widget, which was causing this locking issue.

Userlevel 4
Badge +6

Hey @fntz-a527a9 !

 

Glad to hear that this is now working properly, Always feel free to reach out with any questions in the future! 

Reply