prototype complete
This commit is contained in:
115
lib/screens/transaction_controller.dart
Normal file
115
lib/screens/transaction_controller.dart
Normal file
@@ -0,0 +1,115 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||
import 'package:qpay/screens/pay/pay_controller.dart';
|
||||
import 'package:qpay/screens/home/home_controller.dart';
|
||||
|
||||
part 'transaction_controller.freezed.dart';
|
||||
part 'transaction_controller.g.dart';
|
||||
|
||||
class TransactionModel {
|
||||
late Map<String, dynamic> confirmationData;
|
||||
late PaymentProcessor selectedPaymentProcessor;
|
||||
late FormData repeatFormData;
|
||||
|
||||
BillProduct? selectedProduct;
|
||||
BillProvider? selectedProvider;
|
||||
Map<String, dynamic>? receiptData;
|
||||
FormData formData = FormData(
|
||||
type: '',
|
||||
billClientId: '',
|
||||
debitRef: '',
|
||||
debitCurrency: '',
|
||||
amount: '',
|
||||
debitPhone: '',
|
||||
debitAccount: '',
|
||||
creditAccount: '',
|
||||
creditPhone: '',
|
||||
creditName: '',
|
||||
creditEmail: '',
|
||||
billName: '',
|
||||
errorMessage: '',
|
||||
status: 'PENDING',
|
||||
paymentProcessorLabel: '',
|
||||
charge: '',
|
||||
gatewayCharge: '',
|
||||
tax: '',
|
||||
totalAmount: '',
|
||||
paymentProcessorName: '',
|
||||
paymentProcessorImage: '',
|
||||
providerImage: '',
|
||||
userId: '',
|
||||
providerLabel: '',
|
||||
);
|
||||
|
||||
String? errorMessage;
|
||||
}
|
||||
|
||||
@freezed
|
||||
abstract class FormData with _$FormData {
|
||||
const factory FormData({
|
||||
required String type, // CONFIRM, REQUEST, REVERSE
|
||||
required String billClientId,
|
||||
required String debitRef,
|
||||
required String debitCurrency,
|
||||
required String amount,
|
||||
required String creditAccount,
|
||||
required String? creditPhone,
|
||||
required String? creditName,
|
||||
required String? creditEmail,
|
||||
required String billName,
|
||||
required String? errorMessage,
|
||||
required String status,
|
||||
required String paymentProcessorLabel,
|
||||
required String paymentProcessorName,
|
||||
required String paymentProcessorImage,
|
||||
required String providerImage,
|
||||
required String providerLabel,
|
||||
required String userId,
|
||||
String? debitPhone,
|
||||
String? debitAccount,
|
||||
String? productUid,
|
||||
String? trace,
|
||||
String? authType,
|
||||
String? charge,
|
||||
String? gatewayCharge,
|
||||
String? tax,
|
||||
String? totalAmount,
|
||||
}) = _FormData;
|
||||
|
||||
factory FormData.fromJson(Map<String, dynamic> json) =>
|
||||
_$FormDataFromJson(json);
|
||||
}
|
||||
|
||||
class TransactionController extends ChangeNotifier {
|
||||
TransactionModel model = TransactionModel();
|
||||
|
||||
updateSelectedProvider(BillProvider provider) {
|
||||
model.selectedProvider = provider;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateSelectedProduct(BillProduct product) {
|
||||
model.selectedProduct = product;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateSelectedPaymentProcessor(PaymentProcessor processor) {
|
||||
model.selectedPaymentProcessor = processor;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateConfirmationData(Map<String, dynamic> data) {
|
||||
model.confirmationData = data;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateReceiptData(Map<String, dynamic> data) {
|
||||
model.receiptData = data;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
updateRepeatFormData(FormData data) {
|
||||
model.repeatFormData = data;
|
||||
notifyListeners();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user