validateSubscription method
bool
validateSubscription(
- PurchaseDetails purchaseDetails
)
Implementation
bool validateSubscription(PurchaseDetails purchaseDetails) {
DateTime currentTime = DateTime.now();
DateTime purchaseDate = DateTime.fromMillisecondsSinceEpoch(
int.parse(purchaseDetails.transactionDate ?? "0"),
).add(Duration(
days: purchaseDetails.productID == "weekly_pack"
? 7
: purchaseDetails.productID == "monthly_pack_1"
? 30
: purchaseDetails.productID == "yearly_pack_2"
? 365
: 0,
));
log(purchaseDate.toString());
return purchaseDate.isAfter(currentTime);
}