Problem description: Flutter_inapp_purchase payment repository, error occurred when clicking to buy the managed item;
W/BillingClient(25436): Unable to buy item, Error response code: 7
E/DoobooUtils(25436): Error Code : 7
I/ Flutter (25436): [Price: 65.99, monthPrice: 5.50]
I/ Flutter (25436): [Price: 29.99, monthPrice: 10.00]
I/ Flutter (25436): [Price: 149.99, monthPrice:]
D/FA (25436): Logging Events (FE): HWPurchaseSelect, Bundle[{source=, ga_event_origin(_O)=app, ga_screen_class(_SC)=MainActivity, ga_screen_id(_SI)=-2672549720685398148, Purchase_month =lifetime}]
I/flutter (25436): kiit0611==== 3 responseCode: 7, debugMessage: Item is already owned., code: E_ALREADY_OWNED, message: You already own this item.
The error is obvious: you already have this item, indicating that the current account logged into Google Play has already purchased this item.
Solutions:
Change your Google Play account directly and clear the Google Account cache (clear the Google Play cache). To buy again, sometimes you need to restart the phone.
This problem usually occurs on the ios side, but if it does occur in Google, it can be solved according to the above method. However, it is important to note that when using the library, the code looks like this:
FlutterInappPurchase.instance.clearTransactionIOS();…
/// google order confirmation operation. /// If the purchase transaction is not confirmed within a further 3 days, the user will automatically receive a refund, along with // Google Play will revoke that purchase transaction if (Platform.isAndroid) { FlutterInappPurchase.instance .acknowledgePurchaseAndroid(productItem.purchaseToken); FlutterInappPurchase.instance .consumePurchaseAndroid(productItem.purchaseToken); }
The screenshot is as follows:
Please have such code. FlutterInappPurchase.instance .consumePurchaseAndroid(productItem.purchaseToken); That means consume it, or else it will always be there and report errorCode = 7.
The source code in the Flutter_inapp_Purchase payment repository is as follows: See the red comment.
/// Consumes a purchase on `Android`. /// /// No effect on `iOS`, whose consumable purchases are consumed at the time of purchase. /// /// if you already invoked [getProducts],you ought to invoked this method to confirm you have consumed. /// that means you can purchase one IAPItem more times, otherwise you'll receive error code : 7 /// /// in DoobooUtils.java error like this: /// case BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED: /// errorData[0] = E_ALREADY_OWNED; /// errorData[1] = "You already own this item."; /// break; Future<String> consumePurchaseAndroid(String token, { String developerPayload }) async { if (_platform.isAndroid) { String result = await _channel.invokeMethod('consumeProduct', <String, dynamic>{ 'token': token, 'developerPayload': developerPayload, }); return result; } else if (_platform.isIOS) { return 'no-ops in ios'; } throw PlatformException( code: _platform.operatingSystem, message: "platform not supported"); }
Keep in mind that google-enabled phones can sometimes get weird with lots of accounts and caches (clear the Goole Play cache), so it’s best to switch accounts, clear the cache, and restart the phone.
Read More:
- [Solved] Flutter package flutter build apk Error: permission-handle
- Flutter flutter doctor –android-licenses [How to Solve]
- Unable to find bundled Java version =>Mac Flutter [Android Studio Arctic Fox 2020.3.1]
- [Solved] Flutter compile error: Failed to find Build Tools revision 29.0.2
- [Solved] Flutter Error: fluwx:compileDebugKotlin
- [Solved] flutter Project Error: ScrollController attached to multiple scroll views, Failed assertion: line 109 pos 12
- How to Solve Project Upgrade to flutter2.5.0 Error
- [Solved] Flutter – AAPT: error: resource android:attr/dialogCornerRadius not found.
- [Easy Solution] flutter Run Error: library “libflutter.so“ not found
- [Solved] Flutter Error: No MediaQuery widget ancestor found.
- Flutter android studio runs gradle build error: Could not resolve all artifacts for configuration’:classpath’.
- flutter doctor –android-licenses error [How to Solve]
- Flutter Package error: keyboard_visibility:verifyReleaseResources
- flutter | W/zipro(12512): Error opening archive D:\…Invalid file ERROR: dump failed because…
- [Solved] Flutter SDK constraint error: pub get failed (65; See…
- Flutter Error: dump failed because resource AndroidManifest.xml not found [How to Solve]
- Flutter Xcode Module not found or LibreSSL SSL_connect: SSL_ERROR_SYSCALL
- Flutter upgrade upgrade SDK SSL_ERROR_Syscall error [How to Solve]
- [Solved] Flutter Amap plug-in amap_location error: AmapLocationPlugin.java:287: error
- Android7.0+ Failed to Share Images: exposed beyond app through ClipData.Item.getUri()