IMPS implementation
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
// ignore_for_file: use_build_context_synchronously
|
||||
|
||||
import 'dart:async';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:kmobile/api/services/imps_service.dart';
|
||||
import 'package:kmobile/api/services/neft_service.dart';
|
||||
import 'package:kmobile/api/services/rtgs_service.dart';
|
||||
import 'package:kmobile/data/models/imps_transaction.dart';
|
||||
import 'package:kmobile/data/models/neft_transaction.dart';
|
||||
import 'package:kmobile/data/models/payment_response.dart';
|
||||
import 'package:kmobile/data/models/rtgs_transaction.dart';
|
||||
@@ -118,6 +122,7 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
return [
|
||||
AppLocalizations.of(context).neft,
|
||||
AppLocalizations.of(context).rtgs,
|
||||
AppLocalizations.of(context).imps,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -151,6 +156,8 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
final amount = double.tryParse(amountController.text) ?? 0;
|
||||
final selectedMode = transactionModes(context)[selectedTransactionIndex];
|
||||
final isRtgs = selectedMode == AppLocalizations.of(context).rtgs;
|
||||
final isNeft = selectedMode == AppLocalizations.of(context).neft;
|
||||
final isImps = selectedMode == AppLocalizations.of(context).imps;
|
||||
|
||||
if (isRtgs && amount < 200000) {
|
||||
showDialog(
|
||||
@@ -174,14 +181,14 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => TransactionPinScreen(
|
||||
onPinCompleted: (pinScreenContext, tpin) async {
|
||||
if (!isRtgs) {
|
||||
if (isNeft) {
|
||||
// NEFT
|
||||
final neftTx = NeftTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
@@ -214,14 +221,58 @@ class _QuickPayOutsideBankScreen extends State<QuickPayOutsideBankScreen> {
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (isImps) {
|
||||
// IMPS
|
||||
final impsTx = ImpsTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
final impsService = getIt<ImpsService>();
|
||||
final completer = Completer<PaymentResponse>();
|
||||
|
||||
Navigator.of(pinScreenContext).pushReplacement(
|
||||
MaterialPageRoute(
|
||||
builder: (_) => PaymentAnimationScreen(
|
||||
paymentResponse: completer.future),
|
||||
),
|
||||
);
|
||||
|
||||
try {
|
||||
final neftResponse =
|
||||
await impsService.processImpsTransaction(impsTx);
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: neftResponse.message.toUpperCase() == 'SUCCESS',
|
||||
date: DateTime.now(),
|
||||
creditedAccount: impsTx.toAccount,
|
||||
amount: impsTx.amount,
|
||||
currency: 'INR',
|
||||
utr: neftResponse.utr,
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
} catch (e) {
|
||||
final paymentResponse = PaymentResponse(
|
||||
isSuccess: false,
|
||||
errorMessage: e.toString(),
|
||||
);
|
||||
completer.complete(paymentResponse);
|
||||
}
|
||||
}
|
||||
|
||||
if(isRtgs) {
|
||||
// RTGS
|
||||
final rtgsTx = RtgsTransaction(
|
||||
fromAccount: widget.debitAccount,
|
||||
toAccount: accountNumberController.text,
|
||||
amount: amountController.text,
|
||||
ifscCode: ifscController.text,
|
||||
remitterName: "Unknown", // TODO: Get actual remitter name
|
||||
remitterName: "Unknown",
|
||||
beneficiaryName: nameController.text,
|
||||
tpin: tpin,
|
||||
);
|
||||
|
Reference in New Issue
Block a user