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

Purchase doesn't work properly with Amazon's Live App Testing #1049

Closed
11 tasks done
enoiu opened this issue Apr 20, 2024 · 8 comments · Fixed by #1053
Closed
11 tasks done

Purchase doesn't work properly with Amazon's Live App Testing #1049

enoiu opened this issue Apr 20, 2024 · 8 comments · Fixed by #1053
Labels
bug Something isn't working

Comments

@enoiu
Copy link

enoiu commented Apr 20, 2024

Environment

  • Output of flutter doctor
[√] Flutter (Channel stable, 3.19.5, on Microsoft
    Windows [Version 10.0.22631.3447], locale ja-JP)    
[√] Windows Version (Installed version of Windows is    
    version 10 or higher)
[√] Android toolchain - develop for Android devices
    (Android SDK version 34.0.0)
[√] Chrome - develop for the web
[√] Visual Studio - develop Windows apps (Visual Studio 
    Community 2022 17.8.3)
[√] Android Studio (version 2022.3)
[√] VS Code (version 1.88.1)
[√] Connected device (3 available)
[√] Network resources

• No issues found!
  • Version of purchases-flutter
  purchases_flutter: ^6.26.0
  purchases_ui_flutter: ^6.26.0
  • Testing device version e.g.: iOS 15.5, Android API 30, etc.
    Fire OS 8.3.2.3
  • How often the issue occurs- every one of your customers is impacted? Only in dev?
    in Amazon's Live App Testing
  • Debug logs that reproduce the issue
  • Steps to reproduce, with a description of expected vs. actual behavior
    Other information (e.g. stacktraces, related issues, suggestions how to fix, links for us to have context, eg. stackoverflow, etc.)

Describe the bug

I implemented in-app purchases using PaywallFooterView and tested purchases with Amazon's Live App Testing.
Then, even though the Amazon Appstore UI shows that the purchase is complete, PaywallFooterView's onPurchaseCompleted does not seem to be triggered.

When checking with Logcat, the following error occurred.
(This error was displayed after the log RevenueCatUI D Dismissing paywall after purchase.)

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
#0      _$$StoreTransactionImplFromJson (package:purchases_flutter/models/store_transaction.g.dart:11)
#1      new _$StoreTransactionImpl.fromJson (package:purchases_flutter/models/store_transaction.freezed.dart:215)
#2      _$StoreTransactionFromJson (package:purchases_flutter/models/store_transaction.freezed.dart:18)
#3      new StoreTransaction.fromJson (package:purchases_flutter/models/store_transaction.dart:51)
#4      PaywallViewMethodHandler._handleOnPurchaseCompleted (package:purchases_ui_flutter/views/paywall_view_method_handler.dart:62)
#5      PaywallViewMethodHandler.handleMethodCall (package:purchases_ui_flutter/views/paywall_view_method_handler.dart:32)
#6      InternalPaywallFooterView._buildListenerChannel.<anonymous closure> (package:purchases_ui_flutter/views/internal_paywall_footer_view.dart:99)
#7      MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:571)
#8      MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:564)
#9      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:603)
#10     _invoke2 (dart:ui/hooks.dart:344)
#11     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45)
#12     _Channel.push (dart:ui/channel_buffers.dart:135)
#13     ChannelBuffers.push (dart:ui/channel_buffers.dart:343)
#14     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:737)
#15     _dispatchPlatformMessage (dart:ui/hooks.dart:257)

However, afterwards restoring purchases (onRestoreCompleted) worked fine.

I tried resetting the in-app items from the Amazon Developer page multiple times, but the result did not change.

Additional context

I don't know if it is directly related to this issue, but another app that was published on the Amazon Appstore was suspended due to in-app purchases not working properly.
The reason for the suspension was "Even after purchasing IAP, it does not reflect in the app as app asks for purchase again for using other pro features but displays message as IAP is already purchased."
This app used purchases_flutter: ^6.5.1 and did not use purchases_ui_flutter.
I then submitted an update for the app with purchases_flutter: ^6.24.0, but it was rejected because "Observed that IAP Item is not delivered as expected to the user post purchase."
However, in the case of this app, Purchase worked fine on my actual device (Fire 7 2022, FireOS 8.3.2.2).
Furthermore, perhaps because the app has been suspended, I can no longer install this app that I submitted to the live app test after uninstalling it, so I am currently unable to test this app on my device.
Therefore, I decided to try using purchases_ui_flutter with another app, and the issue I reported this time was confirmed.

@enoiu enoiu added the bug Something isn't working label Apr 20, 2024
@RCGitBot
Copy link
Contributor

👀 We've just linked this issue to our internal tracker and notified the team. Thank you for reporting, we're checking this out!

@mshmoustafa
Copy link
Contributor

Hi @enoiu,
Can you share the entire debug logs that reproduce this?

@enoiu
Copy link
Author

enoiu commented Apr 25, 2024

Thank you for your response.

debug logs (containing "purchase".)
2024-04-19 18:59:06.678 10920-11094 [Purchases] - DEBUG     com.enoiu.codes                      D  Getting storefront from cache was null.
2024-04-19 18:59:07.555 10920-11094 [Purchases] - DEBUG     com.enoiu.codes                      D  API request started: POST /events
2024-04-19 18:59:07.556 10920-11094 [Purchases] - DEBUG     com.enoiu.codes                      D  API request completed with status: POST /events 304
2024-04-19 18:59:08.525 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Vending Offerings from cache
2024-04-19 18:59:08.525 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Checking if cache is stale AppInBackground false
2024-04-19 18:59:08.526 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  Retrieving customer info with policy: CACHED_OR_FETCHED
2024-04-19 18:59:08.527 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Vending CustomerInfo from cache.
2024-04-19 18:59:08.527 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Checking if cache is stale AppInBackground false
2024-04-19 18:59:10.040 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  💰 Purchase started - product:  Product(storeProduct=AmazonStoreProduct(id=com.enoiu.codes.noads, type=INAPP, name=プロ版へアップグレード, title=プロ版へアップグレード, description=すべての機能(広告非表示、ブックマーク、文字の大きさ変更など)を利用できるようになります。, period=null, price=Price(formatted=¥500, amountMicros=500000000, currencyCode=JPY), subscriptionOptions=null, defaultOption=null, iconUrl=https://m.media-amazon.com/images/I/31ZhRIWFKnL._SL110_FMPNG_h1_.png, freeTrialPeriod=null, originalProductJSON={"sku":"com.enoiu.codes.noads","productType":"ENTITLED","description":"すべての機能(広告非表示、ブックマーク、文字の大きさ変更など)を利用できるようになります。","price":"¥500","smallIconUrl":"https:\/\/m.media-amazon.com\/images\/I\/31ZhRIWFKnL._SL110_FMPNG_h1_.png","title":"プロ版へアップグレード","coinsRewardAmount":0}, presentedOfferingContext=PresentedOfferingContext(offeringIdentifier=default, placementIdentifier=null, targetingContext=null)))  - offering: default
2024-04-19 18:59:10.041 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  💰 Purchasing product: com.enoiu.codes.noads
2024-04-19 18:59:10.043   674-5946  ActivityTaskManager     system_server                        I  START u0 {cmp=com.enoiu.codes/com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity (has extras)} from uid 10208
2024-04-19 18:59:10.188  2487-2487  SPCH-ADW_T...owContract amazon.speech.sim                    I  onActivityResume() com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:10.198 10920-10920 FIAM.Display            com.enoiu.codes                      I  Binding to activity: com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:10.270   674-1242  Eve                     system_server                        W  Skipping warm_app_cool_transition_launch_time metric for:com.enoiu.codes/com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity already emitted
2024-04-19 18:59:10.271   674-724   ActivityTaskManager     system_server                        I  Displayed com.enoiu.codes/com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity: +225ms
2024-04-19 18:59:10.621  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromStartToFinishPurchaseItemCommandInitiated
2024-04-19 18:59:10.676  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseItemCommandInitiated
2024-04-19 18:59:10.976  9331-9803  AmazonApps...ItemAction com.amazon.venezia                   I  Initiating purchase request for requestId: 4ae4edec-80c2-4388-b883-42f8b46c830b
2024-04-19 18:59:10.977  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseItemCommandSuccess
2024-04-19 18:59:10.993   674-4960  ActivityTaskManager     system_server                        I  START u0 {cmp=com.amazon.venezia/com.amazon.mas.client.iap.purchase.PurchaseActivity (has extras)} from uid 10208
2024-04-19 18:59:11.017 10920-10920 FIAM.Display            com.enoiu.codes                      I  Unbinding from activity: com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:11.052  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromStartToFinishPurchaseItemCommandCompleted
2024-04-19 18:59:11.073  2487-2487  SPCH-ADW_T...owContract amazon.speech.sim                    I  onActivityResume() com.amazon.mas.client.iap.purchase.PurchaseActivity
2024-04-19 18:59:11.111  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseItemCommandToDetailDialogInitiated
2024-04-19 18:59:11.164  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseNonConsumableInitiated
2024-04-19 18:59:11.307   674-724   ArtManagerInternalImpl  system_server                        D  /data/misc/iorapd/com.amazon.venezia/2001790210/com.amazon.mas.client.iap.purchase.PurchaseActivity/compiled_traces/compiled_trace.pb doesn't exist
2024-04-19 18:59:11.313   674-724   ActivityTaskManager     system_server                        I  Displayed com.amazon.venezia/com.amazon.mas.client.iap.purchase.PurchaseActivity: +281ms
2024-04-19 18:59:11.510  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseItemCommandToNonConsumableDetailDialogCompleted
2024-04-19 18:59:13.067   674-10319 ActivityTaskManager     system_server                        I  START u0 {cmp=com.amazon.venezia/.iap.PurchaseChallengeActivity (has extras)} from uid 10140
2024-04-19 18:59:13.123  2487-2487  SPCH-ADW_T...owContract amazon.speech.sim                    I  onActivityResume() com.amazon.venezia.iap.PurchaseChallengeActivity
2024-04-19 18:59:13.196   674-1242  Eve                     system_server                        W  Skipping warm_app_cool_transition_launch_time metric for:com.amazon.venezia/.iap.PurchaseChallengeActivity already emitted
2024-04-19 18:59:13.198   674-724   ActivityTaskManager     system_server                        I  Displayed com.amazon.venezia/.iap.PurchaseChallengeActivity: +127ms
2024-04-19 18:59:13.277  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseChallengeInitiated
2024-04-19 18:59:13.639  9331-9331  AmazonApps...Controller com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b PW Challenge - NONE pass: true
2024-04-19 18:59:13.642  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseChallengeSuccess
2024-04-19 18:59:13.683  2487-2487  SPCH-ADW_T...owContract amazon.speech.sim                    I  onActivityResume() com.amazon.mas.client.iap.purchase.PurchaseActivity
2024-04-19 18:59:13.978  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableInitiated
2024-04-19 18:59:14.034  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableRequestInitiated
2024-04-19 18:59:14.828  9331-11617 AmazonApps...tryInvoker com.amazon.venezia                   I  Exiting (purchase) after (1) attempts and (1027) milliseconds. Success: (true).
2024-04-19 18:59:14.831  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableRequestOneClickSuccess
2024-04-19 18:59:14.866  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableRequestSuccess
2024-04-19 18:59:14.924  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumablePollReceiptInitiated
2024-04-19 18:59:16.764  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumablePollReceiptSuccess
2024-04-19 18:59:16.808  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableReceiptStored
2024-04-19 18:59:16.844  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseDelegateNonConsumableCompleted
2024-04-19 18:59:16.847  9331-9331  AmazonApps...Controller com.amazon.venezia                   I  IAPPurchase Succeeded: 1713520756847
2024-04-19 18:59:16.894  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseDelegateCompletedToErrorOrThankYouDialogInitiated
2024-04-19 18:59:16.932  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseNonConsumableSuccess
2024-04-19 18:59:16.990  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseDelegateCompletedToThankYouDialogCompleted
2024-04-19 18:59:17.145  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseTimeoutNonConsumableInitiated
2024-04-19 18:59:18.405   674-1242  Eve                     system_server                        W  Already have old data for event WM_PAUSE_ACTIVITY of Activity com.amazon.venezia/com.amazon.mas.client.iap.purchase.PurchaseActivity
2024-04-19 18:59:18.443  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromThankYouDialogClosedToPurchaseResponseCommandInitiated
2024-04-19 18:59:18.454 10920-10920 FIAM.Display            com.enoiu.codes                      I  Binding to activity: com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:18.491  2487-2487  SPCH-ADW_T...owContract amazon.speech.sim                    I  onActivityResume() com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:18.498  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseTimeoutNonConsumableCancelled
2024-04-19 18:59:18.542  9331-11604 AmazonApps...aseTracker com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b Sending SDK broadcast
2024-04-19 18:59:18.762  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromThankYouDialogClosedToPurchaseResponseCommandCompleted
2024-04-19 18:59:18.769  9331-9803  AmazonApps...onseAction com.amazon.venezia                   I  Receipt exists for requestId: 4ae4edec-80c2-4388-b883-42f8b46c830b
2024-04-19 18:59:18.787  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromStartToFinishPurchaseResponseCommandInitiated
2024-04-19 18:59:18.821  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseResponseCommandInitiated
2024-04-19 18:59:19.575  9331-9803  AmazonApps...onseAction com.amazon.venezia                   I  Sending purchase response for requestId: 4ae4edec-80c2-4388-b883-42f8b46c830b
2024-04-19 18:59:19.579  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseResponseCommandSuccess
2024-04-19 18:59:19.608 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Purchase request finished: 
                                                                                                     {
                                                                                                     "requestId": "4ae4edec-80c2-4388-b883-42f8b46c830b",
                                                                                                     "requestStatus": "SUCCESSFUL",
                                                                                                     "userData": {
                                                                                                      "userId": "ztHmIQK3HL3zbSVWZMu9w7VNZhc7Uf4ddSiA1_WkmZ4=",
                                                                                                      "marketplace": "JP"
                                                                                                     },
                                                                                                     "receipt": {
                                                                                                      "receiptId": "8yGxH8ODnK45tRapYLyC_cdtbgUYIjzVWQm1evRObyM=:2:31",
                                                                                                      "sku": "com.enoiu.codes.noads",
                                                                                                      "itemType": "ENTITLED",
                                                                                                      "purchaseDate": "Fri Apr 19 18:59:15 GMT+09:00 2024"
                                                                                                     }
                                                                                                    }
2024-04-19 18:59:19.616 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Getting User data from cache
2024-04-19 18:59:19.617 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Requesting Amazon products with identifiers: com.enoiu.codes.noads
2024-04-19 18:59:19.617 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Retrieved productData: {com.enoiu.codes.noads={
                                                                                                        "sku": "com.enoiu.codes.noads",
                                                                                                        "productType": "ENTITLED",
                                                                                                        "description": "すべての機能(広告非表示、ブックマーク、文字の大きさ変更など)を利用できるようになります。",
                                                                                                        "price": "¥500",
                                                                                                        "smallIconUrl": "https:\/\/m.media-amazon.com\/images\/I\/31ZhRIWFKnL._SL110_FMPNG_h1_.png",
                                                                                                        "title": "プロ版へアップグレード",
                                                                                                        "coinsRewardAmount": 0
                                                                                                    }}
2024-04-19 18:59:19.619 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  Store product found for transaction: AmazonStoreProduct(id=com.enoiu.codes.noads, type=INAPP, name=プロ版へアップグレード, title=プロ版へアップグレード, description=すべての機能(広告非表示、ブックマーク、文字の大きさ変更など)を利用できるようになります。, period=null, price=Price(formatted=¥500, amountMicros=500000000, currencyCode=JPY), subscriptionOptions=null, defaultOption=null, iconUrl=https://m.media-amazon.com/images/I/31ZhRIWFKnL._SL110_FMPNG_h1_.png, freeTrialPeriod=null, originalProductJSON={"sku":"com.enoiu.codes.noads","productType":"ENTITLED","description":"すべての機能(広告非表示、ブックマーク、文字の大きさ変更など)を利用できるようになります。","price":"¥500","smallIconUrl":"https:\/\/m.media-amazon.com\/images\/I\/31ZhRIWFKnL._SL110_FMPNG_h1_.png","title":"プロ版へアップグレード","coinsRewardAmount":0}, presentedOfferingContext=null)
2024-04-19 18:59:19.620 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Found 0 unsynced attributes for App User ID: $RCAnonymousID:9e1545e1fc914a7da8fc38f0c04311a1
2024-04-19 18:59:19.629 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  Getting storefront from cache was null.
2024-04-19 18:59:19.637  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromStartToFinishPurchaseResponseCommandCompleted
2024-04-19 18:59:19.646   674-1242  Eve                     system_server                        W  Already have old data for event WM_PAUSE_ACTIVITY of Activity com.enoiu.codes/com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:19.661 10920-10920 FIAM.Display            com.enoiu.codes                      I  Unbinding from activity: com.revenuecat.purchases.amazon.purchasing.ProxyAmazonBillingActivity
2024-04-19 18:59:20.448 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  API request started: POST /receipts
2024-04-19 18:59:20.449 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  API request completed with status: POST /receipts 200
2024-04-19 18:59:20.456 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ CustomerInfo updated, sending to listener.
2024-04-19 18:59:20.457 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Saving token 8yGxH8ODnK45tRapYLyC_cdtbgUYIjzVWQm1evRObyM=:2:31 with hash uzKFgoEpw9K2B1Fu+XFeuIGksuY=
2024-04-19 18:59:20.457 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Tokens already posted: []
2024-04-19 18:59:20.457 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Tokens in cache before saving []
2024-04-19 18:59:20.458 10920-11093 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ Saving tokens [uzKFgoEpw9K2B1Fu+XFeuIGksuY=]
2024-04-19 18:59:20.465 10920-10920 RevenueCatUI            com.enoiu.codes                      D  Dismissing paywall after purchase
2024-04-19 18:59:20.467 10920-10968 flutter                 com.enoiu.codes                      E  [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: type 'Null' is not a subtype of type 'String' in type cast
                                                                                                    #0      _$$StoreTransactionImplFromJson (package:purchases_flutter/models/store_transaction.g.dart:11)
                                                                                                    #1      new _$StoreTransactionImpl.fromJson (package:purchases_flutter/models/store_transaction.freezed.dart:215)
                                                                                                    #2      _$StoreTransactionFromJson (package:purchases_flutter/models/store_transaction.freezed.dart:18)
                                                                                                    #3      new StoreTransaction.fromJson (package:purchases_flutter/models/store_transaction.dart:51)
                                                                                                    #4      PaywallViewMethodHandler._handleOnPurchaseCompleted (package:purchases_ui_flutter/views/paywall_view_method_handler.dart:62)
                                                                                                    #5      PaywallViewMethodHandler.handleMethodCall (package:purchases_ui_flutter/views/paywall_view_method_handler.dart:32)
                                                                                                    #6      InternalPaywallFooterView._buildListenerChannel.<anonymous closure> (package:purchases_ui_flutter/views/internal_paywall_footer_view.dart:99)
                                                                                                    #7      MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:571)
                                                                                                    #8      MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:564)
                                                                                                    #9      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:603)
                                                                                                    #10     _invoke2 (dart:ui/hooks.dart:344)
                                                                                                    #11     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45)
                                                                                                    #12     _Channel.push (dart:ui/channel_buffers.dart:135)
                                                                                                    #13     ChannelBuffers.push (dart:ui/channel_buffers.dart:343)
                                                                                                    #14     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:737)
                                                                                                    #15     _dispatchPlatformMessage (dart:ui/hooks.dart:257)
2024-04-19 18:59:20.984  9331-9803  AmazonApps...lledAction com.amazon.venezia                   I  fulfilled id 8yGxH8ODnK45tRapYLyC_cdtbgUYIjzVWQm1evRObyM=:2:31
2024-04-19 18:59:20.985  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseFulfilledCommandToStoredFulfillmentStatusInitiated
2024-04-19 18:59:21.005  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseFulfilledCommandInitiated
2024-04-19 18:59:21.019  9331-9803  AmazonApps...lledAction com.amazon.venezia                   I  Purchase fulfillment notified for receiptId: 8yGxH8ODnK45tRapYLyC_cdtbgUYIjzVWQm1evRObyM=:2:31
2024-04-19 18:59:21.028  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseFulfilledCommandUpdateReceiptInitiated
2024-04-19 18:59:21.044  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseFulfilledCommandUpdateReceiptSuccessStoredFulfilled
2024-04-19 18:59:21.061  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapPurchaseFulfilledCommandSuccess
2024-04-19 18:59:21.078  9331-10069 AmazonApps...ngDelegate com.amazon.venezia                   I  IAP event: 4ae4edec-80c2-4388-b883-42f8b46c830b IapTimeFromPurchaseFulfilledCommandToStoredFulfillmentStatusCompleted
2024-04-19 19:00:19.545 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ App backgrounded
2024-04-19 19:00:19.547 10920-10920 [Purchases] - DEBUG     com.enoiu.codes                      D  ℹ️ No subscriber attributes to synchronize.

@vegaro
Copy link
Contributor

vegaro commented Apr 25, 2024

Thanks for sending that over @enoiu . Looks like we are crashing with a null value in the JSON we get from the backend. Let me look into it, since it looks like we may have a bug, and I will report back.

@vegaro
Copy link
Contributor

vegaro commented Apr 25, 2024

@enoiu I am still trying to reproduce, but one thing I've noticed is that you are using an Entitlement sku. Does this happen also with subscriptions or consumables? I don't see anything weird in the response we sent from the backend to that device that could cause this.

@vegaro
Copy link
Contributor

vegaro commented Apr 25, 2024

@enoiu I think I've identified the bug. It's in the PurchaseCompleted callback of the PaywallView, where it receives an StoreTransaction, but it should be a different model. I will test my theory and look for a fix

vegaro added a commit that referenced this issue Apr 29, 2024
In `PurchaseCompleted` we are passing a Flutter's `StoreTransaction` in
the callback. This is very confusing but:

- In Android `StoreTransaction` is what's returned after a successful
purchase. This class has a nullable `orderId`
- In Android `Transaction` is the transactions in the CustomerInfo. This
class has a non-nullable `transactionIdentifier`

The issue we are having is that in Flutter we only have one
`StoreTransaction` with a non-nullable `transactionId`, and we are using
it in both places, the `PurchaseCompleted` and `CustomerInfo`.

I see several ways of fixing this:

- Making transactionIdentifier nullable. I don’t like this. It’s
breaking
- Making transactionIdentifier an empty string. Fixing it in next major
- Making transactionIdentifier an empty string, deprecating it and
creating orderId which is nullable and the same as
transactionIdentifier. We’ll have nullable orderIds in the customer info
transactions where this object is also used. In Android we have two
classes, one for CustomerInfo transactions (Transaction with
non-nullable transactionId ) and StoreTransaction which is used for
completed purchases
- Making a copy of StoreTransaction and name it CompletedPurchase , but
with a nullable transactionIdentifier. Also breaking since we need to
modify the PurchaseCompleted callback to receive this object. Making a
new callback won’t work because the broken `PurchaseCompleted will keep
crashing.

In this PR I am doing number 2, since it's the least breaking. This only
affects apps using Amazon paywalls, which is not many.

Will fix #1049
@vegaro
Copy link
Contributor

vegaro commented Apr 29, 2024

We just merged a fix for this. We'll ship the fix in the next release. Sorry about the trouble

@enoiu
Copy link
Author

enoiu commented Apr 29, 2024

Thank you very much for your great work.

Jethro87 pushed a commit to Jethro87/purchases-flutter that referenced this issue Jan 4, 2025
In `PurchaseCompleted` we are passing a Flutter's `StoreTransaction` in
the callback. This is very confusing but:

- In Android `StoreTransaction` is what's returned after a successful
purchase. This class has a nullable `orderId`
- In Android `Transaction` is the transactions in the CustomerInfo. This
class has a non-nullable `transactionIdentifier`

The issue we are having is that in Flutter we only have one
`StoreTransaction` with a non-nullable `transactionId`, and we are using
it in both places, the `PurchaseCompleted` and `CustomerInfo`.

I see several ways of fixing this:

- Making transactionIdentifier nullable. I don’t like this. It’s
breaking
- Making transactionIdentifier an empty string. Fixing it in next major
- Making transactionIdentifier an empty string, deprecating it and
creating orderId which is nullable and the same as
transactionIdentifier. We’ll have nullable orderIds in the customer info
transactions where this object is also used. In Android we have two
classes, one for CustomerInfo transactions (Transaction with
non-nullable transactionId ) and StoreTransaction which is used for
completed purchases
- Making a copy of StoreTransaction and name it CompletedPurchase , but
with a nullable transactionIdentifier. Also breaking since we need to
modify the PurchaseCompleted callback to receive this object. Making a
new callback won’t work because the broken `PurchaseCompleted will keep
crashing.

In this PR I am doing number 2, since it's the least breaking. This only
affects apps using Amazon paywalls, which is not many.

Will fix RevenueCat#1049
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants