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 5c39773bae6d..ef71809d15d9 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.5.2 + +* Adds support for passing `obfuscatedProfileId` through `GooglePlayPurchaseParam`. + ## 0.5.1 * Adds support to overlay billing related messages. See `InAppPurchaseAndroidPlatformAddition.showInAppMessages`. diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart index d865e328edbe..7a6e73048159 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart @@ -152,10 +152,12 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform { Future buyNonConsumable({required PurchaseParam purchaseParam}) async { ChangeSubscriptionParam? changeSubscriptionParam; String? offerToken; + String? obfuscatedProfileId; if (purchaseParam is GooglePlayPurchaseParam) { changeSubscriptionParam = purchaseParam.changeSubscriptionParam; offerToken = purchaseParam.offerToken; + obfuscatedProfileId = purchaseParam.obfuscatedProfileId; } if (offerToken == null && purchaseParam.productDetails is GooglePlayProductDetails) { @@ -167,6 +169,7 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform { product: purchaseParam.productDetails.id, offerToken: offerToken, accountId: purchaseParam.applicationUserName, + obfuscatedProfileId: obfuscatedProfileId, oldProduct: changeSubscriptionParam?.oldPurchaseDetails.productID, purchaseToken: changeSubscriptionParam?.oldPurchaseDetails.verificationData.serverVerificationData, diff --git a/packages/in_app_purchase/in_app_purchase_android/lib/src/types/google_play_purchase_param.dart b/packages/in_app_purchase/in_app_purchase_android/lib/src/types/google_play_purchase_param.dart index 0e5f91701153..ee6fa30808fb 100644 --- a/packages/in_app_purchase/in_app_purchase_android/lib/src/types/google_play_purchase_param.dart +++ b/packages/in_app_purchase/in_app_purchase_android/lib/src/types/google_play_purchase_param.dart @@ -12,10 +12,19 @@ class GooglePlayPurchaseParam extends PurchaseParam { GooglePlayPurchaseParam({ required super.productDetails, super.applicationUserName, + this.obfuscatedProfileId, this.changeSubscriptionParam, this.offerToken, }); + /// The obfuscated profile id specified when making a purchase. + /// + /// This is passed to Google Play as the obfuscated profile id. It should be + /// an obfuscated identifier that is uniquely associated with the user's + /// profile in your app, and must not contain personally identifiable + /// information. + final String? obfuscatedProfileId; + /// The 'changeSubscriptionParam' containing information for upgrading or /// downgrading an existing subscription. final ChangeSubscriptionParam? changeSubscriptionParam; 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 110702ff74f1..6309b423db2e 100644 --- a/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml +++ b/packages/in_app_purchase/in_app_purchase_android/pubspec.yaml @@ -3,7 +3,7 @@ description: An implementation for the Android platform of the Flutter `in_app_p 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.5.1 +version: 0.5.2 environment: sdk: ^3.12.0 diff --git a/packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_test.dart b/packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_test.dart index c0b6260167d4..5f7342b571bc 100644 --- a/packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_test.dart +++ b/packages/in_app_purchase/in_app_purchase_android/test/in_app_purchase_android_platform_test.dart @@ -358,6 +358,7 @@ void main() { test('buy non consumable, serializes and deserializes data', () async { const ProductDetailsWrapper productDetails = dummyOneTimeProductDetails; const accountId = 'hashedAccountId'; + const profileId = 'hashedProfileId'; const debugMessage = 'dummy message'; const BillingResponse sentCode = BillingResponse.ok; const expectedBillingResult = BillingResultWrapper( @@ -403,10 +404,15 @@ void main() { final purchaseParam = GooglePlayPurchaseParam( productDetails: GooglePlayProductDetails.fromProductDetails(productDetails).first, applicationUserName: accountId, + obfuscatedProfileId: profileId, ); final bool launchResult = await iapAndroidPlatform.buyNonConsumable( purchaseParam: purchaseParam, ); + final VerificationResult verification = verify(mockApi.launchBillingFlow(captureAny)); + final params = verification.captured.single as PlatformBillingFlowParams; + expect(params.accountId, equals(accountId)); + expect(params.obfuscatedProfileId, equals(profileId)); final PurchaseDetails result = await completer.future; expect(launchResult, isTrue);