Skip to content

Commit

Permalink
[in_app_purchase] Update Play Billing library to 7.1.1 (#8218)
Browse files Browse the repository at this point in the history
Updates Play Billing Library to the latest version 7.1.1. Exposes new APIs as per [release notes](https://developer.android.com/google/play/billing/release-notes):
- Adds Dart representation of `ProductDetails.InstallmentPlanDetails`
- Adds Dart representation of `PendingPurchasesParams` and removes the deprecated `enablePendingPurchases` method on `BillingClientWrapper` (breaking change)
- Adds Dart representation of `Purchase.PendingPurchaseUpdate`
- Removes the deprecated `ProrationMode` as it has been removed from the native library (breaking change)

This PR introduces breaking changes in `in_app_purchase_android`, but does not introduce any breaking changes on the platform interface level.

Fixes flutter/flutter#147394
  • Loading branch information
mchudy authored Jan 20, 2025
1 parent 6dee381 commit e8f1f63
Show file tree
Hide file tree
Showing 51 changed files with 1,630 additions and 1,935 deletions.
11 changes: 11 additions & 0 deletions packages/in_app_purchase/in_app_purchase_android/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
## 0.4.0

* Updates Google Play Billing Library from 6.2.0 to 7.1.1.
* **BREAKING CHANGES**:
* Removes the deprecated `ProrationMode` enum. `ReplacementMode` should be used instead.
* Removes the deprecated `BillingClientWrapper.enablePendingPurchases` method.
* Removes JSON serialization from Dart wrapper classes.
* Removes `subscriptionsOnVR` and `inAppItemsOnVR` from `BillingClientFeature`.
* Adds `installmentPlanDetails` to `SubscriptionOfferDetailsWrapper`.
* Adds APIs to support pending transactions for subscription prepaid plans (`PendingPurchasesParams`).

## 0.3.6+13

* Updates androidx.annotation:annotation to 1.9.1.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ android {
compileSdk 34

defaultConfig {
minSdk 19
minSdk 21
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
lintOptions {
Expand Down Expand Up @@ -60,7 +60,7 @@ android {

dependencies {
implementation 'androidx.annotation:annotation:1.9.1'
implementation 'com.android.billingclient:billing:6.2.0'
implementation 'com.android.billingclient:billing:7.1.1'
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.json:json:20250107'
testImplementation 'org.mockito:mockito-core:5.4.0'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,13 @@ interface BillingClientFactory {
* @param callbackApi The callback API to be used by the {@link BillingClient}.
* @param billingChoiceMode Enables the ability to offer alternative billing or Google Play
* billing.
* @param pendingPurchasesParams Parameters to enable pending purchases. See {@link
* com.android.billingclient.api.PendingPurchasesParams}.
* @return The {@link BillingClient} object that is created.
*/
BillingClient createBillingClient(
@NonNull Context context,
@NonNull Messages.InAppPurchaseCallbackApi callbackApi,
PlatformBillingChoiceMode billingChoiceMode);
PlatformBillingChoiceMode billingChoiceMode,
Messages.PlatformPendingPurchasesParams pendingPurchasesParams);
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package io.flutter.plugins.inapppurchase;

import static io.flutter.plugins.inapppurchase.Translator.fromUserChoiceDetails;
import static io.flutter.plugins.inapppurchase.Translator.toPendingPurchasesParams;

import android.content.Context;
import androidx.annotation.NonNull;
Expand All @@ -21,8 +22,11 @@ final class BillingClientFactoryImpl implements BillingClientFactory {
public BillingClient createBillingClient(
@NonNull Context context,
@NonNull Messages.InAppPurchaseCallbackApi callbackApi,
PlatformBillingChoiceMode billingChoiceMode) {
BillingClient.Builder builder = BillingClient.newBuilder(context).enablePendingPurchases();
PlatformBillingChoiceMode billingChoiceMode,
Messages.PlatformPendingPurchasesParams pendingPurchasesParams) {
BillingClient.Builder builder =
BillingClient.newBuilder(context)
.enablePendingPurchases(toPendingPurchasesParams(pendingPurchasesParams));
switch (billingChoiceMode) {
case ALTERNATIVE_BILLING_ONLY:
// https://developer.android.com/google/play/billing/alternative/alternative-billing-without-user-choice-in-app
Expand Down
Loading

0 comments on commit e8f1f63

Please sign in to comment.