Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic> error while purchasePackage() called #300

Closed
5 tasks
abeyshiferaw0 opened this issue Jan 18, 2022 · 13 comments · Fixed by #301
Assignees
Labels
bug Something isn't working status: needs-additional-info Issues that are missing steps from bug template

Comments

@abeyshiferaw0
Copy link

Describe the bug
calling purchasePackage() would throw this error after subscription purchase is complete

_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>

  1. Environment

    1. Output of flutter doctor [✓] Flutter (Channel stable, 2.8.0, on macOS 11.5.2 20G95 darwin-x64, locale en-ET) [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [!] Xcode - develop for iOS and macOS (Xcode 12.5.1) ! Flutter recommends a minimum Xcode version of 13.0.0. Download the latest version or update via the Mac App Store. [✓] Chrome - develop for the web [✓] Android Studio (version 2020.3) [✓] VS Code (version 1.63.2) [✓] Connected device (2 available)
    2. How widespread is the issue. Percentage of devices affected

    I only tested on Android.

  2. Debug logs that reproduce the issue

Issue is not caught by package but error thrown is type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>'

  1. Steps to reproduce, with a description of expected vs. actual behavior
    call purchasePackage method with subscription packages should reproduce the error
    PurchaserInfo purchaserInfo = await Purchases.purchasePackage( offering.availablePackages.first, );

  2. Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

final prorationMode = upgradeInfo?.prorationMode; final response = await _channel.invokeMethod('purchasePackage', { 'packageIdentifier': packageToPurchase.identifier, 'offeringIdentifier': packageToPurchase.offeringIdentifier, 'oldSKU': upgradeInfo?.oldSKU, 'prorationMode': prorationMode?.index }); return PurchaserInfo.fromJson(response['purchaserInfo']);

return PurchaserInfo.fromJson(response['purchaserInfo']); seems to be where the error is happening

Additional context
none

@abeyshiferaw0 abeyshiferaw0 added the bug Something isn't working label Jan 18, 2022
@ghost ghost added the status: needs-additional-info Issues that are missing steps from bug template label Jan 18, 2022
@ghost
Copy link

ghost commented Jan 18, 2022

Hello! It doesn't seem like we have quite enough information to send this to a human yet to help out. We would love if you could provide more details about your issue by following the template without modifying any of the pre-filled text. If you're looking for support, head over to our Community.

@ecorradini
Copy link

I have this problem too.
This is the complete exception log:
Unhandled Exception: type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>' #0 Purchases.purchaseProduct (package:purchases_flutter/purchases_flutter.dart:199:43) <asynchronous suspension>
I get this error each time I make a purchase, in my case a renewable subscription.

@signmotion
Copy link

signmotion commented Jan 18, 2022

Confirm on Android also.

STR

    try {
      final purchaserInfo = await Purchases.purchasePackage(package);
      ...
    } on PlatformException catch (ex) {
      // it's OK
    } catch (ex) {
      // have the error:
      //   type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>'
    }

More tests to the god of tests, guys!

Related to #295

@vegaro
Copy link
Contributor

vegaro commented Jan 18, 2022

Looking into it

@vegaro vegaro self-assigned this Jan 18, 2022
@vegaro
Copy link
Contributor

vegaro commented Jan 18, 2022

Looks like response['purchaserInfo'] is not Map<String, dynamic> anymore and it's a Map<Object?, Object?> now. Trying to figure out why.

@abeyshiferaw0
Copy link
Author

Looks like response['purchaserInfo'] is not Map<String, dynamic> anymore and it's a Map<Object?, Object?> now. Trying to figure out why.

is this happing because of a change in server response to purchasePackage() from revenue cat? it looks like it,

@vegaro
Copy link
Contributor

vegaro commented Jan 18, 2022

No. I just checked and this is not happening in version 3.8.0. I've reverted every commit and I think I isolated it to be caused by #270. But I still don't understand how that PR can cause to change what purchasePackage is returning from the Native side.

@vegaro
Copy link
Contributor

vegaro commented Jan 18, 2022

Also, this is what response looks like:

In the Java code:

Screen Shot 2022-01-18 at 1 16 17 PM

In Dart code:
Screen Shot 2022-01-18 at 1 19 06 PM

Screen Shot 2022-01-18 at 1 20 38 PM

{productIdentifier: com.revenuecat.lifetime, purchaserInfo: {entitlements: {all: {entitlement_5: {identifier: entitlement_5, isActive: true, willRenew: false, periodType: NORMAL, latestPurchaseDateMillis: 1642501009000, latestPurchaseDate: 2022-01-18T10:16:49.000Z, originalPurchaseDateMillis: 1642501009000, originalPurchaseDate: 2022-01-18T10:16:49.000Z, expirationDateMillis: 1642501304000, expirationDate: 2022-01-18T10:21:44.000Z, store: PLAY_STORE, productIdentifier: weekly_intro_pricing_two_billing_periods, isSandbox: true, unsubscribeDetectedAt: 2022-01-18T10:19:03.000Z, unsubscribeDetectedAtMillis: 1642501143000, billingIssueDetectedAt: null, billingIssueDetectedAtMillis: null, ownershipType: UNKNOWN}, pro_cat: {identifier: pro_cat, isActive: true, willRenew: false, periodType: NORMAL, latestPurchaseDateMillis: 1642501196000, latestPurchaseDate: 2022-01-18T10:19:56.000Z, originalPurchaseDateMillis: 1642501196000, originalPurchaseDate: 2022-01-18T10:19:56.000Z, expirationDateMillis: null, expirationDate: null, store: PLAY_STORE, productIdentifier: com.revenuecat.lifetime, isSandbox: true, unsubscribeDetectedAt: null, unsubscribeDetectedAtMillis: null, billingIssueDetectedAt: null, billingIssueDetectedAtMillis: null, ownershipType: UNKNOWN}}, active: {entitlement_5: {identifier: entitlement_5, isActive: true, willRenew: false, periodType: NORMAL, latestPurchaseDateMillis: 1642501009000, latestPurchaseDate: 2022-01-18T10:16:49.000Z, originalPurchaseDateMillis: 1642501009000, originalPurchaseDate: 2022-01-18T10:16:49.000Z, expirationDateMillis: 1642501304000, expirationDate: 2022-01-18T10:21:44.000Z, store: PLAY_STORE, productIdentifier: weekly_intro_pricing_two_billing_periods, isSandbox: true, unsubscribeDetectedAt: 2022-01-18T10:19:03.000Z, unsubscribeDetectedAtMillis: 1642501143000, billingIssueDetectedAt: null, billingIssueDetectedAtMillis: null, ownershipType: UNKNOWN}, pro_cat: {identifier: pro_cat, isActive: true, willRenew: false, periodType: NORMAL, latestPurchaseDateMillis: 1642501196000, latestPurchaseDate: 2022-01-18T10:19:56.000Z, originalPurchaseDateMillis: 1642501196000, originalPurchaseDate: 2022-01-18T10:19:56.000Z, expirationDateMillis: null, expirationDate: null, store: PLAY_STORE, productIdentifier: com.revenuecat.lifetime, isSandbox: true, unsubscribeDetectedAt: null, unsubscribeDetectedAtMillis: null, billingIssueDetectedAt: null, billingIssueDetectedAtMillis: null, ownershipType: UNKNOWN}}}, activeSubscriptions: [weekly_intro_pricing_two_billing_periods], allPurchasedProductIdentifiers: [com.revenuecat.lifetime, weekly_intro_pricing_two_billing_periods], latestExpirationDate: 2022-01-18T10:21:44.000Z, latestExpirationDateMillis: 1642501304000, firstSeen: 2022-01-18T10:16:32.000Z, firstSeenMillis: 1642500992000, originalAppUserId: $RCAnonymousID:8fa520e1e940430a97ddc346600461b8, requestDate: 2022-01-18T10:20:00.000Z, requestDateMillis: 1642501200000, allExpirationDates: {weekly_intro_pricing_two_billing_periods: 2022-01-18T10:21:44.000Z}, allExpirationDatesMillis: {weekly_intro_pricing_two_billing_periods: 1642501304000}, allPurchaseDates: {weekly_intro_pricing_two_billing_periods: 2022-01-18T10:16:49.000Z, com.revenuecat.lifetime: 2022-01-18T10:19:56.000Z}, allPurchaseDatesMillis: {weekly_intro_pricing_two_billing_periods: 1642501009000, com.revenuecat.lifetime: 1642501196000}, originalApplicationVersion: null, managementURL: https://play.google.com/store/account/subscriptions, originalPurchaseDate: null, originalPurchaseDateMillis: null, nonSubscriptionTransactions: [{revenueCatId: a5f37c61ac, productId: com.revenuecat.lifetime, purchaseDateMillis: 1642501196000, purchaseDate: 2022-01-18T10:19:56.000Z}]}}

@vegaro
Copy link
Contributor

vegaro commented Jan 18, 2022

We figured it out. PR incoming soon

@Joldersman
Copy link

Confirm, the same bug.

E/flutter (14125): [ERROR:flutter/lib/ui/ui_dart_state.cc(209)] Unhandled Exception: type '_InternalLinkedHashMap<Object?, Object?>' is not a subtype of type 'Map<String, dynamic>'
E/flutter (14125): #0 Purchases.purchasePackage (package:purchases_flutter/purchases_flutter.dart:223:43)
E/flutter (14125):
E/flutter (14125): #1 PurchaseApi.purchasePackage (package:body_mass_index/payments/purchase_api.dart:30:5)
E/flutter (14125):

@vegaro
Copy link
Contributor

vegaro commented Jan 19, 2022

We just pushed 3.9.2 that fixes the problem. Sorry about the trouble. We are going to be writing more tests to prevent this type of issue from happening again.

@vegaro vegaro pinned this issue Jan 19, 2022
@rgillera
Copy link

I got the same issue :(

@Joldersman
Copy link

I got the same issue :(

Just update
dependencies:
purchases_flutter: ^3.9.2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working status: needs-additional-info Issues that are missing steps from bug template
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants