Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
Sai Srinivas
gen_rentals
Commits
de4cf645
Commit
de4cf645
authored
Nov 07, 2025
by
Sai Srinivas
Browse files
Razorpay Setup improve
parent
669ff5f9
Changes
25
Show whitespace changes
Inline
Side-by-side
ios/Runner/Assets.xcassets/AppIcon.appiconset/AppIcon~ipad.png
0 → 100644
View file @
de4cf645
8.97 KB
lib/Screens/BillScreens/BillDetailListScreen.dart
View file @
de4cf645
...
@@ -50,30 +50,58 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
...
@@ -50,30 +50,58 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
setState
(()
{
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
(
CustomSnackBar
.
showSuccess
(
context:
context
,
context:
context
,
message:
"Payment Success!"
,
message:
data
?.
message
??
"Payment Success!"
,
);
);
// buttonLoading = false;
// buttonLoading = false;
});
});
}
}
void
_handlePaymentError
(
PaymentFailureResponse
response
)
{
void
_handlePaymentError
(
PaymentFailureResponse
response
)
{
setState
(()
{
setState
(()
{
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed!"
,
message:
"Payment failed!"
,
);
);
// buttonLoading = false;
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
PaymentSuccessFaillScreen
(
total:
"10218"
,
date:
"8th Oct, 2025"
,
payMode:
"UPI"
,
status:
"Fail"
,
)),
);
});
});
_razorpay
.
clear
();
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
}
}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{
_razorpay
.
clear
();
}
Future
<
void
>
payAmountFunction
(
String
amount
,
String
id
)
async
{
Future
<
void
>
payAmountFunction
(
String
amount
,
String
id
)
async
{
try
{
try
{
...
@@ -103,6 +131,7 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
...
@@ -103,6 +131,7 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
debugPrint
(
"❌ No response received from PayAmount API"
);
debugPrint
(
"❌ No response received from PayAmount API"
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
_razorpay
.
clear
();
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
'Error occurred:
$e
'
,
message:
'Error occurred:
$e
'
,
...
@@ -142,6 +171,7 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
...
@@ -142,6 +171,7 @@ class _BillDetailListScreenState extends State<BillDetailListScreen> {
// toast(context, "Order Placed Successfully");
// toast(context, "Order Placed Successfully");
// print("Verify Payment");
// print("Verify Payment");
});
});
_razorpay
.
clear
();
}
}
...
...
lib/Screens/BillScreens/BillDetailScreen.dart
View file @
de4cf645
...
@@ -7,6 +7,7 @@ import '../../Notifier/PayAmountProvider.dart';
...
@@ -7,6 +7,7 @@ import '../../Notifier/PayAmountProvider.dart';
import
'../../Utility/AppColors.dart'
;
import
'../../Utility/AppColors.dart'
;
import
'../../Utility/CustomSnackbar.dart'
;
import
'../../Utility/CustomSnackbar.dart'
;
import
'../../Utility/Reusablewidgets.dart'
;
import
'../../Utility/Reusablewidgets.dart'
;
import
'../TransactionScreens/PaymentSuccessfailScreen.dart'
;
class
BillDetailScreen
extends
StatefulWidget
{
class
BillDetailScreen
extends
StatefulWidget
{
final
String
sessionId
;
final
String
sessionId
;
...
@@ -71,31 +72,67 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
...
@@ -71,31 +72,67 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
});
});
}
}
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
setState
(()
{
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
(
CustomSnackBar
.
showSuccess
(
context:
context
,
context:
context
,
message:
"Payment Success!"
,
message:
data
?.
message
??
"Payment Success!"
,
);
);
// buttonLoading = false;
// buttonLoading = false;
});
});
}
}
void
_handlePaymentError
(
PaymentFailureResponse
response
)
{
void
_handlePaymentError
(
PaymentFailureResponse
response
)
{
setState
(()
{
setState
(()
async
{
final
provider
=
Provider
.
of
<
PayAmountProvider
>(
context
,
listen:
false
);
await
provider
.
getPaymentStatus
(
sessionId:
widget
.
sessionId
,
empId:
widget
.
accId
,
razorpayOrderId:
""
);
final
data
=
provider
.
statusResponse
;
Navigator
.
push
(
context
,
MaterialPageRoute
(
builder:
(
context
)
=>
PaymentSuccessFaillScreen
(
total:
"
${data?.amount}
"
,
date:
"
${data?.date}
"
,
payMode:
"UPI"
,
status:
"Fail"
,
)),
);
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed
!
"
,
message:
"Payment failed
, please try again.
"
,
);
);
// buttonLoading = false;
});
});
_razorpay
.
clear
();
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
}
}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{
_razorpay
.
clear
();
}
Future
<
void
>
payAmountFunction
(
String
amount
,
String
id
)
async
{
Future
<
void
>
payAmountFunction
(
String
amount
,
String
id
)
async
{
try
{
try
{
...
@@ -129,6 +166,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
...
@@ -129,6 +166,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
context:
context
,
context:
context
,
message:
'Error occurred:
$e
'
,
message:
'Error occurred:
$e
'
,
);
);
_razorpay
.
clear
();
}
}
}
}
...
@@ -152,8 +190,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
...
@@ -152,8 +190,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
try
{
try
{
_razorpay
.
open
(
options
);
_razorpay
.
open
(
options
);
}
catch
(
e
,
s
)
{
}
catch
(
e
,
s
)
{
// FirebaseCrashlytics.instance.log('Error occurred: $e');
_razorpay
.
clear
();
// FirebaseCrashlytics.instance.recordError(e, s);
debugPrint
(
e
.
toString
());
debugPrint
(
e
.
toString
());
}
}
}
}
...
@@ -164,6 +201,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
...
@@ -164,6 +201,7 @@ class _BillDetailScreenState extends State<BillDetailScreen> {
// toast(context, "Order Placed Successfully");
// toast(context, "Order Placed Successfully");
// print("Verify Payment");
// print("Verify Payment");
});
});
_razorpay
.
clear
();
}
}
...
...
lib/Screens/DashboardScreen.dart
View file @
de4cf645
...
@@ -66,6 +66,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
...
@@ -66,6 +66,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
status:
"Success"
,
status:
"Success"
,
)),
)),
);
);
_razorpay
.
clear
();
CustomSnackBar
.
showSuccess
(
CustomSnackBar
.
showSuccess
(
context:
context
,
context:
context
,
message:
data
?.
message
??
"Payment Success!"
,
message:
data
?.
message
??
"Payment Success!"
,
...
@@ -97,13 +98,16 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
...
@@ -97,13 +98,16 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
});
});
_razorpay
.
clear
();
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
}
}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{
_razorpay
.
clear
();
}
Future
<
void
>
payAmountFunction
(
String
amount
)
async
{
Future
<
void
>
payAmountFunction
(
String
amount
)
async
{
try
{
try
{
...
@@ -170,6 +174,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
...
@@ -170,6 +174,7 @@ class _DashboardScreenState extends State<DashboardScreen> with WidgetsBindingOb
// toast(context, "Order Placed Successfully");
// toast(context, "Order Placed Successfully");
// print("Verify Payment");
// print("Verify Payment");
});
});
_razorpay
.
clear
();
}
}
// void onError(CFErrorResponse errorResponse, String orderId) {
// void onError(CFErrorResponse errorResponse, String orderId) {
...
...
lib/Screens/TransactionScreens/TransactionsScreen.dart
View file @
de4cf645
...
@@ -48,6 +48,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
...
@@ -48,6 +48,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
void
_handlePaymentSuccess
(
PaymentSuccessResponse
response
)
{
setState
(()
async
{
setState
(()
async
{
final
provider
=
Provider
.
of
<
PayAmountProvider
>(
context
,
listen:
false
);
final
provider
=
Provider
.
of
<
PayAmountProvider
>(
context
,
listen:
false
);
...
@@ -66,6 +67,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
...
@@ -66,6 +67,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
status:
"Success"
,
status:
"Success"
,
)),
)),
);
);
_razorpay
.
clear
();
CustomSnackBar
.
showSuccess
(
CustomSnackBar
.
showSuccess
(
context:
context
,
context:
context
,
message:
data
?.
message
??
"Payment Success!"
,
message:
data
?.
message
??
"Payment Success!"
,
...
@@ -97,13 +99,15 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
...
@@ -97,13 +99,15 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
});
});
_razorpay
.
clear
();
CustomSnackBar
.
showError
(
CustomSnackBar
.
showError
(
context:
context
,
context:
context
,
message:
"Payment failed, please try again."
,
message:
"Payment failed, please try again."
,
);
);
}
}
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{
void
_handleExternalWallet
(
ExternalWalletResponse
response
)
{}
_razorpay
.
clear
();
}
Future
<
void
>
payAmountFunction
(
String
amount
)
async
{
Future
<
void
>
payAmountFunction
(
String
amount
)
async
{
try
{
try
{
...
@@ -134,6 +138,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
...
@@ -134,6 +138,7 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
debugPrint
(
"❌ No response received from PayAmount API"
);
debugPrint
(
"❌ No response received from PayAmount API"
);
}
}
}
catch
(
e
)
{
}
catch
(
e
)
{
_razorpay
.
clear
();
debugPrint
(
"❌ 'Error occurred:
$e
'"
);
debugPrint
(
"❌ 'Error occurred:
$e
'"
);
}
}
}
}
...
@@ -161,6 +166,14 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
...
@@ -161,6 +166,14 @@ class _TransactionsScreenState extends State<TransactionsScreen> {
debugPrint
(
e
.
toString
());
debugPrint
(
e
.
toString
());
}
}
}
}
void
verifyPayment
(
String
orderId
)
{
isSuccess
=
true
;
setState
(()
{
// toast(context, "Order Placed Successfully");
// print("Verify Payment");
});
_razorpay
.
clear
();
}
...
...
Prev
1
2
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment