mirror of
https://github.com/cake-tech/cake_wallet.git
synced 2025-01-23 11:15:33 +00:00
Add payment status update for ionia.
This commit is contained in:
parent
ce479849ea
commit
3b61edcc5a
13 changed files with 423 additions and 20 deletions
15
lib/di.dart
15
lib/di.dart
|
@ -146,6 +146,10 @@ import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart';
|
|||
import 'package:cake_wallet/ionia/ionia_token_service.dart';
|
||||
import 'package:cake_wallet/anypay/anypay_api.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_gift_card_details_view_model.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_payment_status_page.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_payment_status_view_model.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
|
||||
final getIt = GetIt.instance;
|
||||
|
||||
|
@ -741,5 +745,16 @@ Future setup(
|
|||
|
||||
getIt.registerFactory(() => IoniaAccountCardsPage(getIt.get<IoniaAccountViewModel>()));
|
||||
|
||||
getIt.registerFactoryParam<IoniaPaymentStatusViewModel, IoniaAnyPayPaymentInfo, AnyPayPaymentCommittedInfo>(
|
||||
(IoniaAnyPayPaymentInfo paymentInfo, AnyPayPaymentCommittedInfo committedInfo)
|
||||
=> IoniaPaymentStatusViewModel(
|
||||
getIt.get<IoniaService>(),
|
||||
paymentInfo: paymentInfo,
|
||||
committedInfo: committedInfo));
|
||||
|
||||
getIt.registerFactoryParam<IoniaPaymentStatusPage, IoniaAnyPayPaymentInfo, AnyPayPaymentCommittedInfo>(
|
||||
(IoniaAnyPayPaymentInfo paymentInfo, AnyPayPaymentCommittedInfo committedInfo)
|
||||
=> IoniaPaymentStatusPage(getIt.get<IoniaPaymentStatusViewModel>(param1: paymentInfo, param2: committedInfo)));
|
||||
|
||||
_isSetupFinished = true;
|
||||
}
|
||||
|
|
9
lib/ionia/ionia_any_pay_payment_info.dart
Normal file
9
lib/ionia/ionia_any_pay_payment_info.dart
Normal file
|
@ -0,0 +1,9 @@
|
|||
import 'package:cake_wallet/anypay/any_pay_payment.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_order.dart';
|
||||
|
||||
class IoniaAnyPayPaymentInfo {
|
||||
const IoniaAnyPayPaymentInfo(this.ioniaOrder, this.anyPayPayment);
|
||||
|
||||
final IoniaOrder ioniaOrder;
|
||||
final AnyPayPayment anyPayPayment;
|
||||
}
|
|
@ -13,6 +13,8 @@ import 'package:cake_wallet/anypay/any_pay_trasnaction.dart';
|
|||
import 'package:cake_wallet/bitcoin/bitcoin.dart';
|
||||
import 'package:cake_wallet/monero/monero.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_order.dart';
|
||||
|
||||
class IoniaAnyPay {
|
||||
IoniaAnyPay(this.ioniaService, this.anyPayApi, this.wallet);
|
||||
|
@ -21,14 +23,15 @@ class IoniaAnyPay {
|
|||
final AnyPayApi anyPayApi;
|
||||
final WalletBase wallet;
|
||||
|
||||
Future<AnyPayPayment> purchase({
|
||||
Future<IoniaAnyPayPaymentInfo> purchase({
|
||||
@required String merchId,
|
||||
@required double amount}) async {
|
||||
final invoice = await ioniaService.purchaseGiftCard(
|
||||
merchId: merchId,
|
||||
amount: amount,
|
||||
currency: wallet.currency.title.toUpperCase());
|
||||
return anyPayApi.paymentRequest(invoice.uri);
|
||||
final anypayPayment = await anyPayApi.paymentRequest(invoice.uri);
|
||||
return IoniaAnyPayPaymentInfo(invoice, anypayPayment);
|
||||
}
|
||||
|
||||
Future<AnyPayPaymentCommittedInfo> commitInvoice(AnyPayPayment payment) async {
|
||||
|
|
|
@ -21,6 +21,7 @@ class IoniaApi {
|
|||
static final getCurrentUserGiftCardSummariesUrl = Uri.https(baseUri, '/$pathPrefix/GetCurrentUserGiftCardSummaries');
|
||||
static final changeGiftCardUrl = Uri.https(baseUri, '/$pathPrefix/ChargeGiftCard');
|
||||
static final getGiftCardUrl = Uri.https(baseUri, '/$pathPrefix/GetGiftCard');
|
||||
static final getPaymentStatusUrl = Uri.https(baseUri, '/$pathPrefix/PaymentStatus');
|
||||
|
||||
// Create user
|
||||
|
||||
|
@ -355,4 +356,46 @@ class IoniaApi {
|
|||
final data = decodedBody['Data'] as Map<String, dynamic>;
|
||||
return IoniaGiftCard.fromJsonMap(data);
|
||||
}
|
||||
|
||||
// Payment Status
|
||||
|
||||
Future<int> getPaymentStatus({
|
||||
@required String username,
|
||||
@required String password,
|
||||
@required String clientId,
|
||||
@required String orderId,
|
||||
@required String paymentId}) async {
|
||||
final headers = <String, String>{
|
||||
'clientId': clientId,
|
||||
'username': username,
|
||||
'password': password,
|
||||
'Content-Type': 'application/json'};
|
||||
final body = <String, dynamic>{
|
||||
'order_id': orderId,
|
||||
'paymentId': paymentId};
|
||||
final response = await post(
|
||||
getPaymentStatusUrl,
|
||||
headers: headers,
|
||||
body: json.encode(body));
|
||||
|
||||
if (response.statusCode != 200) {
|
||||
throw Exception('Failed to get Payment Status for order_id ${orderId} paymentId ${paymentId};Incorrect response status: ${response.statusCode};');
|
||||
}
|
||||
|
||||
final decodedBody = json.decode(response.body) as Map<String, dynamic>;
|
||||
final isSuccessful = decodedBody['Successful'] as bool ?? false;
|
||||
|
||||
if (!isSuccessful) {
|
||||
final msg = decodedBody['ErrorMessage'] as String ?? '';
|
||||
|
||||
if (msg.isNotEmpty) {
|
||||
throw Exception(msg);
|
||||
}
|
||||
|
||||
throw Exception('Failed to get Payment Status for order_id ${orderId} paymentId ${paymentId}');
|
||||
}
|
||||
|
||||
final data = decodedBody['Data'] as Map<String, dynamic>;
|
||||
return data['gift_card_id'] as int;
|
||||
}
|
||||
}
|
|
@ -12,7 +12,7 @@ class IoniaOrder {
|
|||
uri: obj['uri'] as String,
|
||||
currency: obj['currency'] as String,
|
||||
amount: obj['amount'] as double,
|
||||
paymentId: obj['payment_id'] as String);
|
||||
paymentId: obj['paymentId'] as String);
|
||||
}
|
||||
|
||||
final String id;
|
||||
|
|
|
@ -149,4 +149,14 @@ class IoniaService {
|
|||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
return ioniaApi.getGiftCard(username: username, password: password, clientId: clientId,id: id);
|
||||
}
|
||||
|
||||
// Payment Status
|
||||
|
||||
Future<int> getPaymentStatus({
|
||||
@required String orderId,
|
||||
@required String paymentId}) async {
|
||||
final username = await secureStorage.read(key: ioniaUsernameStorageKey);
|
||||
final password = await secureStorage.read(key: ioniaPasswordStorageKey);
|
||||
return ioniaApi.getPaymentStatus(username: username, password: password, clientId: clientId, orderId: orderId, paymentId: paymentId);
|
||||
}
|
||||
}
|
|
@ -75,6 +75,9 @@ import 'package:cake_wallet/wallet_type_utils.dart';
|
|||
import 'package:cake_wallet/wallet_types.g.dart';
|
||||
import 'package:cake_wallet/src/screens/dashboard/widgets/address_page.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/ionia.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/cards/ionia_payment_status_page.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
|
||||
RouteSettings currentRouteSettings;
|
||||
|
||||
|
@ -451,6 +454,14 @@ Route<dynamic> createRoute(RouteSettings settings) {
|
|||
final args = settings.arguments as List;
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaGiftCardDetailPage>(param1: args.first));
|
||||
|
||||
case Routes.ioniaPaymentStatusPage:
|
||||
final args = settings.arguments as List;
|
||||
final paymentInfo = args.first as IoniaAnyPayPaymentInfo;
|
||||
final commitedInfo = args[1] as AnyPayPaymentCommittedInfo;
|
||||
return CupertinoPageRoute<void>(builder: (_) => getIt.get<IoniaPaymentStatusPage>(
|
||||
param1: paymentInfo,
|
||||
param2: commitedInfo));
|
||||
|
||||
default:
|
||||
return MaterialPageRoute<void>(
|
||||
builder: (_) => Scaffold(
|
||||
|
|
|
@ -73,4 +73,5 @@ class Routes {
|
|||
static const ioniaAccountCardsPage = 'ionia_account_cards_page';
|
||||
static const ioniaCustomTipPage = 'ionia_custom_tip_page';
|
||||
static const ioniaGiftCardDetailPage = '/ionia_gift_card_detail_page';
|
||||
static const ioniaPaymentStatusPage = '/ionia_payment_status_page';
|
||||
}
|
||||
|
|
|
@ -1,11 +1,11 @@
|
|||
import 'dart:ui';
|
||||
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/di.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:cake_wallet/palette.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/confirm_modal.dart';
|
||||
import 'package:cake_wallet/src/screens/ionia/widgets/text_icon_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_background.dart';
|
||||
|
@ -109,18 +109,12 @@ class IoniaBuyGiftCardDetailPage extends StatelessWidget {
|
|||
}
|
||||
|
||||
if (state is ExecutedSuccessfullyState) {
|
||||
final transactionInfo = state.payload as AnyPayPaymentCommittedInfo;
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showDialog<void>(
|
||||
context: context,
|
||||
barrierDismissible: true,
|
||||
barrierColor: PaletteDark.darkNightBlue.withOpacity(0.75),
|
||||
builder: (BuildContext context) {
|
||||
return Center(
|
||||
child: _IoniaTransactionCommitedAlert(transactionInfo: transactionInfo),
|
||||
);
|
||||
},
|
||||
);
|
||||
Navigator.of(context).pushReplacementNamed(
|
||||
Routes.ioniaPaymentStatusPage,
|
||||
arguments: [
|
||||
ioniaPurchaseViewModel.paymentInfo,
|
||||
ioniaPurchaseViewModel.committedInfo]);
|
||||
});
|
||||
}
|
||||
});
|
||||
|
|
249
lib/src/screens/ionia/cards/ionia_payment_status_page.dart
Normal file
249
lib/src/screens/ionia/cards/ionia_payment_status_page.dart
Normal file
|
@ -0,0 +1,249 @@
|
|||
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
||||
import 'package:cake_wallet/routes.dart';
|
||||
import 'package:cake_wallet/src/screens/base_page.dart';
|
||||
import 'package:cake_wallet/src/widgets/alert_with_one_action.dart';
|
||||
import 'package:cake_wallet/src/widgets/primary_button.dart';
|
||||
import 'package:cake_wallet/src/widgets/scollable_with_bottom_section.dart';
|
||||
import 'package:cake_wallet/typography.dart';
|
||||
import 'package:cake_wallet/utils/show_bar.dart';
|
||||
import 'package:cake_wallet/utils/show_pop_up.dart';
|
||||
import 'package:cake_wallet/view_model/ionia/ionia_payment_status_view_model.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:cake_wallet/generated/i18n.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:flutter_mobx/flutter_mobx.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
|
||||
class IoniaPaymentStatusPage extends BasePage {
|
||||
IoniaPaymentStatusPage(this.viewModel);
|
||||
|
||||
final IoniaPaymentStatusViewModel viewModel;
|
||||
|
||||
@override
|
||||
Widget middle(BuildContext context) {
|
||||
return Text(
|
||||
S.of(context).generating_gift_card,
|
||||
textAlign: TextAlign.center,
|
||||
style: textMediumSemiBold(
|
||||
color: Theme.of(context).accentTextTheme.display4.backgroundColor));
|
||||
}
|
||||
|
||||
@override
|
||||
Widget body(BuildContext context) {
|
||||
return _IoniaPaymentStatusPageBody(viewModel);
|
||||
}
|
||||
}
|
||||
|
||||
class _IoniaPaymentStatusPageBody extends StatefulWidget {
|
||||
_IoniaPaymentStatusPageBody(this.viewModel);
|
||||
|
||||
final IoniaPaymentStatusViewModel viewModel;
|
||||
|
||||
@override
|
||||
_IoniaPaymentStatusPageBodyBodyState createState() => _IoniaPaymentStatusPageBodyBodyState();
|
||||
}
|
||||
|
||||
class _IoniaPaymentStatusPageBodyBodyState extends State<_IoniaPaymentStatusPageBody> {
|
||||
ReactionDisposer _onErrorReaction;
|
||||
ReactionDisposer _onGiftCardReaction;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
if (widget.viewModel.giftCard != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.ioniaGiftCardDetailPage, arguments: [widget.viewModel.giftCard]);
|
||||
});
|
||||
}
|
||||
|
||||
if (widget.viewModel.error != null) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: widget.viewModel.error,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
_onErrorReaction = reaction((_) => widget.viewModel.error, (String error) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
showPopUp<void>(
|
||||
context: context,
|
||||
builder: (BuildContext context) {
|
||||
return AlertWithOneAction(
|
||||
alertTitle: S.of(context).error,
|
||||
alertContent: error,
|
||||
buttonText: S.of(context).ok,
|
||||
buttonAction: () => Navigator.of(context).pop());
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
_onGiftCardReaction = reaction((_) => widget.viewModel.giftCard, (IoniaGiftCard giftCard) {
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
Navigator.of(context)
|
||||
.pushReplacementNamed(Routes.ioniaGiftCardDetailPage, arguments: [giftCard]);
|
||||
});
|
||||
});
|
||||
|
||||
super.initState();
|
||||
}
|
||||
|
||||
@override
|
||||
void dispose() {
|
||||
_onErrorReaction?.reaction?.dispose();
|
||||
_onGiftCardReaction?.reaction?.dispose();
|
||||
widget.viewModel.timer.cancel();
|
||||
super.dispose();
|
||||
}
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return ScrollableWithBottomSection(
|
||||
contentPadding: EdgeInsets.all(24),
|
||||
content: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.green),
|
||||
height: 10,
|
||||
width: 10)),
|
||||
Text(
|
||||
S.of(context).awaiting_payment_confirmation,
|
||||
style: textLargeSemiBold(
|
||||
color: Theme.of(context).primaryTextTheme.title.color))
|
||||
]),
|
||||
SizedBox(height: 40),
|
||||
Row(children: [
|
||||
SizedBox(width: 20),
|
||||
Expanded(child:
|
||||
Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
mainAxisAlignment: MainAxisAlignment.start,
|
||||
children: [
|
||||
...widget.viewModel
|
||||
.committedInfo
|
||||
.transactions
|
||||
.map((transaction) => buildDescriptionTileWithCopy(context, S.of(context).transaction_details_transaction_id, transaction.id)),
|
||||
Divider(height: 30),
|
||||
buildDescriptionTileWithCopy(context, S.of(context).order_id, widget.viewModel.paymentInfo.ioniaOrder.id),
|
||||
Divider(height: 30),
|
||||
buildDescriptionTileWithCopy(context, S.of(context).payment_id, widget.viewModel.paymentInfo.ioniaOrder.paymentId),
|
||||
]))
|
||||
]),
|
||||
SizedBox(height: 40),
|
||||
Observer(builder: (_) {
|
||||
if (widget.viewModel.giftCard != null) {
|
||||
return Container(
|
||||
padding: EdgeInsets.only(top: 40),
|
||||
child: Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10,),
|
||||
child: Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: Colors.green),
|
||||
height: 10,
|
||||
width: 10)),
|
||||
Text(
|
||||
S.of(context).gift_card_is_generated,
|
||||
style: textLargeSemiBold(
|
||||
color: Theme.of(context).primaryTextTheme.title.color))
|
||||
]));
|
||||
}
|
||||
|
||||
return Row(children: [
|
||||
Padding(
|
||||
padding: EdgeInsets.only(right: 10),
|
||||
child: Observer(builder: (_) {
|
||||
return Container(
|
||||
decoration: BoxDecoration(
|
||||
borderRadius: BorderRadius.circular(10),
|
||||
color: widget.viewModel.giftCard == null ? Colors.grey : Colors.green),
|
||||
height: 10,
|
||||
width: 10);
|
||||
})),
|
||||
Text(
|
||||
S.of(context).generating_gift_card,
|
||||
style: textLargeSemiBold(
|
||||
color: Theme.of(context).primaryTextTheme.title.color))]);
|
||||
}),
|
||||
],
|
||||
),
|
||||
bottomSection: Padding(
|
||||
padding: EdgeInsets.only(bottom: 12),
|
||||
child: Column(children: [
|
||||
Container(
|
||||
padding: EdgeInsets.only(left: 40, right: 40, bottom: 20),
|
||||
child: Text(
|
||||
S.of(context).proceed_after_one_minute,
|
||||
style: textMedium(
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
).copyWith(fontWeight: FontWeight.w500),
|
||||
textAlign: TextAlign.center,
|
||||
)),
|
||||
Observer(builder: (_) {
|
||||
if (widget.viewModel.giftCard != null) {
|
||||
return PrimaryButton(
|
||||
onPressed: () => Navigator.of(context)
|
||||
.pushReplacementNamed(
|
||||
Routes.ioniaGiftCardDetailPage,
|
||||
arguments: [widget.viewModel.giftCard]),
|
||||
text: S.of(context).open_gift_card,
|
||||
color: Theme.of(context).accentTextTheme.body2.color,
|
||||
textColor: Colors.white);
|
||||
}
|
||||
|
||||
return PrimaryButton(
|
||||
onPressed: () => Navigator.of(context).pushNamed(Routes.support),
|
||||
text: S.of(context).contact_support,
|
||||
color: Theme.of(context).accentTextTheme.caption.color,
|
||||
textColor: Theme.of(context).primaryTextTheme.title.color);
|
||||
})
|
||||
])
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget buildDescriptionTile(BuildContext context, String title, String subtitle, VoidCallback onTap) {
|
||||
return GestureDetector(
|
||||
onTap: () => onTap(),
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
title,
|
||||
style: textXSmall(
|
||||
color: Theme.of(context).primaryTextTheme.overline.color,
|
||||
),
|
||||
),
|
||||
SizedBox(height: 8),
|
||||
Text(
|
||||
subtitle,
|
||||
style: textMedium(
|
||||
color: Theme.of(context).primaryTextTheme.title.color,
|
||||
),
|
||||
),
|
||||
],
|
||||
));
|
||||
}
|
||||
|
||||
Widget buildDescriptionTileWithCopy(BuildContext context, String title, String subtitle) {
|
||||
return buildDescriptionTile(context, title, subtitle, () {
|
||||
Clipboard.setData(ClipboardData(text: subtitle));
|
||||
showBar<void>(context,
|
||||
S.of(context).transaction_details_copied(title));
|
||||
});
|
||||
}
|
||||
}
|
58
lib/view_model/ionia/ionia_payment_status_view_model.dart
Normal file
58
lib/view_model/ionia/ionia_payment_status_view_model.dart
Normal file
|
@ -0,0 +1,58 @@
|
|||
import 'dart:async';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_service.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_gift_card.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
|
||||
part 'ionia_payment_status_view_model.g.dart';
|
||||
|
||||
class IoniaPaymentStatusViewModel = IoniaPaymentStatusViewModelBase with _$IoniaPaymentStatusViewModel;
|
||||
|
||||
abstract class IoniaPaymentStatusViewModelBase with Store {
|
||||
IoniaPaymentStatusViewModelBase(
|
||||
this.ioniaService,{
|
||||
@required this.paymentInfo,
|
||||
@required this.committedInfo}) {
|
||||
_timer = Timer.periodic(updateTime, (timer) async {
|
||||
await updatePaymentStatus();
|
||||
|
||||
if (giftCard != null) {
|
||||
timer?.cancel();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
static const updateTime = Duration(seconds: 3);
|
||||
|
||||
final IoniaService ioniaService;
|
||||
final IoniaAnyPayPaymentInfo paymentInfo;
|
||||
final AnyPayPaymentCommittedInfo committedInfo;
|
||||
|
||||
@observable
|
||||
IoniaGiftCard giftCard;
|
||||
|
||||
@observable
|
||||
String error;
|
||||
|
||||
Timer get timer => _timer;
|
||||
|
||||
Timer _timer;
|
||||
|
||||
@action
|
||||
Future<void> updatePaymentStatus() async {
|
||||
try {
|
||||
final giftCardId = await ioniaService.getPaymentStatus(
|
||||
orderId: paymentInfo.ioniaOrder.id,
|
||||
paymentId: paymentInfo.ioniaOrder.paymentId);
|
||||
|
||||
if (giftCardId != null) {
|
||||
giftCard = await ioniaService.getGiftCard(id: giftCardId);
|
||||
}
|
||||
|
||||
} catch (e) {
|
||||
error = e.toString();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,11 +1,12 @@
|
|||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment.dart';
|
||||
import 'package:cake_wallet/anypay/any_pay_payment_committed_info.dart';
|
||||
import 'package:cake_wallet/core/execution_state.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_anypay.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_merchant.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_tip.dart';
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:mobx/mobx.dart';
|
||||
import 'package:cake_wallet/ionia/ionia_any_pay_payment_info.dart';
|
||||
|
||||
part 'ionia_purchase_merch_view_model.g.dart';
|
||||
|
||||
|
@ -38,7 +39,9 @@ abstract class IoniaMerchPurchaseViewModelBase with Store {
|
|||
|
||||
final IoniaAnyPay ioniaAnyPayService;
|
||||
|
||||
AnyPayPayment invoice;
|
||||
IoniaAnyPayPaymentInfo paymentInfo;
|
||||
|
||||
AnyPayPayment get invoice => paymentInfo?.anyPayPayment;
|
||||
|
||||
AnyPayPaymentCommittedInfo committedInfo;
|
||||
|
||||
|
@ -67,7 +70,7 @@ abstract class IoniaMerchPurchaseViewModelBase with Store {
|
|||
Future<void> createInvoice() async {
|
||||
try {
|
||||
invoiceCreationState = IsExecutingState();
|
||||
invoice = await ioniaAnyPayService.purchase(merchId: ioniaMerchant.id.toString(), amount: giftCardAmount);
|
||||
paymentInfo = await ioniaAnyPayService.purchase(merchId: ioniaMerchant.id.toString(), amount: giftCardAmount);
|
||||
invoiceCreationState = ExecutedSuccessfullyState();
|
||||
} catch (e) {
|
||||
invoiceCreationState = FailureState(e.toString());
|
||||
|
|
|
@ -620,5 +620,12 @@
|
|||
"awaiting_payment_confirmation": "Awaiting payment confirmation",
|
||||
"transaction_sent_notice": "If the screen doesn’t proceed after 1 minute, check a block explorer and your email.",
|
||||
"agree": "Agree",
|
||||
"in_store": "In Store"
|
||||
"in_store": "In Store",
|
||||
"generating_gift_card": "Generating Gift Card",
|
||||
"payment_was_received": "Your payment was received.",
|
||||
"proceed_after_one_minute": "If the screen doesn’t proceed after 1 minute, check your email.",
|
||||
"order_id": "Order ID",
|
||||
"gift_card_is_generated": "Gift Card is generated",
|
||||
"open_gift_card": "Open Gift Card",
|
||||
"contact_support": "Contact Support"
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue