Add pop to inform if payment is ok or not
This commit is contained in:
parent
c68e152040
commit
5504cb0b17
|
@ -50,20 +50,14 @@ class HistoryProvider with ChangeNotifier {
|
|||
return barcode;
|
||||
}
|
||||
|
||||
void pay(BuildContext context, String pinCode) {
|
||||
Future<String> pay(BuildContext context, String pinCode) async {
|
||||
// MyWalletsProvider _myWalletProvider = MyWalletsProvider();
|
||||
String dewif =
|
||||
File(walletsDirectory.path + '/${defaultWallet.chest}/wallet.dewif')
|
||||
.readAsLinesSync()[0];
|
||||
List dewifList = await File(
|
||||
walletsDirectory.path + '/${defaultWallet.chest}/wallet.dewif')
|
||||
.readAsLines();
|
||||
String dewif = dewifList[0];
|
||||
try {
|
||||
print(defaultWallet.derivation);
|
||||
print(payAmount.text);
|
||||
print(payComment.text);
|
||||
print(dewif);
|
||||
print(endPointGVA);
|
||||
print(pinCode);
|
||||
print(pubkey);
|
||||
DubpRust.simplePaymentFromTransparentAccount(
|
||||
await DubpRust.simplePaymentFromTransparentAccount(
|
||||
accountIndex: defaultWallet.derivation,
|
||||
amount: double.parse(payAmount.text),
|
||||
txComment: payComment.text,
|
||||
|
@ -71,9 +65,11 @@ class HistoryProvider with ChangeNotifier {
|
|||
gvaEndpoint: endPointGVA,
|
||||
secretCode: pinCode,
|
||||
recipient: pubkey);
|
||||
return "Success";
|
||||
} catch (e) {
|
||||
log.e("ERROR DUBP PAYMENTS");
|
||||
log.e(e);
|
||||
return "Payments errors: $e";
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,6 +133,7 @@ class HistoryProvider with ChangeNotifier {
|
|||
return pubkeyShort;
|
||||
}
|
||||
|
||||
// poka: Do99s6wQR2JLfhirPdpAERSjNbmjjECzGxHNJMiNKT3P
|
||||
// Pi: D2meevcAHFTS2gQMvmRW5Hzi25jDdikk4nC4u1FkwRaU // For debug
|
||||
// Boris: JE6mkuzSpT3ePciCPRTpuMT9fqPUVVLJz2618d33p7tn
|
||||
// Matograine portefeuille: 9p5nHsES6xujFR7pw2yGy4PLKKHgWsMvsDHaHF64Uj25.
|
||||
|
|
|
@ -24,6 +24,7 @@ class UnlockingWallet extends StatelessWidget {
|
|||
bool hasError = false;
|
||||
var pinColor = Color(0xffF9F9F1);
|
||||
var walletPin = '';
|
||||
String resultPay;
|
||||
|
||||
Future<NewWallet> get badWallet => null;
|
||||
|
||||
|
@ -148,7 +149,9 @@ class UnlockingWallet extends StatelessWidget {
|
|||
Navigator.pushNamed(formKey.currentContext, '/mywallets');
|
||||
} else if (action == "pay") {
|
||||
print("Go payments");
|
||||
_historyProvider.pay(context, _pin.toUpperCase());
|
||||
resultPay =
|
||||
await _historyProvider.pay(context, _pin.toUpperCase());
|
||||
await _paymentsResult(context);
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -160,4 +163,30 @@ class UnlockingWallet extends StatelessWidget {
|
|||
)),
|
||||
);
|
||||
}
|
||||
|
||||
Future<bool> _paymentsResult(context) {
|
||||
return showDialog<bool>(
|
||||
context: context,
|
||||
barrierDismissible: true, // user must tap button!
|
||||
builder: (BuildContext context) {
|
||||
return AlertDialog(
|
||||
title: Text(resultPay == "Success"
|
||||
? 'Paiement effecuté avec succès !'
|
||||
: "Une erreur s'est produite lors du paiement"),
|
||||
content: SingleChildScrollView(child: Text('')),
|
||||
actions: <Widget>[
|
||||
TextButton(
|
||||
child: Text("OK"),
|
||||
onPressed: () {
|
||||
Navigator.popUntil(
|
||||
context,
|
||||
ModalRoute.withName('/'),
|
||||
);
|
||||
},
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue