Hi @Saeed Basweidan,
Does it work with any other mode? And would you be able to pass the snippet of code where you do the purchase call?
Best,
hi @joan-cardona
all other modes work fine only deferred mode call does not resolve
check the code
also i testing with sand box
import 'package:flutter/material.dart';
import 'package:purchases_flutter/purchases_flutter.dart';
Future<void> purchaseSubscription(BuildContext context, Package package, String activeSubscriptionId) async {
try {
WidgetUtils.showLoading(context);
// Sync attributes and offerings if needed
Purchases.syncAttributesAndOfferingsIfNeeded();
CustomerInfo customerInfo;
if (activeSubscriptionId.isNotEmpty) {
print("---------------------+++++++++++++ deferred---------------------+++++++++++++ ");
customerInfo = await Purchases.purchasePackage(
package,
googleProductChangeInfo: GoogleProductChangeInfo(
activeSubscriptionId,
prorationMode: GoogleProrationMode.deferred,
),
);
print("---------------------+++++++++++++ after deferred---------------------+++++++++++++ ");
} else {
customerInfo = await Purchases.purchasePackage(package);
}
print('---------------------+++++++++++++ payment is done now ---------------------+++++++++++++ ');
if (customerInfo.activeSubscriptions.isNotEmpty) {
logPurchase(package.storeProduct.currencyCode, package.storeProduct.price);
print('purchase-updated: `${package}`');
await Future.delayed(Duration(seconds: 2));
WidgetUtils.hideLoading(context);
Navigator.of(context).pushNamed("/home");
}
} on PlatformException catch (e) {
WidgetUtils.hideLoading(context);
final errorCode = PurchasesErrorHelper.getErrorCode(e);
String errorMessage = "An error occurred: ${e.message}";
if (errorCode == PurchasesErrorCode.purchaseNotAllowedError) {
errorMessage = 'User not allowed to purchase';
} else if (errorCode == PurchasesErrorCode.paymentPendingError) {
errorMessage = 'Payment is pending';
} else if (errorCode == PurchasesErrorCode.productAlreadyPurchasedError) {
errorMessage = 'User already subscribed';
}
if (errorCode != PurchasesErrorCode.purchaseCancelledError) {
WidgetUtils.showMessage(context, "Purchase Error", errorMessage);
}
}
}