diff --git a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md index f32df46b48d..f4ced732d72 100644 --- a/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md +++ b/packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md @@ -1,3 +1,7 @@ +## 0.3.0+6 + +* Bumps com.android.billingclient:billing from 5.2.0 to 6.0.0. + ## 0.3.0+5 * Bumps org.jetbrains.kotlin:kotlin-bom from 1.8.0 to 1.8.21. diff --git a/packages/in_app_purchase/in_app_purchase_android/android/build.gradle b/packages/in_app_purchase/in_app_purchase_android/android/build.gradle index 3a2344bda3e..ea081bfd1bb 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/build.gradle +++ b/packages/in_app_purchase/in_app_purchase_android/android/build.gradle @@ -61,7 +61,7 @@ dependencies { // org.jetbrains.kotlin:kotlin-bom artifact purpose is to align kotlin stdlib and related code versions. // See: https://youtrack.jetbrains.com/issue/KT-55297/kotlin-stdlib-should-declare-constraints-on-kotlin-stdlib-jdk8-and-kotlin-stdlib-jdk7 implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.21")) - implementation 'com.android.billingclient:billing:5.2.0' + implementation 'com.android.billingclient:billing:6.0.0' testImplementation 'junit:junit:4.13.2' testImplementation 'org.json:json:20230227' testImplementation 'org.mockito:mockito-core:4.7.0' diff --git a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java index e6c6e0ae793..b1c4d0a7315 100644 --- a/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java +++ b/packages/in_app_purchase/in_app_purchase_android/android/src/main/java/io/flutter/plugins/inapppurchase/MethodCallHandlerImpl.java @@ -22,7 +22,6 @@ import com.android.billingclient.api.BillingClient; import com.android.billingclient.api.BillingClientStateListener; import com.android.billingclient.api.BillingFlowParams; -import com.android.billingclient.api.BillingFlowParams.ProrationMode; import com.android.billingclient.api.BillingResult; import com.android.billingclient.api.ConsumeParams; import com.android.billingclient.api.ConsumeResponseListener; @@ -50,17 +49,20 @@ static final class MethodNames { static final String END_CONNECTION = "BillingClient#endConnection()"; static final String ON_DISCONNECT = "BillingClientStateListener#onBillingServiceDisconnected()"; static final String QUERY_PRODUCT_DETAILS = - "BillingClient#queryProductDetailsAsync(QueryProductDetailsParams, ProductDetailsResponseListener)"; + "BillingClient#queryProductDetailsAsync(QueryProductDetailsParams," + + " ProductDetailsResponseListener)"; static final String LAUNCH_BILLING_FLOW = "BillingClient#launchBillingFlow(Activity, BillingFlowParams)"; static final String QUERY_PURCHASES_ASYNC = "BillingClient#queryPurchasesAsync(QueryPurchaseParams, PurchaseResponseListener)"; static final String QUERY_PURCHASE_HISTORY_ASYNC = - "BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams, PurchaseHistoryResponseListener)"; + "BillingClient#queryPurchaseHistoryAsync(QueryPurchaseHistoryParams," + + " PurchaseHistoryResponseListener)"; static final String CONSUME_PURCHASE_ASYNC = "BillingClient#consumeAsync(ConsumeParams, ConsumeResponseListener)"; static final String ACKNOWLEDGE_PURCHASE = - "BillingClient#acknowledgePurchase(AcknowledgePurchaseParams, AcknowledgePurchaseResponseListener)"; + "BillingClient#acknowledgePurchase(AcknowledgePurchaseParams," + + " AcknowledgePurchaseResponseListener)"; static final String IS_FEATURE_SUPPORTED = "BillingClient#isFeatureSupported(String)"; static final String GET_CONNECTION_STATE = "BillingClient#getConnectionState()"; @@ -131,6 +133,7 @@ void onDetachedFromActivity() { } @Override + @SuppressWarnings(value = "deprecation") public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result result) { switch (call.method) { case MethodNames.IS_READY: @@ -156,7 +159,8 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull MethodChannel.Result (String) call.argument("purchaseToken"), call.hasArgument("prorationMode") ? (int) call.argument("prorationMode") - : ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, + : com.android.billingclient.api.BillingFlowParams.ProrationMode + .UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, result); break; case MethodNames.QUERY_PURCHASES_ASYNC: @@ -222,6 +226,7 @@ private void queryProductDetailsAsync( }); } + @SuppressWarnings(value = "deprecation") private void launchBillingFlow( String product, @Nullable String offerToken, @@ -241,7 +246,9 @@ private void launchBillingFlow( "NOT_FOUND", "Details for product " + product - + " are not available. It might because products were not fetched prior to the call. Please fetch the products first. An example of how to fetch the products could be found here: " + + " are not available. It might because products were not fetched prior to the call." + + " Please fetch the products first. An example of how to fetch the products could be" + + " found here: " + LOAD_PRODUCT_DOC_URL, null); return; @@ -265,7 +272,9 @@ private void launchBillingFlow( + offerToken + " for product " + product - + " is not valid. Make sure to only pass offer tokens that belong to the product. To obtain offer tokens for a product, fetch the products. An example of how to fetch the products could be found here: " + + " is not valid. Make sure to only pass offer tokens that belong to the product." + + " To obtain offer tokens for a product, fetch the products. An example of how to" + + " fetch the products could be found here: " + LOAD_PRODUCT_DOC_URL, null); return; @@ -273,10 +282,13 @@ private void launchBillingFlow( } if (oldProduct == null - && prorationMode != ProrationMode.UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { + && prorationMode + != com.android.billingclient.api.BillingFlowParams.ProrationMode + .UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY) { result.error( "IN_APP_PURCHASE_REQUIRE_OLD_PRODUCT", - "launchBillingFlow failed because oldProduct is null. You must provide a valid oldProduct in order to use a proration mode.", + "launchBillingFlow failed because oldProduct is null. You must provide a valid oldProduct" + + " in order to use a proration mode.", null); return; } else if (oldProduct != null && !cachedProducts.containsKey(oldProduct)) { @@ -284,7 +296,9 @@ private void launchBillingFlow( "IN_APP_PURCHASE_INVALID_OLD_PRODUCT", "Details for product " + oldProduct - + " are not available. It might because products were not fetched prior to the call. Please fetch the products first. An example of how to fetch the products could be found here: " + + " are not available. It might because products were not fetched prior to the call." + + " Please fetch the products first. An example of how to fetch the products could be" + + " found here: " + LOAD_PRODUCT_DOC_URL, null); return; diff --git a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml index 2132e84abba..d8ac5f6d38c 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml @@ -2,7 +2,7 @@ name: in_app_purchase_android description: An implementation for the Android platform of the Flutter `in_app_purchase` plugin. This uses the Android BillingClient APIs. repository: https://github.com/flutter/packages/tree/main/packages/in_app_purchase/in_app_purchase_android issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+in_app_purchase%22 -version: 0.3.0+5 +version: 0.3.0+6 environment: sdk: ">=2.18.0 <4.0.0"