Closed siman302 closed 2 months ago
Are you getting any error here ?
` // Set the callback before initiating the payment _cfPaymentGatewayService.setCallback(verifyPayment, onError);
log('Initiating payment...'); _cfPaymentGatewayService.doPayment(cfWebCheckout); } on CFException catch (e) { log("CFException during payment: ${e.message}"); } catch (e) { log("Unexpected error during payment: $e"); }`
Yes, @suhas-cashfree, the verifyPayment and onError functions are not being invoked when a payment is made, whether it fails or succeeds.
Are you getting any error here -> log("CFException during payment: ${e.message}");
Or here -> log("Unexpected error during payment: $e");
No, Not get any error, payment done successfully. verifyPayment and onError functions not invoke, that an issue.
Check the code video. flutter web. https://drive.google.com/file/d/1lo4Er_7_psRsZunQuGDdAty3LOqQ8An4/view?usp=sharing
Hey hi This is expected behaviour What you are doing is a redirect flow You received verify callback as soon as the web page opened.
You have to have a "return_url" when you create the order. So that once the payment is complete, there is a redirection that will happen to that url
Check return url here -> https://docs.cashfree.com/reference/pgcreateorder
Yes, I set the return_url, which I send in the request when I get create the order. That link will open successfully, when payment process in completed, whether it completed or failed.
Still I don't received the callbacks. @suhas-cashfree
That’s what I was saying. In this flow, you will not get callbacks. You should check the order status on redirection to your return url. The return url will have order id in query params
Closing this ticket. Please raise a new one, if the issue still persists
Thanks @suhas-cashfree
I try to implement the cashflow on the flutter web. Everything is working fine, expect then call back functions.
Note: I am testing on the sandbox and so I think domain restriction is not an issue, because I am developer from Pakistan
` // Verify Payment Callback Future verifyPayment(String orderId) async {
final verifyUrl = "${_cashfreeBaseUrl}pg/orders/$orderId";
}
// Error Callback void onError(CFErrorResponse errorResponse, String orderId) { log("Payment error for Order ID: $orderId"); log("Error message: ${errorResponse.getMessage()}"); // Add further error handling logic }
// Web Checkout Function Future webCheckout(CFSession session) async {
try {
// Build the checkout object with the session
var cfWebCheckout =
CFWebCheckoutPaymentBuilder().setSession(session).build();
}`
verifyPayment and onError functions are not invoke, when I check it in details in the cfpaymentgatewayservice.dart file, I found that in function doPayment, the invokeMethod("doWebPayment") return the null value instantly, not wait until the doWebPayment finish execution that why verifyPayment and onError functions not call. Kindly fix the doWebPayment functions, Thanks.
`doPayment(CFPayment cfPayment) { if (verifyPayment == null || onError == null) { throw CFException(CFExceptionConstants.CALLBACK_NOT_SET); }
}`