Commit 0515ce45 authored by Sai Srinivas's avatar Sai Srinivas
Browse files

Razorpay setup

parents f3a137b2 f693e7f1
class TransactionListResponse {
String? error;
String? balanceAmount;
String? balanceType;
String? totalCredit;
String? totalDebit;
Map<String, List<TransactionItem>>? transactions;
String? message;
TransactionListResponse({
this.error,
this.balanceAmount,
this.balanceType,
this.totalCredit,
this.totalDebit,
this.transactions,
this.message,
});
TransactionListResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
balanceAmount = json['balance_amount'];
balanceType = json['balance_type'];
totalCredit = json['total_credit'];
totalDebit = json['total_debit'];
message = json['message'];
if (json['transactions'] != null) {
transactions = {};
json['transactions'].forEach((key, value) {
transactions![key] = List<TransactionItem>.from(
value.map((v) => TransactionItem.fromJson(v)),
);
});
}
}
Map<String, dynamic> toJson() {
final data = <String, dynamic>{};
data['error'] = error;
data['balance_amount'] = balanceAmount;
data['balance_type'] = balanceType;
data['total_credit'] = totalCredit;
data['total_debit'] = totalDebit;
data['message'] = message;
if (transactions != null) {
data['transactions'] = transactions!.map((key, value) =>
MapEntry(key, value.map((v) => v.toJson()).toList()));
}
return data;
}
}
class TransactionItem {
String? id;
String? billId;
String? atype;
String? type;
String? datetime;
String? cAmount;
String? dAmount;
String? narration;
TransactionItem({
this.id,
this.billId,
this.atype,
this.type,
this.datetime,
this.cAmount,
this.dAmount,
this.narration,
});
TransactionItem.fromJson(Map<String, dynamic> json) {
id = json['id'];
billId = json['bill_id'];
atype = json['atype'];
type = json['type'];
datetime = json['datetime'];
cAmount = json['c_amount'];
dAmount = json['d_amount'];
narration = json['narration'];
}
Map<String, dynamic> toJson() => {
'id': id,
'bill_id': billId,
'atype': atype,
'type': type,
'datetime': datetime,
'c_amount': cAmount,
'd_amount': dAmount,
'narration': narration,
};
}
// class TransactionListResponse {
// String? error;
// String? balanceAmount;
// String? balanceType;
// String? totalCredit;
// String? totalDebit;
// Map<String, List<TransactionItem>>? transactions;
// String? message;
//
// TransactionListResponse({
// this.error,
// this.balanceAmount,
// this.balanceType,
// this.totalCredit,
// this.totalDebit,
// this.transactions,
// this.message,
// });
//
// TransactionListResponse.fromJson(Map<String, dynamic> json) {
// error = json['error'];
// balanceAmount = json['balance_amount'];
// balanceType = json['balance_type'];
// totalCredit = json['total_credit'];
// totalDebit = json['total_debit'];
// message = json['message'];
//
// if (json['transactions'] != null) {
// transactions = {};
// json['transactions'].forEach((key, value) {
// transactions![key] = List<TransactionItem>.from(
// value.map((v) => TransactionItem.fromJson(v)),
// );
// });
// }
// }
//
// Map<String, dynamic> toJson() {
// final data = <String, dynamic>{};
// data['error'] = error;
// data['balance_amount'] = balanceAmount;
// data['balance_type'] = balanceType;
// data['total_credit'] = totalCredit;
// data['total_debit'] = totalDebit;
// data['message'] = message;
// if (transactions != null) {
// data['transactions'] = transactions!.map((key, value) =>
// MapEntry(key, value.map((v) => v.toJson()).toList()));
// }
// return data;
// }
// }
//
// class TransactionItem {
// String? id;
// String? billId;
// String? atype;
// String? type;
// String? datetime;
// String? cAmount;
// String? dAmount;
// String? narration;
//
// TransactionItem({
// this.id,
// this.billId,
// this.atype,
// this.type,
// this.datetime,
// this.cAmount,
// this.dAmount,
// this.narration,
// });
//
// TransactionItem.fromJson(Map<String, dynamic> json) {
// id = json['id'];
// billId = json['bill_id'];
// atype = json['atype'];
// type = json['type'];
// datetime = json['datetime'];
// cAmount = json['c_amount'];
// dAmount = json['d_amount'];
// narration = json['narration'];
// }
//
// Map<String, dynamic> toJson() => {
// 'id': id,
// 'bill_id': billId,
// 'atype': atype,
// 'type': type,
// 'datetime': datetime,
// 'c_amount': cAmount,
// 'd_amount': dAmount,
// 'narration': narration,
// };
// }
class PayAmountResponse {
String? error;
String? amount;
String? message;
String? orderId;
String? razorKey;
String? sessionExists;
PayAmountResponse(
{this.error,
this.amount,
this.message,
this.orderId,
this.razorKey,
this.sessionExists});
PayAmountResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
amount = json['amount'];
message = json['message'];
orderId = json['order_id'];
razorKey = json['razor_key'];
sessionExists = json['session_exists'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['amount'] = this.amount;
data['message'] = this.message;
data['order_id'] = this.orderId;
data['razor_key'] = this.razorKey;
data['session_exists'] = this.sessionExists;
return data;
}
}
......@@ -6,6 +6,7 @@ class TransactionListResponse {
String? totalDebit;
Map<String, List<TransactionItem>>? transactions;
String? message;
String? lastPaid;
TransactionListResponse({
this.error,
......@@ -24,7 +25,7 @@ class TransactionListResponse {
totalCredit = json['total_credit'];
totalDebit = json['total_debit'];
message = json['message'];
lastPaid = json['last_payment'];
if (json['transactions'] != null) {
transactions = {};
json['transactions'].forEach((key, value) {
......@@ -43,6 +44,7 @@ class TransactionListResponse {
data['total_credit'] = totalCredit;
data['total_debit'] = totalDebit;
data['message'] = message;
data['last_payment'] = lastPaid;
if (transactions != null) {
data['transactions'] = transactions!.map((key, value) =>
MapEntry(key, value.map((v) => v.toJson()).toList()));
......
......@@ -5,7 +5,7 @@ import 'package:gen_service/Services/api_calling.dart';
import '../Models/CommonResponse.dart';
import '../Models/HelpAndComplaintModels/ComplaintListResponse.dart';
import '../Models/HelpAndComplaintModels/GeneratorListResponse.dart';
import '../Screens/HelpAndComplaintScreens/DropDownsListResponse.dart';
import '../Models/HelpAndComplaintModels/DropDownsListResponse.dart';
class HelpAndComplaintProvider extends ChangeNotifier {
bool _isLoading = false;
......
import 'package:flutter/cupertino.dart';
import '../Models/TransactionModels/PayAmountResponse.dart';
import '../Services/api_calling.dart';
class PayAmountProvider with ChangeNotifier {
bool _isLoading = false;
PayAmountResponse? _payResponse;
PaymentStatusResponse? _statusResponse;
String? _errorMessage;
bool get isLoading => _isLoading;
PayAmountResponse? get payResponse => _payResponse;
PaymentStatusResponse? get statusResponse => _statusResponse;
String? get errorMessage => _errorMessage;
/// Pay Amount API
Future<void> payAmount({
required String sessionId,
required String empId,
required String amount,
required String refType,
required String refId,
}) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final res = await ApiCalling.payAmountApi(
sessionId,
empId,
amount,
refType,
refId,
);
if (res != null) {
_payResponse = res;
} else {
_errorMessage = "No response from server";
}
} catch (e) {
_errorMessage = "Error: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
/// Get Payment Status API
Future<void> getPaymentStatus({
required String sessionId,
required String empId,
required String razorpayOrderId,
}) async {
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final res = await ApiCalling.getPaymentStatusApi(
sessionId,
empId,
razorpayOrderId,
);
if (res != null) {
_statusResponse = res;
} else {
_errorMessage = "No response from server";
}
} catch (e) {
_errorMessage = "Error: $e";
} finally {
_isLoading = false;
notifyListeners();
}
}
/// Reset all states
void reset() {
_payResponse = null;
_statusResponse = null;
_errorMessage = null;
notifyListeners();
}
}
// Payment Status Response
class PaymentStatusResponse {
int? error;
double? amount;
String? date;
String? message;
int? sessionExists;
PaymentStatusResponse(
{this.error, this.amount, this.date, this.message, this.sessionExists});
PaymentStatusResponse.fromJson(Map<String, dynamic> json) {
error = json['error'];
amount = json['amount'];
date = json['date'];
message = json['message'];
sessionExists = json['session_exists'];
}
Map<String, dynamic> toJson() {
final Map<String, dynamic> data = new Map<String, dynamic>();
data['error'] = this.error;
data['amount'] = this.amount;
data['date'] = this.date;
data['message'] = this.message;
data['session_exists'] = this.sessionExists;
return data;
}
}
\ No newline at end of file
......@@ -12,26 +12,40 @@ import '../Services/api_post_request.dart';
import '../Utility/CustomSnackbar.dart';
class TransactionsProvider with ChangeNotifier {
TransactionListResponse? _transactionList;
bool _isLoading = false;
String? _errorMessage;
TransactionListResponse? _transactionList;
int _currentPage = 1;
bool _hasMore = true;
bool _isLoadingMore = false;
TransactionListResponse? get transactionList => _transactionList;
bool get isLoading => _isLoading;
bool get isLoadingMore => _isLoadingMore;
String? get errorMessage => _errorMessage;
TransactionListResponse? get transactionList => _transactionList;
bool get hasMore => _hasMore;
/// Fetch Transactions from API
/// Fetch Transactions from API (initial load)
Future<void> fetchTransactions(String accId, String sessionId) async {
_currentPage = 1;
_hasMore = true;
_isLoading = true;
_errorMessage = null;
notifyListeners();
try {
final response = await ApiCalling.fetchTransactionListApi(accId, sessionId);
final response = await ApiCalling.fetchTransactionListApi(
accId,
sessionId,
_currentPage.toString()
);
if (response != null) {
_transactionList = response;
_errorMessage = null;
// Check if we have more data (assuming 15 items per page)
_hasMore = _calculateHasMore(response);
} else {
_errorMessage = "No response from server";
}
......@@ -43,10 +57,86 @@ class TransactionsProvider with ChangeNotifier {
notifyListeners();
}
/// Load more transactions
Future<void> loadMoreTransactions(String accId, String sessionId) async {
if (_isLoadingMore || !_hasMore) return;
_isLoadingMore = true;
notifyListeners();
try {
final response = await ApiCalling.fetchTransactionListApi(
accId,
sessionId,
(_currentPage + 1).toString()
);
debugPrint("\nPage Number ${_currentPage+1}");
if (response != null && response.transactions != null) {
_currentPage++;
// Merge new transactions with existing ones
_mergeTransactions(response);
// Check if we have more data
_hasMore = _calculateHasMore(response);
}
} catch (e) {
debugPrint("Load more error: $e");
}
_isLoadingMore = false;
notifyListeners();
}
/// Merge new transactions with existing data
void _mergeTransactions(TransactionListResponse newResponse) {
if (_transactionList == null) {
_transactionList = newResponse;
return;
}
// Merge transactions by month
if (newResponse.transactions != null) {
if (_transactionList!.transactions == null) {
_transactionList!.transactions = {};
}
newResponse.transactions!.forEach((month, newItems) {
if (_transactionList!.transactions!.containsKey(month)) {
// Month exists, append items
_transactionList!.transactions![month]!.addAll(newItems);
} else {
// New month, add all items
_transactionList!.transactions![month] = newItems;
}
});
}
}
/// Check if there are more pages to load
bool _calculateHasMore(TransactionListResponse response) {
if (response.transactions == null || response.transactions!.isEmpty) {
return false;
}
// Count total items in current response
int totalItems = 0;
response.transactions!.forEach((month, items) {
totalItems += items.length;
});
// If we got less than 15 items, probably no more data
return totalItems >= 15;
}
/// Clear Data
void clearTransactions() {
_transactionList = null;
_errorMessage = null;
_currentPage = 1;
_hasMore = true;
_isLoadingMore = false;
notifyListeners();
}
......
......@@ -85,6 +85,7 @@ class _OtpScreenState extends State<OtpScreen> {
if (authProvider.otpResponse?.accId != null) {
await prefs.saveString("accId", authProvider.otpResponse!.accId!);
await prefs.saveString("session_id", authProvider.otpResponse!.sessionId!);
await prefs.saveString("mob_number", widget.mob);
}
// ✅ Navigate to Home Screen
......@@ -94,6 +95,7 @@ class _OtpScreenState extends State<OtpScreen> {
pageBuilder: (_, __, ___) => HomeScreen(
accId: authProvider.otpResponse!.accId!,
sessionId: authProvider.otpResponse!.sessionId.toString(),
mobNumber: widget.mob,
),
transitionsBuilder: (_, animation, __, child) {
return FadeTransition(opacity: animation, child: child);
......
......@@ -88,7 +88,7 @@ class _AddComplaintScreenState extends State<AddComplaintScreen> {
StretchMode.blurBackground,
],
background: Container(
decoration: const BoxDecoration(color: AppColors.primary),
decoration: const BoxDecoration(gradient: AppColors.commonAppBarGradient),
child: Padding(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
......@@ -123,7 +123,7 @@ class _AddComplaintScreenState extends State<AddComplaintScreen> {
/// Main content
SliverToBoxAdapter(
child: Container(
color: AppColors.primary,
color: AppColors.backgroundBottom,
child: Container(
padding:
const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
......
......@@ -114,7 +114,9 @@ class _ComplaintListScreenState extends State<ComplaintListScreen> {
],
background: Container(
decoration:
const BoxDecoration(color: AppColors.primary),
const BoxDecoration(
gradient: AppColors.commonAppBarGradient
),
child: Padding(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 16),
child: Row(
......@@ -149,7 +151,7 @@ class _ComplaintListScreenState extends State<ComplaintListScreen> {
SliverToBoxAdapter(
child: Container(
padding: const EdgeInsets.only(top: 1),
color: AppColors.primary,
color: AppColors.backgroundBottom,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 20),
decoration: const BoxDecoration(
......@@ -318,14 +320,14 @@ class ComplaintCard extends StatelessWidget {
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(12),
border: Border.all(color: Colors.grey.shade200),
boxShadow: [
BoxShadow(
color: Colors.grey.shade200,
blurRadius: 4,
offset: const Offset(0, 2),
)
],
// border: Border.all(color: Colors.grey.shade200),
// boxShadow: [
// BoxShadow(
// color: Colors.grey.shade200,
// blurRadius: 4,
// offset: const Offset(0, 2),
// )
// ],
),
child: Column(
children: [
......
......@@ -108,7 +108,7 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
StretchMode.blurBackground,
],
background: Container(
decoration: const BoxDecoration(color: AppColors.primary),
decoration: const BoxDecoration(gradient: AppColors.commonAppBarGradient),
child: Padding(
padding: const EdgeInsets.symmetric(
horizontal: 16,
......@@ -145,7 +145,7 @@ class _SelectOrderHelpScreenState extends State<SelectOrderHelpScreen> {
/// Main content
SliverToBoxAdapter(
child: Container(
color: AppColors.primary,
color: AppColors.backgroundBottom,
child: Container(
padding: const EdgeInsets.symmetric(
horizontal: 16,
......
This diff is collapsed.
......@@ -356,7 +356,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
profileProvider.fetchProfile(widget.accId, widget.sessionId);
},
stretchTriggerOffset: 300.0,
expandedHeight: 245.0,
expandedHeight: 260.0,
flexibleSpace: LayoutBuilder(
builder: (context, constraints) {
final top = constraints.biggest.height;
......@@ -418,8 +418,8 @@ class _ProfileScreenState extends State<ProfileScreen> {
data.name.toString(),
style: const TextStyle(
color: Colors.white,
fontSize: 20,
fontWeight: FontWeight.w600,
fontSize: 24,
fontWeight: FontWeight.w400,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
......@@ -429,8 +429,9 @@ class _ProfileScreenState extends State<ProfileScreen> {
Text(
'+91 ${data.mobNum}',
style: TextStyle(
fontWeight: FontWeight.w400,
color: Colors.white.withOpacity(0.9),
fontSize: 14,
fontSize: 16,
),
maxLines: 1,
overflow: TextOverflow.ellipsis,
......@@ -449,7 +450,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
" Logout ",
style: TextStyle(
color: AppColors.normalText,
fontWeight: FontWeight.w400,
fontWeight: FontWeight.w600,
fontSize: 14,
overflow: TextOverflow.ellipsis,
),
......@@ -582,7 +583,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
padding: EdgeInsets.all(16),
child: Row(
children: [
if(title != "State" && title != "Sub Locality")
Container(
padding: EdgeInsets.all(title =="Address" ? 8 :12),
decoration: BoxDecoration(
......@@ -595,20 +596,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
fit: BoxFit.contain,
),
),
if(title != "Email ID" && title != "Address")
Expanded(
flex: 1,
child: Container(
padding: EdgeInsets.all(14),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(18)
),
child: SizedBox(
width: 24,
height: 24,
),
),
),
SizedBox(width: 14,),
Expanded(
flex: 7,
......
......@@ -117,6 +117,7 @@ class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderSt
Future<void> _navigateToDashboard() async {
final String? savedAccId = await prefs.getString("accId");
final String? savedSessionId = await prefs.getString("session_id");
final String? mobNumber = await prefs.getString("mob_number");
if (savedAccId != null && savedAccId.isNotEmpty) {
Navigator.pushReplacement(
......@@ -125,6 +126,7 @@ class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderSt
pageBuilder: (_, __, ___) => HomeScreen(
accId: savedAccId,
sessionId: savedSessionId.toString(),
mobNumber: mobNumber.toString(),
),
transitionsBuilder: (_, animation, __, child) {
return FadeTransition(
......@@ -513,7 +515,7 @@ class _SplashScreenState extends State<SplashScreen> with SingleTickerProviderSt
),
const SizedBox(height: 4),
Text(
"Avantect Web Grid",
"Avantech Web Grid",
style: TextStyle(
fontSize: 16,
fontWeight: FontWeight.w600,
......
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:gen_service/Notifiers/TransactionsProvider.dart';
import 'package:razorpay_flutter/razorpay_flutter.dart';
import '../../Notifiers/PayAmountProvider.dart';
import '../../Utility/AppColors.dart';
import '../../Utility/CustomSnackbar.dart';
import '../../Utility/SharedpreferencesService.dart';
class BillDetailScreen extends StatefulWidget {
final String sessionId;
......@@ -21,15 +24,159 @@ class BillDetailScreen extends StatefulWidget {
}
class _BillDetailScreenState extends State<BillDetailScreen> {
late Razorpay _razorpay;
bool? isSuccess;
var paymentMethod = "";
var User_contact = "0";
final prefs = SharedPreferencesService.instance;
@override
void initState() {
super.initState();
_razorpay =Razorpay();
Future.microtask(() {
final provider = Provider.of<TransactionsProvider>(context, listen: false);
provider.fetchBillDetails(widget.accId, widget.sessionId, widget.billId);
});
}
//_________________________________________________________
void _handlePaymentSuccess(PaymentSuccessResponse response) {
setState(() async {
final provider = Provider.of<PayAmountProvider>(context, listen: false);
await provider.getPaymentStatus(
sessionId: widget.sessionId,
empId: widget.accId,
razorpayOrderId: response.orderId.toString()
);
final data = provider.statusResponse;
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => PaymentSuccessFaillScreen(
// total: "${data?.amount}",
// date: "${data?.date}",
// payMode: "UPI",
// status: "Success",
// )),
// );
_razorpay.clear();
CustomSnackBar.showSuccess(
context: context,
message: data?.message ?? "Payment Success!",
);
// buttonLoading = false;
});
}
void _handlePaymentError(PaymentFailureResponse response) {
setState(() async {
// Navigator.push(
// context,
// MaterialPageRoute(builder: (context) => PaymentSuccessFaillScreen(
// total: "${data?.amount}",
// date: "${data?.date}",
// payMode: "UPI",
// status: "Fail",
// )),
// );
CustomSnackBar.showError(
context: context,
message: "Payment failed, please try again.",
);
});
_razorpay.clear();
CustomSnackBar.showError(
context: context,
message: "Payment failed, please try again.",
);
}
void _handleExternalWallet(ExternalWalletResponse response) {
_razorpay.clear();
}
Future<void> payAmountFunction(String amount, String id) async {
try {
final provider = Provider.of<PayAmountProvider>(context, listen: false);
await provider.payAmount(
sessionId: widget.sessionId,
empId: widget.accId,
amount: amount,
refType: "Payment",
refId: id,
);
final data = provider.payResponse;
if (data != null) {
if (data.error == "0") {
openCheckout(data.orderId, data.razorKey!);
} else {
CustomSnackBar.showError(
context: context,
message: "${data.message}",
);
debugPrint("❌ Could not Complete Payment: ${data.message}");
}
} else {
debugPrint("❌ No response received from PayAmount API");
}
} catch (e) {
debugPrint("❌ 'Error occurred: $e'");
}
}
//razorpay payments__________________________________________________________
void openCheckout(razorPayOrderId, String razorpayKey) async {
final String? mobNumber = await prefs.getString("mob_number");
_razorpay.on(Razorpay.EVENT_PAYMENT_SUCCESS, _handlePaymentSuccess);
_razorpay.on(Razorpay.EVENT_PAYMENT_ERROR, _handlePaymentError);
_razorpay.on(Razorpay.EVENT_EXTERNAL_WALLET, _handleExternalWallet);
// _buildCheckWidget();
Map<String, dynamic> options = {
'key': razorpayKey,
'amount': int.parse("${((0) * 100).round()}"),
'name': 'Gen Service',
'order_id': razorPayOrderId,
'description': "Bill",
'currency': 'INR',
'method': 'upi',
'prefill': {'contact': mobNumber, 'email': ''}
};
// print(options);
try {
_razorpay.open(options);
} catch (e, s) {
// FirebaseCrashlytics.instance.log('Error occurred: $e');
// FirebaseCrashlytics.instance.recordError(e, s);
debugPrint(e.toString());
}
}
void verifyPayment(String orderId) {
isSuccess = true;
setState(() {
// toast(context, "Order Placed Successfully");
// print("Verify Payment");
});
_razorpay.clear();
}
// void onError(CFErrorResponse errorResponse, String orderId) {
// isSuccess = false;
// setState(() {
// // print(errorResponse.getMessage());
// // print("Error while making payment");
// });
// }
@override
Widget build(BuildContext context) {
return Consumer<TransactionsProvider>(
......@@ -92,7 +239,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
// Amount
Text(
"₹${details.totalAmount ?? "0"}",
"₹${details.totalAmount}",
style: const TextStyle(
fontSize: 32,
fontFamily: "Poppins",
......@@ -221,7 +368,17 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
Expanded(
child: ElevatedButton(
onPressed: () {
// Razorpay or Payment
if(details.totalAmount == "0.00") {
CustomSnackBar.showWarning(
context: context,
message: "Invalid amount or less then 1",
);
}else{
Navigator.pop(context);
// handle payment navigation
payAmountFunction(details.totalAmount.toString(), details.id.toString());
}
},
style: ElevatedButton.styleFrom(
backgroundColor: AppColors.amountText,
......
......@@ -59,7 +59,7 @@ class _GeneratordetailsscreenState extends State<Generatordetailsscreen> {
final error = detailsProvider.errorMessage;
final data = detailsProvider.detailsResponse;
final genDetails = data!.genDetails??GenDetails();
final locDetails = data!.locationDetails??LocationDetails();
final locDetails = data.locationDetails??LocationDetails();
final quotationsList = data.quotations??[];
final scheduleList = data.schedule ?? [];
final amcQuotationsList = data.amcQuotations??[];
......
......@@ -24,6 +24,8 @@ const amcQuoteListUrl = "${baseUrl}all_amc_quotations";
const complaintListUrl = "${baseUrl}all_complaint_list";
const downloadBillUrl = "${baseUrl}download_bill";
const downloadRecieptUrl = "${baseUrl}download_reciept";
const payAmountUrl = "${baseUrl}pay_amount";
const getPaymentStatusUrl = "${baseUrl}get_payment_status";
/// Help and complaints
const addComplaintUrl = "${baseUrl}add_complaint";
......
......@@ -15,8 +15,10 @@ import '../Models/AuthResponse.dart';
import '../Models/CommonResponse.dart';
import '../Models/DashboardResponse.dart';
import '../Models/HelpAndComplaintModels/GeneratorListResponse.dart';
import '../Models/TransactionModels/PayAmountResponse.dart';
import '../Models/TransactionModels/TransactionListResponse.dart';
import '../Screens/HelpAndComplaintScreens/DropDownsListResponse.dart';
import '../Models/HelpAndComplaintModels/DropDownsListResponse.dart';
import '../Notifiers/PayAmountProvider.dart';
import 'api_URLs.dart';
import 'api_post_request.dart';
import 'package:http/http.dart' as http show MultipartFile;
......@@ -150,12 +152,14 @@ class ApiCalling {
static Future<TransactionListResponse?> fetchTransactionListApi(
String accId,
String sessionId,
String pageNumber,
) async {
debugPrint("###############################Transaction Api calling ");
try {
Map<String, String> data = {
"acc_id": accId,
"session_id": sessionId,
"page_number": pageNumber,
};
final res = await post(data, transactionsUrl, {});
......@@ -286,6 +290,66 @@ class ApiCalling {
}
}
/// pay_amount
static Future<PayAmountResponse?> payAmountApi(
String sessionId,
String empId,
String ammount,
String refType,
String refId,
) async {
try {
Map<String, String> data = {
"session_id": sessionId,
"acc_id": empId,
"amount": ammount,
"ref_type": refType,
"ref_id": refId,
};
final res = await post(data, payAmountUrl, {});
debugPrint("PayAmount Response ${res?.body}");
if (res != null) {
return PayAmountResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ API Error (payAmountApi): $e");
return null;
}
}
/// Fetch or get_payment_status
static Future<PaymentStatusResponse?> getPaymentStatusApi(
String sessionId,
String empId,
String razorpayOrderId,
) async {
try {
Map<String, String> data = {
"session_id": sessionId,
"emp_id": empId,
"razorpay_order_id": razorpayOrderId,
};
final res = await post(data, getPaymentStatusUrl, {});
if (res != null) {
return PaymentStatusResponse.fromJson(jsonDecode(res.body));
} else {
debugPrint("Null Response");
return null;
}
} catch (e) {
debugPrint("❌ API Error (getPaymentStatusApi): $e");
return null;
}
}
//___________________________________Help and Complaints
......
......@@ -45,7 +45,7 @@ class AppColors {
static const Color backgroundLight = Color(0xFFFFFFFF);
static const Color backgroundDark = Color(0xFF111827);
static const Color backgroundRegular = Color(0xFFF2F2F2);
static const Color backgroundBottom = Color(0xFF4076FF);
//Button
static const Color buttonColor = Color(0xFF008CDE);
......@@ -72,7 +72,7 @@ class AppColors {
end: Alignment.bottomRight,
colors: [
AppColors.subtitleText,
Color(0xFFFFFFFF),
Color(0x00FFFFFF),
],
);
......@@ -147,4 +147,13 @@ class AppColors {
Color(0xFF4076FF),
],
);
static const LinearGradient commonAppBarGradient = LinearGradient(
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
colors: [
Color(0xFF04Bfef),
Color(0xFF4076FF),
],
);
}
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment