import 'package:flutter/foundation.dart'; /// Normalized purchase status reported by the store. enum StorePurchaseStatus { pending, purchased, restored, canceled, error } /// Store-neutral representation of a catalog product queried from Google Play. @immutable class StoreProduct { final String id; final String title; final String description; final String price; final double rawPrice; final String currencyCode; final String currencySymbol; final bool isSubscription; const StoreProduct({ required this.id, required this.title, required this.description, required this.price, required this.rawPrice, required this.currencyCode, this.currencySymbol = '', this.isSubscription = false, }); @override bool operator ==(Object other) => identical(this, other) || other is StoreProduct && runtimeType == other.runtimeType && id == other.id && price == other.price && currencyCode == other.currencyCode; @override int get hashCode => id.hashCode ^ price.hashCode ^ currencyCode.hashCode; } /// Store-neutral purchase transaction emitted by the billing stream. @immutable class StorePurchase { final String purchaseId; final String productId; final StorePurchaseStatus status; final String transactionDate; final String? purchaseToken; final String? purchaseTokenHash; final bool pendingCompletePurchase; final String? errorMessage; final Object? originalPayload; const StorePurchase({ required this.purchaseId, required this.productId, required this.status, required this.transactionDate, this.purchaseToken, this.purchaseTokenHash, this.pendingCompletePurchase = false, this.errorMessage, this.originalPayload, }); @override bool operator ==(Object other) => identical(this, other) || other is StorePurchase && runtimeType == other.runtimeType && purchaseId == other.purchaseId && productId == other.productId && status == other.status && purchaseTokenHash == other.purchaseTokenHash; @override int get hashCode => purchaseId.hashCode ^ productId.hashCode ^ status.hashCode ^ purchaseTokenHash.hashCode; } /// Failure details encountered during store queries or operations. @immutable class BillingFailure { final String code; final String message; final Object? details; const BillingFailure({ required this.code, required this.message, this.details, }); @override String toString() => 'BillingFailure(code: $code, message: $message)'; }