stuff
This commit is contained in:
parent
4aed336b51
commit
67cfa49e2d
8 changed files with 128 additions and 136 deletions
|
|
@ -3,7 +3,6 @@ import 'dart:developer';
|
|||
import 'dart:io';
|
||||
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_rustore_billing/pigeons/rustore.dart';
|
||||
import 'package:in_app_purchase/in_app_purchase.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
import 'package:url_launcher/url_launcher_string.dart';
|
||||
|
|
@ -31,7 +30,8 @@ class InAppPurchaseService {
|
|||
Future<bool> buyPack(CardPackBuyDto dto) async {
|
||||
try {
|
||||
if (RUSTORE_BUILD) {
|
||||
return RustorePurchaseService().buyPack(dto);
|
||||
// return RustorePurchaseService().buyPack(dto);
|
||||
return false;
|
||||
} else {
|
||||
final pack = await _getPackStoreProduct(dto);
|
||||
final result = await _buyItemInStore(pack.first);
|
||||
|
|
|
|||
|
|
@ -1,112 +1,110 @@
|
|||
import 'dart:developer';
|
||||
|
||||
import 'package:auto_route/auto_route.dart';
|
||||
import 'package:flutter_rustore_billing/flutter_rustore_billing.dart';
|
||||
import 'package:mnemo_cards/features/analytics/analytics.dart';
|
||||
import 'package:mnemo_cards/flags.dart';
|
||||
import 'package:mnemo_cards/main.dart';
|
||||
import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
|
||||
import '../../../di/locator.dart';
|
||||
import '../../../domain/router/dialogs.dart';
|
||||
|
||||
class RustorePurchaseService {
|
||||
Future<bool> init() async {
|
||||
return RustoreBillingClient.initialize(
|
||||
"2063563896",
|
||||
"mnemocards://iamback",
|
||||
true,
|
||||
).then((value) {
|
||||
print("initialize success: $value");
|
||||
return true;
|
||||
}, onError: (err) {
|
||||
print("initialize err: $err");
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
Future<bool> buyPack(CardPackBuyDto dto) async {
|
||||
if (dto.rustoreId == null) {
|
||||
return false;
|
||||
}
|
||||
if (!await init()) {
|
||||
return false;
|
||||
}
|
||||
if (!await RustoreBillingClient.available().then((value) {
|
||||
print("available success $value");
|
||||
return true;
|
||||
}, onError: (err) {
|
||||
print("available err: $err");
|
||||
return false;
|
||||
})) {
|
||||
return false;
|
||||
}
|
||||
final product = (await RustoreBillingClient.products([dto.rustoreId]))
|
||||
.products
|
||||
.firstOrNull;
|
||||
if (product == null) {
|
||||
return false;
|
||||
}
|
||||
try {
|
||||
final result = await RustoreBillingClient.purchase(dto.rustoreId!, null);
|
||||
try {
|
||||
try {
|
||||
// creating payment to check it later
|
||||
// in case there will be an error after confirmation
|
||||
await locator.repository.checkPayment(
|
||||
itemId: result.successPurchase!.productId,
|
||||
key: result.successPurchase!.subscriptionToken!,
|
||||
paymentSystem: androidPaymentSystem,
|
||||
);
|
||||
} catch (e, s) {
|
||||
Analytics.buyError(
|
||||
dto,
|
||||
PaymentSystem.rustore,
|
||||
message: 'Error when creating payment',
|
||||
);
|
||||
log('Error when creating payment', error: e, stackTrace: s);
|
||||
showErrorDialog(
|
||||
'Технические шоколадки...\n\nПопробуйте позже или обновите приложение до последней версии');
|
||||
return false;
|
||||
}
|
||||
final p = await RustoreBillingClient.confirm(
|
||||
result.successPurchase!.subscriptionToken!,
|
||||
);
|
||||
if (p.success) {
|
||||
final r = await locator.repository.checkPayment(
|
||||
itemId: result.successPurchase!.productId,
|
||||
key: result.successPurchase!.subscriptionToken!,
|
||||
paymentSystem: androidPaymentSystem,
|
||||
);
|
||||
if (r) {
|
||||
return r;
|
||||
} else {
|
||||
Analytics.buyError(
|
||||
dto,
|
||||
PaymentSystem.rustore,
|
||||
message: 'Error when confirming payment',
|
||||
);
|
||||
showErrorDialog(
|
||||
'Технические шоколадки...\n\nДоступ откроется в течение 5 мин',
|
||||
);
|
||||
}
|
||||
}
|
||||
} catch (e, s) {
|
||||
log('Error when confirming purchase', error: e, stackTrace: s);
|
||||
Analytics.crashlyticsError(
|
||||
e: e,
|
||||
s: s,
|
||||
message: 'Error when confirming rustore purchase',
|
||||
);
|
||||
}
|
||||
} catch (e, s) {
|
||||
log('Error when processing purchase', error: e, stackTrace: s);
|
||||
Analytics.crashlyticsError(
|
||||
e: e,
|
||||
s: s,
|
||||
message: 'Error when processing rustore purchase',
|
||||
);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// import 'dart:developer';
|
||||
//
|
||||
// import 'package:flutter_rustore_billing/flutter_rustore_billing.dart';
|
||||
// import 'package:mnemo_cards/features/analytics/analytics.dart';
|
||||
// import 'package:mnemo_cards/flags.dart';
|
||||
// import 'package:mnemo_cards_common/mnemo_cards_common.dart';
|
||||
//
|
||||
// import '../../../di/locator.dart';
|
||||
// import '../../../domain/router/dialogs.dart';
|
||||
//
|
||||
// class RustorePurchaseService {
|
||||
// Future<bool> init() async {
|
||||
// return RustoreBillingClient.initialize(
|
||||
// "2063563896",
|
||||
// "mnemocards://iamback",
|
||||
// true,
|
||||
// ).then((value) {
|
||||
// print("initialize success: $value");
|
||||
// return true;
|
||||
// }, onError: (err) {
|
||||
// print("initialize err: $err");
|
||||
// return false;
|
||||
// });
|
||||
// }
|
||||
//
|
||||
// Future<bool> buyPack(CardPackBuyDto dto) async {
|
||||
// if (dto.rustoreId == null) {
|
||||
// return false;
|
||||
// }
|
||||
// if (!await init()) {
|
||||
// return false;
|
||||
// }
|
||||
// if (!await RustoreBillingClient.available().then((value) {
|
||||
// print("available success $value");
|
||||
// return true;
|
||||
// }, onError: (err) {
|
||||
// print("available err: $err");
|
||||
// return false;
|
||||
// })) {
|
||||
// return false;
|
||||
// }
|
||||
// final product = (await RustoreBillingClient.products([dto.rustoreId]))
|
||||
// .products
|
||||
// .firstOrNull;
|
||||
// if (product == null) {
|
||||
// return false;
|
||||
// }
|
||||
// try {
|
||||
// final result = await RustoreBillingClient.purchase(dto.rustoreId!, null);
|
||||
// try {
|
||||
// try {
|
||||
// // creating payment to check it later
|
||||
// // in case there will be an error after confirmation
|
||||
// await locator.repository.checkPayment(
|
||||
// itemId: result.successPurchase!.productId,
|
||||
// key: result.successPurchase!.subscriptionToken!,
|
||||
// paymentSystem: androidPaymentSystem,
|
||||
// );
|
||||
// } catch (e, s) {
|
||||
// Analytics.buyError(
|
||||
// dto,
|
||||
// PaymentSystem.rustore,
|
||||
// message: 'Error when creating payment',
|
||||
// );
|
||||
// log('Error when creating payment', error: e, stackTrace: s);
|
||||
// showErrorDialog(
|
||||
// 'Технические шоколадки...\n\nПопробуйте позже или обновите приложение до последней версии');
|
||||
// return false;
|
||||
// }
|
||||
// final p = await RustoreBillingClient.confirm(
|
||||
// result.successPurchase!.subscriptionToken!,
|
||||
// );
|
||||
// if (p.success) {
|
||||
// final r = await locator.repository.checkPayment(
|
||||
// itemId: result.successPurchase!.productId,
|
||||
// key: result.successPurchase!.subscriptionToken!,
|
||||
// paymentSystem: androidPaymentSystem,
|
||||
// );
|
||||
// if (r) {
|
||||
// return r;
|
||||
// } else {
|
||||
// Analytics.buyError(
|
||||
// dto,
|
||||
// PaymentSystem.rustore,
|
||||
// message: 'Error when confirming payment',
|
||||
// );
|
||||
// showErrorDialog(
|
||||
// 'Технические шоколадки...\n\nДоступ откроется в течение 5 мин',
|
||||
// );
|
||||
// }
|
||||
// }
|
||||
// } catch (e, s) {
|
||||
// log('Error when confirming purchase', error: e, stackTrace: s);
|
||||
// Analytics.crashlyticsError(
|
||||
// e: e,
|
||||
// s: s,
|
||||
// message: 'Error when confirming rustore purchase',
|
||||
// );
|
||||
// }
|
||||
// } catch (e, s) {
|
||||
// log('Error when processing purchase', error: e, stackTrace: s);
|
||||
// Analytics.crashlyticsError(
|
||||
// e: e,
|
||||
// s: s,
|
||||
// message: 'Error when processing rustore purchase',
|
||||
// );
|
||||
// }
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
|
|
|
|||
|
|
@ -76,7 +76,7 @@ class _ProgressWidgetState extends State<ProgressWidget> {
|
|||
widget.popText!,
|
||||
style: TextStyle(
|
||||
fontSize: 16,
|
||||
fontWeight: FontWeight.w400,
|
||||
fontWeight: FontWeight.w700,
|
||||
),
|
||||
),
|
||||
),
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
import 'package:auto_size_text/auto_size_text.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_screenutil/flutter_screenutil.dart';
|
||||
import 'package:mnemo_cards/managers/audio_player.dart';
|
||||
|
|
@ -73,7 +74,7 @@ class CommonTestQuestionWidget extends StatelessWidget {
|
|||
),
|
||||
),
|
||||
),
|
||||
if (text != null)
|
||||
if (text != null && audio != null)
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
|
|
@ -100,6 +101,16 @@ class CommonTestQuestionWidget extends StatelessWidget {
|
|||
)
|
||||
],
|
||||
),
|
||||
)
|
||||
else if (text != null)
|
||||
Container(
|
||||
alignment: Alignment.center,
|
||||
padding: const EdgeInsets.only(top: 8.0),
|
||||
child: AutoSizeText(
|
||||
text!,
|
||||
style: theme.headlineLarge,
|
||||
textAlign: TextAlign.center,
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@ class FirebaseRepository {
|
|||
static ConfigModel? _lastConfig;
|
||||
|
||||
static ConfigModel get appConfig {
|
||||
update();
|
||||
// update();
|
||||
return _lastConfig!;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -181,7 +181,6 @@ class _BuyButton extends StatelessWidget {
|
|||
height: 120.h,
|
||||
alignment: Alignment.center,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.white,
|
||||
border: Border.all(color: borderGray),
|
||||
borderRadius: BorderRadius.circular(16.0),
|
||||
),
|
||||
|
|
|
|||
16
pubspec.lock
16
pubspec.lock
|
|
@ -494,14 +494,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.0.20"
|
||||
flutter_rustore_billing:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
name: flutter_rustore_billing
|
||||
sha256: "95905fec5ab46f7d0e798469c847423aa4dac07461a6111892be3f34c48a5b75"
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "6.0.1"
|
||||
flutter_screenutil:
|
||||
dependency: "direct main"
|
||||
description:
|
||||
|
|
@ -624,14 +616,6 @@ packages:
|
|||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "2.1.2"
|
||||
go_router:
|
||||
dependency: transitive
|
||||
description:
|
||||
name: go_router
|
||||
sha256: b465e99ce64ba75e61c8c0ce3d87b66d8ac07f0b35d0a7e0263fcfc10f99e836
|
||||
url: "https://pub.dev"
|
||||
source: hosted
|
||||
version: "13.2.5"
|
||||
google_identity_services_web:
|
||||
dependency: transitive
|
||||
description:
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ name: mnemo_cards
|
|||
description: Mnemo
|
||||
publish_to: 'none'
|
||||
|
||||
version: 1.0.2+15
|
||||
version: 1.0.2+16
|
||||
|
||||
environment:
|
||||
sdk: '>=3.1.3 <4.0.0'
|
||||
|
|
@ -65,7 +65,7 @@ dependencies:
|
|||
url_launcher: ^6.2.6
|
||||
|
||||
# RUSTORE
|
||||
flutter_rustore_billing: ^6.0.1
|
||||
# flutter_rustore_billing: ^6.0.1
|
||||
|
||||
collection: any
|
||||
freezed_annotation: any
|
||||
|
|
|
|||
Loading…
Reference in a new issue