fix: some problems are fixed
This commit is contained in:
@@ -114,8 +114,8 @@ Future<void> setupLocator() async {
|
||||
locator.registerFactory<AuthBloc>(
|
||||
() => AuthBloc(locator(), locator(), locator(), locator()));
|
||||
locator.registerFactory<WalletBloc>(() => WalletBloc(locator(), locator()));
|
||||
locator.registerFactory<ShopBloc>(() => ShopBloc(
|
||||
locator(), locator(), locator(), locator(), locator(), locator()));
|
||||
locator.registerFactory<ShopBloc>(() => ShopBloc(locator(), locator(),
|
||||
locator(), locator(), locator(), locator(), locator()));
|
||||
locator.registerFactory<ProfileBloc>(
|
||||
() => ProfileBloc(locator(), locator()));
|
||||
locator.registerFactory<LeaderboardBloc>(() => LeaderboardBloc(locator()));
|
||||
|
||||
@@ -21,12 +21,12 @@ class BazaarPaymentGateway implements PaymentGateway {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> purchase(String productSku) async {
|
||||
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||
try {
|
||||
await connect();
|
||||
final info = await FlutterPoolakey.purchase(
|
||||
productSku,
|
||||
payload: 'hakemsho',
|
||||
payload: payload.isNotEmpty ? payload : 'hakemsho',
|
||||
);
|
||||
if (info.purchaseToken.isEmpty) {
|
||||
return const PurchaseResult.failure();
|
||||
|
||||
@@ -11,7 +11,7 @@ class DevPaymentGateway implements PaymentGateway {
|
||||
Future<void> connect() async {}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> purchase(String productSku) async {
|
||||
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||
final stamp = DateTime.now().millisecondsSinceEpoch;
|
||||
return PurchaseResult.success(
|
||||
token: 'dev-$productSku-$stamp',
|
||||
|
||||
@@ -19,10 +19,12 @@ class MyketPaymentGateway implements PaymentGateway {
|
||||
}
|
||||
|
||||
@override
|
||||
Future<PurchaseResult> purchase(String productSku) async {
|
||||
Future<PurchaseResult> purchase(String productSku, {String payload = ''}) async {
|
||||
await connect();
|
||||
final Map<dynamic, dynamic> result =
|
||||
await MyketIAP.launchPurchaseFlow(sku: productSku, payload: 'hakemsho');
|
||||
final Map<dynamic, dynamic> result = await MyketIAP.launchPurchaseFlow(
|
||||
sku: productSku,
|
||||
payload: payload.isNotEmpty ? payload : 'hakemsho',
|
||||
);
|
||||
|
||||
final Purchase? purchase = result[MyketIAP.PURCHASE] as Purchase?;
|
||||
if (purchase == null || purchase.mToken.isEmpty) {
|
||||
|
||||
@@ -33,7 +33,9 @@ abstract class PaymentGateway {
|
||||
String get store;
|
||||
|
||||
/// جریانِ خریدِ [productSku] (همان UUIDِ محصول در پنلِ فروشگاه) را باز میکند.
|
||||
Future<PurchaseResult> purchase(String productSku);
|
||||
/// [payload] در فروشگاه ذخیره و در پنلِ توسعهدهنده نمایش داده میشود؛ اینجا
|
||||
/// شمارهی موبایلِ کاربر را میفرستیم تا خرید قابلِ ردیابی باشد.
|
||||
Future<PurchaseResult> purchase(String productSku, {String payload = ''});
|
||||
|
||||
/// اتصالِ اولیه (در صورتِ نیاز). پیش از اولین خرید صدا زده میشود.
|
||||
Future<void> connect() async {}
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
import 'package:flutter_secure_storage/flutter_secure_storage.dart';
|
||||
|
||||
/// ذخیرهی امن توکن JWT.
|
||||
/// ذخیرهی امن توکن JWT و شمارهی موبایلِ کاربر.
|
||||
class TokenStorage {
|
||||
static const _key = 'jwt_token';
|
||||
static const _mobileKey = 'user_mobile';
|
||||
final FlutterSecureStorage _storage;
|
||||
|
||||
TokenStorage([FlutterSecureStorage? storage])
|
||||
@@ -12,5 +13,13 @@ class TokenStorage {
|
||||
|
||||
Future<void> write(String token) => _storage.write(key: _key, value: token);
|
||||
|
||||
Future<void> clear() => _storage.delete(key: _key);
|
||||
Future<String?> readMobile() => _storage.read(key: _mobileKey);
|
||||
|
||||
Future<void> writeMobile(String mobile) =>
|
||||
_storage.write(key: _mobileKey, value: mobile);
|
||||
|
||||
Future<void> clear() async {
|
||||
await _storage.delete(key: _key);
|
||||
await _storage.delete(key: _mobileKey);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user