fix: some problems are fixed

This commit is contained in:
2026-07-05 18:40:53 +03:30
parent 5017e9a613
commit e94f03c499
16 changed files with 384 additions and 152 deletions
@@ -1,6 +1,7 @@
import 'package:flutter_bloc/flutter_bloc.dart';
import '../../../../core/payment/payment_gateway.dart';
import '../../../../core/storage/token_storage.dart';
import '../../../../core/resources/data_state.dart';
import '../../../../core/usecase/use_case.dart';
import '../../domain/use_cases/ad_reward_usecase.dart';
@@ -19,6 +20,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
final PurchaseUseCase purchaseUseCase;
final AdRewardUseCase adRewardUseCase;
final PaymentGateway gateway;
final TokenStorage storage;
ShopBloc(
this.getShopUseCase,
@@ -27,6 +29,7 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
this.purchaseUseCase,
this.adRewardUseCase,
this.gateway,
this.storage,
) : super(ShopBlocState.initial()) {
on<LoadShopEvent>((event, emit) => _load(emit));
@@ -59,9 +62,13 @@ class ShopBloc extends Bloc<ShopEvent, ShopBlocState> {
// شناسه‌ی کاتالوگ استفاده می‌کنیم (حالتِ توسعه/تک‌فروشگاهی).
final sku = event.sku.isNotEmpty ? event.sku : event.productId;
// شماره‌ی موبایل را به‌عنوان payload می‌فرستیم تا خرید در پنلِ فروشگاه
// قابلِ ردیابی باشد.
final mobile = await storage.readMobile() ?? '';
final PurchaseResult result;
try {
result = await gateway.purchase(sku);
result = await gateway.purchase(sku, payload: mobile);
} catch (e) {
return DataError<String>('خطا در پرداخت: $e');
}