Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 91f05e7

Browse files
committed
Don't force GooglePlayPurchaseParam
1 parent 81f7e6b commit 91f05e7

1 file changed

Lines changed: 7 additions & 9 deletions

File tree

packages/in_app_purchase/in_app_purchase_android/lib/src/in_app_purchase_android_platform.dart

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -130,22 +130,20 @@ class InAppPurchaseAndroidPlatform extends InAppPurchasePlatform {
130130

131131
@override
132132
Future<bool> buyNonConsumable({required PurchaseParam purchaseParam}) async {
133-
if (!(purchaseParam is GooglePlayPurchaseParam)) {
134-
throw ArgumentError(
135-
'On Android, the `purchaseParam` should always be of type `GooglePlayPurchaseParam`.',
136-
);
133+
ChangeSubscriptionParam? changeSubscriptionParam;
134+
135+
if (purchaseParam is GooglePlayPurchaseParam) {
136+
changeSubscriptionParam = purchaseParam.changeSubscriptionParam;
137137
}
138138

139139
BillingResultWrapper billingResultWrapper =
140140
await billingClient.launchBillingFlow(
141141
sku: purchaseParam.productDetails.id,
142142
accountId: purchaseParam.applicationUserName,
143-
oldSku: purchaseParam
144-
.changeSubscriptionParam?.oldPurchaseDetails.productID,
145-
purchaseToken: purchaseParam.changeSubscriptionParam
143+
oldSku: changeSubscriptionParam?.oldPurchaseDetails.productID,
144+
purchaseToken: changeSubscriptionParam
146145
?.oldPurchaseDetails.verificationData.serverVerificationData,
147-
prorationMode:
148-
purchaseParam.changeSubscriptionParam?.prorationMode);
146+
prorationMode: changeSubscriptionParam?.prorationMode);
149147
return billingResultWrapper.responseCode == BillingResponse.ok;
150148
}
151149

0 commit comments

Comments
 (0)