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

Issue using getAvailablePurchases #44

Closed
rlee1990 opened this issue Oct 14, 2018 · 11 comments
Closed

Issue using getAvailablePurchases #44

rlee1990 opened this issue Oct 14, 2018 · 11 comments
Labels
android android related issue

Comments

@rlee1990
Copy link

When I try to use getAvailablePurchases with version 0.8.0 I receive this error
E/MethodChannel#flutter_inapp( 8976): Failed to handle method call E/MethodChannel#flutter_inapp( 8976): java.lang.IllegalStateException: Reply already submitted E/MethodChannel#flutter_inapp( 8976): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174) E/MethodChannel#flutter_inapp( 8976): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler$1.success(MethodChannel.java:203) E/MethodChannel#flutter_inapp( 8976): at com.dooboolab.flutterinapppurchase.AndroidInappPurchasePlugin.onMethodCall(AndroidInappPurchasePlugin.java:275) E/MethodChannel#flutter_inapp( 8976): at com.dooboolab.flutterinapppurchase.FlutterInappPurchasePlugin.onMethodCall(FlutterInappPurchasePlugin.java:37) E/MethodChannel#flutter_inapp( 8976): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:200) E/MethodChannel#flutter_inapp( 8976): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/MethodChannel#flutter_inapp( 8976): at android.os.MessageQueue.nativePollOnce(Native Method) E/MethodChannel#flutter_inapp( 8976): at android.os.MessageQueue.next(MessageQueue.java:325) E/MethodChannel#flutter_inapp( 8976): at android.os.Looper.loop(Looper.java:142) E/MethodChannel#flutter_inapp( 8976): at android.app.ActivityThread.main(ActivityThread.java:6940) E/MethodChannel#flutter_inapp( 8976): at java.lang.reflect.Method.invoke(Native Method) E/MethodChannel#flutter_inapp( 8976): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) E/MethodChannel#flutter_inapp( 8976): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) E/FlutterNativeView( 8976): Uncaught exception in binary message listener E/FlutterNativeView( 8976): java.lang.IllegalStateException: Reply already submitted E/FlutterNativeView( 8976): at io.flutter.view.FlutterNativeView$1.reply(FlutterNativeView.java:174) E/FlutterNativeView( 8976): at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:218) E/FlutterNativeView( 8976): at io.flutter.view.FlutterNativeView.handlePlatformMessage(FlutterNativeView.java:163) E/FlutterNativeView( 8976): at android.os.MessageQueue.nativePollOnce(Native Method) E/FlutterNativeView( 8976): at android.os.MessageQueue.next(MessageQueue.java:325) E/FlutterNativeView( 8976): at android.os.Looper.loop(Looper.java:142) E/FlutterNativeView( 8976): at android.app.ActivityThread.main(ActivityThread.java:6940) E/FlutterNativeView( 8976): at java.lang.reflect.Method.invoke(Native Method) E/FlutterNativeView( 8976): at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) E/FlutterNativeView( 8976): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374) E/flutter ( 8976): [ERROR:flutter/shell/common/shell.cc(182)] Dart Error: Unhandled exception: E/flutter ( 8976): PlatformException(InappPurchasePlugin, E_BILLING_RESPONSE_JSON_PARSE_ERROR, No value for originalJson) E/flutter ( 8976): #0 StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7) E/flutter ( 8976): #1 MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18) E/flutter ( 8976): <asynchronous suspension> E/flutter ( 8976): #2 FlutterInappPurchase.getAvailablePurchases (package:flutter_inapp_purchase/flutter_inapp_purchase.dart:173:40) E/flutter ( 8976): <asynchronous suspension> E/flutter ( 8976): #3 _InAppPurchasesSettingsState._restoreProducts (file:///Volumes/drive/Flutter_Apps/flutter_crushn/lib/ui/inapp_purchases_view.dart:116:26) E/flutter ( 8976): <asynchronous suspension> E/flutter ( 8976): #4 _InAppPurchasesSettingsState.build.<anonymous closure> (file:///Volumes/drive/Flutter_Apps/flutter_crushn/lib/ui/inapp_purchases_view.dart:108:24) E/flutter ( 8976): #5 _InkResponseState._handleTap (package:flutter/src/material/ink_well.dart:507:14) E/flutter ( 8976): #6 _InkResponseState.build.<anonymous closure> (package:flutter/src/material/ink_well.dart:562:30) E/flutter ( 8976): #7 GestureRecognizer.invokeCallback (package:flutter/src/gestures/recognizer.dart:102:24) E/flutter ( 8976): #8 TapGestureRecognizer._checkUp (package:flutter/src/gestures/tap.dart:242:9) E/flutter ( 8976): #9 TapGestureRecognizer.handlePrimaryPointer (package:flutter/src/gestures/tap.dart:175:7) E/flutter ( 8976): #10 PrimaryPointerGestureRecognizer.handleEvent (package:flutter/src/gestures/recognizer.dart:315:9) E/flutter ( 8976): #11 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12) E/flutter ( 8976): #12 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11) E/flutter ( 8976): #13 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:143:19) E/flutter ( 8976): #14 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:121:22) E/flutter ( 8976): #15 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:101:7) E/flutter ( 8976): #16 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:64:7) E/flutter ( 8976): #17 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:48:7) E/flutter ( 8976): #18 _invoke1 (dart:ui/hooks.dart:153:13) E/flutter ( 8976): #19 _dispatchPointerDataPacket (dart:ui/hooks.dart:107:5)

@rlee1990
Copy link
Author

This is only an issue in Android. I am using a Galaxy note 8 running 8.0 if this helps.

@hyochan hyochan added the android android related issue label Oct 14, 2018
@arkanmgerges
Copy link

Hi,
I'm using samsung galaxy note 8.

I made subscription FlutterInappPurchase.buySubscription(item.productId);
the subscription succeeded, and it's registered also in my google play store account (my user is put as a test user)
Then I uninstall the app from my device, and install it again (the subscription is still active).
When I used await FlutterInappPurchase.getAvailablePurchases();
I got the exception PlatformException(InappPurchasePlugin, E_BILLING_RESPONSE_JSON_PARSE_ERROR, No value for originalJson)

E/flutter (29291): [ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled exception:
E/flutter (29291): PlatformException(InappPurchasePlugin, E_BILLING_RESPONSE_JSON_PARSE_ERROR, No value for originalJson)
E/flutter (29291): #0      StandardMethodCodec.decodeEnvelope (package:flutter/src/services/message_codecs.dart:551:7)
E/flutter (29291): #1      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:279:18)
E/flutter (29291): <asynchronous suspension>
E/flutter (29291): #2      FlutterInappPurchase.getAvailablePurchases (package:flutter_inapp_purchase/flutter_inapp_purchase.dart:180:40)
E/flutter (29291): <asynchronous suspension>
E/flutter (29291): #3      InAppPurchaseManager.checkSubscription (package:localspeedreading/model/in_app_purchase_manager.dart:38:52)
E/flutter (29291): <asynchronous suspension>
E/flutter (29291): #4      connectivityUpdated (package:localspeedreading/redux/middleware/app_connectivity_middleware.dart:9:36)
E/flutter (29291): #5      TypedMiddleware.call (package:redux/src/utils.dart:218:7)
E/flutter (29291): #6      Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #7      TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #8      Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #9      TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #10     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #11     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #12     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #13     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #14     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #15     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #16     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #17     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #18     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #19     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #20     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #21     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #22     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #23     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #24     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #25     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #26     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #27     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #28     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #29     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #30     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #31     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #32     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #33     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #34     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #35     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #36     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #37     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #38     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #39     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #40     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #41     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #42     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #43     TypedMiddleware.call (package:redux/src/utils.dart:220:11)
E/flutter (29291): #44     Store._createDispatchers.<anonymous closure> (package:redux/src/store.dart:238:43)
E/flutter (29291): #45     TypedMiddleware.call (package:redux/src/utils.dart:220:11)

Thanks

@rlee1990
Copy link
Author

Any update on this @dooboolab

@arkanmgerges
Copy link

Hi,
I'm just want to say that I'm debugging your plugin. Right now (when I wrote this comment), and I observed on subscription the exception is thrown on this line:

// File AndroidInappPurchasePlugin:262
item.put("transactionReceipt", json.getString("originalJson"));

What I've got from google play, they were these keys (I've omitted the value):

{
"orderId":"value omitted",
"packageName":"value omitted",
"productId":"value omitted",
"purchaseTime":"value omitted",
"purchaseState":"value omitted",
"purchaseToken":"value omitted",
"autoRenewing": "value omitted"
}

As you can observe, there is no such key when the type is 'subs' on this line:
// File AndroidInappPurchasePlugin.java:237
availableItems = mService.getPurchases(3, reg.context().getPackageName(), type, null);

Thanks,
Arkan

@arkanmgerges
Copy link

Hi again,
Just an update, if you want to keep the code and to check for the key "originalJson", I just put it inside a verification like this:

if (json.has("originalJson")) {
              item.put("transactionReceipt", json.getString("originalJson"));
            }

And now my app is running, I can subscribe, and also I can check if the subscription is canceled, by using the property "autoRenewingAndroid".

Thanks,
Arkan

@holyspidoo
Copy link
Contributor

I have this exact issue. Any chance @arkanmgerges can do a PR? This is pretty major stuff.

@rlee1990
Copy link
Author

I'm not sure what you guys are saying is related to this issue. I have no issue with buying a subscription or even switching from one subscription to another. My issue is with restoring purchases in Android.

@holyspidoo
Copy link
Contributor

Yes, my issue is also when restoring purchases (not subscriptions), but it seems @arkanmgerges has found where the problem occurs?

@holyspidoo
Copy link
Contributor

Makes sense since purchaseToken was replaced by originalJson in this commit:
e00555c

hyochan added a commit that referenced this issue Oct 18, 2018
@hyochan
Copy link
Owner

hyochan commented Oct 18, 2018

Thank you for finding bug. I've released to 0.8.3 resolving this. Please give us a PR anytime if you find something like this.

@hyochan hyochan closed this as completed Oct 18, 2018
@arkanmgerges
Copy link

Great, thanks for updating the code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android android related issue
Projects
None yet
Development

No branches or pull requests

4 participants