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 @@
## NEXT

* Adds support for passing an obfuscated profile ID in 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 @@ -14,6 +14,7 @@ class GooglePlayPurchaseParam extends PurchaseParam {
super.applicationUserName,
this.changeSubscriptionParam,
this.offerToken,
this.obfuscatedProfileId,
});

/// The 'changeSubscriptionParam' containing information for upgrading or
Expand All @@ -25,4 +26,10 @@ class GooglePlayPurchaseParam extends PurchaseParam {
/// For subscriptions, to get the offer token corresponding to the selected
/// offer call productDetails.subscriptionOfferDetails?.get(selectedOfferIndex)?.offerToken
final String? offerToken;

/// An optional obfuscated profile ID associated with the user's profile.
///
/// Setting this field requires [applicationUserName], which maps to the
/// obfuscated account ID, to be specified as well.
final String? obfuscatedProfileId;
Comment thread
lianshumin marked this conversation as resolved.
}
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,34 @@ void main() {
expect(result.productID, productDetails.productId);
});

test('buyNonConsumable passes obfuscatedProfileId', () async {
const profileId = 'hashedProfileId';
const accountId = 'hashedAccountId';
const expectedBillingResult = BillingResultWrapper(
responseCode: BillingResponse.ok,
debugMessage: 'dummy message',
);
when(
mockApi.launchBillingFlow(any),
).thenAnswer((_) async => convertToPigeonResult(expectedBillingResult));

final bool launchResult = await iapAndroidPlatform.buyNonConsumable(
purchaseParam: GooglePlayPurchaseParam(
productDetails: GooglePlayProductDetails.fromProductDetails(
dummyOneTimeProductDetails,
).first,
applicationUserName: accountId,
obfuscatedProfileId: profileId,
),
);

final VerificationResult result = verify(mockApi.launchBillingFlow(captureAny));
final params = result.captured.single as PlatformBillingFlowParams;
expect(launchResult, isTrue);
expect(params.accountId, accountId);
expect(params.obfuscatedProfileId, profileId);
});
Comment thread
lianshumin marked this conversation as resolved.

test('handles an error with an empty purchases list', () async {
const ProductDetailsWrapper productDetails = dummyOneTimeProductDetails;
const accountId = 'hashedAccountId';
Expand Down