mnemo_cards/lib/features/purchase/rustore/mnemo_rustore.dart
2024-08-05 03:12:20 +03:00

110 lines
3.7 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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;
// }
// }