Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 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,7 @@
## 0.5.2

* Adds support for passing `obfuscatedProfileId` through `GooglePlayPurchaseParam`.

## 0.5.1

* Adds support to overlay billing related messages. See `InAppPurchaseAndroidPlatformAddition.showInAppMessages`.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,10 +152,12 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform {
Future<bool> 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) {
Expand All @@ -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,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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);
Expand Down