fix: some problems are fixed
This commit is contained in:
@@ -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');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user