v1.1.26 android release
This commit is contained in:
+24
-39
@@ -75,49 +75,34 @@ class RevenueCatPurchases with Logging {
|
||||
}
|
||||
|
||||
Future<void> makePurchase(wtproduct.Product product) async {
|
||||
try {
|
||||
if (_offering == null) {
|
||||
_offering = await getOfferings();
|
||||
}
|
||||
if (_offering != null) {
|
||||
String productId = Platform.isAndroid ? product.productIdAndroid! : product.productIdIos!;
|
||||
Package? selectedPackage;
|
||||
log("Nr of packages: " + _offering!.availablePackages.length.toString() + " ProductId: " + productId);
|
||||
for (var package in _offering!.availablePackages) {
|
||||
log("package to check " + package.product.identifier.toString());
|
||||
if (package.product.identifier == productId) {
|
||||
selectedPackage = package;
|
||||
log("**** Selected package to purchase" + package.product.identifier);
|
||||
break;
|
||||
}
|
||||
if (_offering == null) {
|
||||
_offering = await getOfferings();
|
||||
}
|
||||
if (_offering != null) {
|
||||
String productId = Platform.isAndroid ? product.productIdAndroid! : product.productIdIos!;
|
||||
Package? selectedPackage;
|
||||
log("Nr of packages: " + _offering!.availablePackages.length.toString() + " ProductId: " + productId);
|
||||
for (var package in _offering!.availablePackages) {
|
||||
log("package to check " + package.product.identifier.toString());
|
||||
if (package.product.identifier == productId) {
|
||||
selectedPackage = package;
|
||||
log("**** Selected package to purchase" + package.product.identifier);
|
||||
break;
|
||||
}
|
||||
if (selectedPackage != null) {
|
||||
PurchaserInfo purchaserInfo = await Purchases.purchasePackage(selectedPackage);
|
||||
if (purchaserInfo.entitlements.all["wt_subscription"] != null && purchaserInfo.entitlements.all["wt_subscription"]!.isActive) {
|
||||
Cache().hasPurchased = true;
|
||||
log(" -- Purchased -- ");
|
||||
}
|
||||
} else {
|
||||
log("!!!! No Selected package to purchase");
|
||||
throw Exception("Purchase was not successful");
|
||||
}
|
||||
if (selectedPackage != null) {
|
||||
PurchaserInfo purchaserInfo = await Purchases.purchasePackage(selectedPackage);
|
||||
if (purchaserInfo.entitlements.all["wt_subscription"] != null && purchaserInfo.entitlements.all["wt_subscription"]!.isActive) {
|
||||
Cache().hasPurchased = true;
|
||||
log(" -- Purchased -- ");
|
||||
}
|
||||
} else {
|
||||
log("!!!! No active offering");
|
||||
}
|
||||
} on PlatformException catch (e) {
|
||||
var errorCode = PurchasesErrorHelper.getErrorCode(e);
|
||||
if (errorCode == PurchasesErrorCode.invalidReceiptError) {
|
||||
log("iOS Sandbox invalid receipt");
|
||||
Cache().hasPurchased = true;
|
||||
log(" -- Purchased -- ");
|
||||
return;
|
||||
}
|
||||
log(e.toString());
|
||||
if (errorCode == PurchasesErrorCode.purchaseCancelledError) {
|
||||
throw Exception("Purchase was cancelled");
|
||||
} else {
|
||||
throw Exception("Purchase was not successful");
|
||||
log("!!!! No Selected package to purchase");
|
||||
throw Exception("No Selected package to purchase");
|
||||
}
|
||||
} else {
|
||||
log("!!!! No active offering");
|
||||
throw Exception("No active offering");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user