-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Success message is coming even the payment request is cancelled from the selected source at phone pe #22
Comments
Kindly share the issue with [email protected]. They will be able to help with the issue. |
We mailed but no reverts. Could you please help us here, if there is a mistake in the code, or in the flutter dependency of phone pe. |
Share your email Id |
Well, I am so sorry but, I am a junior employ who dont have access to that mail id, I am just trying to solve the issue. Well, I could give you reference, class Phonepepayment extends StatefulWidget { @OverRide class _PhonepepaymentState extends State { String checksum = ""; String callbackurl = "https://webhook.site/callback-url"; String body = ""; String apiEndPoint = "/pg/v1/pay"; Object? result; getChecksum(){ String jsonBody = jsonEncode(requestData); checksum = '${sha256.convert(utf8.encode(base64Body + apiEndPoint + saltKey)).toString()}###$saltIndex'; return base64Body; @OverRide
} @OverRide
} void phonepeInit() { void startPgTransaction() async{ void handleError(error){ Even in the Sandbox environment, with test keys, you can check, it is the same issue. The user enters UPI id on phone pay page, and it directs to say Google Pay for payment, and the user cancels the payment there, or do not pay, but the phone pe sdk, returns success. Please check this out. |
You can share any other email Id through which the support team can reach out to and if required they will setup a call. |
Sure here's my id [email protected] |
I'm also facing the issue that when payment is declined it returns a successful response. any solution ?? |
Hi, Please share your issue with the [email protected], they will help you. |
import 'package:dio/dio.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:phonepe_payment_sdk/phonepe_payment_sdk.dart';
import '../model/success_model.dart';
import '../utill/app_constants.dart';
import '../utill/app_events.dart';
import '../utill/shared_preference.dart';
import '../view/widget/custom_payment_dialog.dart';
class PhonePeController extends GetxController {
//Phonepe
Object? result;
final String _environmentValue = 'PRODUCTION';
final String _appId = "";
final String _merchantId = "M22OYS8NI0XNS";
final bool _enableLogs = true;
String _type = '';
//Update payment
final Dio _dio = Dio();
final isUpdateLoading = false.obs;
final isUpdateSuccess = false.obs;
SuccessModel successModel = SuccessModel();
@OverRide
void onInit() {
super.onInit();
initPhonePeSdk();
}
void initPhonePeSdk() {
PhonePePaymentSdk.init(_environmentValue, _appId, _merchantId, _enableLogs)
.then((isInitialized) {
debugPrint("PhonePeController $isInitialized");
result = 'PhonePe SDK Initialized - $isInitialized';
}).catchError((error) {
debugPrint("PhonePeController Init Error $error");
handleError(error);
return error;
});
}
void handleError(error) {
if (error is Exception) {
result = error.toString();
} else {
result = {"error": error};
}
}
void startTransaction(
String body,
String callBackUrl,
String checksum,
String type1,
String orderId,
String paymentId,
num amount,
String mobile,
String userUniId) async {
_type = type1;
AppEvents().sendInitCheckoutEvent(
amount.toString(), orderId.toString(), userUniId.toString(), type1);
try {
PhonePePaymentSdk.startTransaction(body, callBackUrl, checksum, "")
.then((response) {
if (response != null) {
String status = response['status'].toString();
String error = response['error'].toString();
if (status == 'SUCCESS') {
result = "Flow Completed - Status: Success!";
AppEvents().sendPaymentSuccessEvent(amount.toString(),
orderId.toString(), userUniId.toString(), type1);
updateOnlinePayment(orderId, paymentId);
} else {
result = "Flow Completed - Status: $status and Error: $error";
Get.dialog(
AlertDialog(
title: const Text('Payment Failed'),
actions: [
ElevatedButton(
onPressed: () {
Get.back(); // Close the dialog
},
child: const Text('OK'),
),
],
),
);
}
} else {
Get.dialog(
AlertDialog(
title: const Text('Payment Failed'),
actions: [
ElevatedButton(
onPressed: () {
Get.back(); // Close the dialog
},
child: const Text('OK'),
),
],
),
);
result = "Flow Incomplete";
}
}).catchError((error) {
debugPrint("PhonePeController catchError $error");
handleError(error);
return error;
});
} catch (error) {
debugPrint("PhonePeController catch $error");
handleError(error);
}
}
Future updateOnlinePayment(String orderId, String paymentId) async {
CustomPaymentDialog.showDialog();
isUpdateLoading(true);
}
void showSuccessDialog(String paymentId, String type) {
Get.dialog(
AlertDialog(
title: const Text('Payment Successful'),
content: Text('Payment ID: $paymentId'),
actions: [
ElevatedButton(
onPressed: () {
Get.back(); //Close Dialog
if (type == AppConstants.jeevini) {
//JEEVINI
Get.offAllNamed('/paid_orders_tab_screen',
arguments: {'index': 0});
} else if (type == AppConstants.divineCode) {
//DIVINE
Get.offAllNamed('/paid_orders_tab_screen',
arguments: {'index': 1});
} else if (type == AppConstants.pdfBook) {
//BOOKS
Get.offAllNamed('/paid_orders_tab_screen',
arguments: {'index': 2});
} else if (type == AppConstants.report) {
//REPORT
Get.offAllNamed('/paid_orders_tab_screen',
arguments: {'index': 3});
} else if (type == AppConstants.shop) {
//Service
Get.offAllNamed('/orders_tab_screen', arguments: {'index': 1});
} else if (type == AppConstants.serviceOrder) {
//Service
Get.offAllNamed('/orders_tab_screen', arguments: {'index': 2});
} else if (type == AppConstants.architect) {
//Service
Get.offAllNamed('/architect_orders_tab_screen');
} else {
Get.offAllNamed('/dashboard');
}
},
child: const Text('OK'),
),
],
),
);
}
}
phonepe_payment_sdk: ^2.0.3
**The issue I am facing right now is, that when the user goes to pay throgh phone pe PG, like the user opted for google pay upi, he went there, but he changed his mind and di not made payment, the code shows success. his should not occur, please help me solve.
The text was updated successfully, but these errors were encountered: