Closed ibrafayez closed 3 years ago
Please share with us which version you use and a snapshot from the integration code
@mohamedkhairy953 Sure
flutter_paytabs_bridge: ^2.0.3-beta
integration code: (billingDetails & configuration are the same as required in README) Card Payment:
FlutterPaytabsBridge.startCardPayment(configuration, (event) {
if (event["status"] == "success") {
successPayment();
return;
} else if (event["status"] == "error") {
// Handle error here.
_Result = 'An Error Has Occurred, Please try again later';
} else if (event["status"] == "event") {
// Handle events here.
_Result = 'unsuccessful';
}
}
ApplePay:(configuration is the same as required in README)
FlutterPaytabsBridge.startApplePayPayment(configuration, (event) {
if (event["status"] == "success") {
successPayment();
return;
} else if (event["status"] == "error") {
// Handle error here.
_Result = 'An Error Has Occurred, Please try again later';
} else if (event["status"] == "event") {
// Handle events here.
_Result = "Something went wrong";
}
}
successPayment():
void successPayment() {
dispose();
Navigator.of(context).pushAndRemoveUntil(MaterialPageRoute(builder: (context) => CreateImageScreen()), (Route<dynamic> route) => false);
}
NOTE: I removed the setState because of the error
Hi @ibrafayez
If you are using StatefulWidget so you should use setState() to update your widget state, And regarding the issue, it is not related to ApplePay functionality, please try to print the event in your startApplePayPayment or try to run our sample app just to make sure the issue not related to PayTabs flutter plugin.
Waiting for your reply
Thanks
If the user pays for the first time the payment works and it takes the user to the next screen, but if the user go through this process again the app only charges the user the amount but it shows an error and doesn't go to the next screen:
EROOR:
[VERBOSE-2:ui_dart_state.cc(186)] Unhandled Exception: setState() called after dispose(): _BodyState#91ce6(lifecycle state: defunct, not mounted) This error happens if you call setState() on a State object for a widget that no longer appears in the widget tree (e.g., whose parent widget no longer includes the widget in its build). This error can occur when code calls setState() from a timer or an animation callback. The preferred solution is to cancel the timer or stop listening to the animation in the dispose() callback. Another solution is to check the "mounted" property of this object before calling setState() to ensure the object is still in the tree. This error might indicate a memory leak if setState() is being called because another object is retaining a reference to this State object after it has been removed from the tree. To avoid memory leaks, consider breaking the reference to this object during dispose().
I tried adding dispose() but it did nothing, Also I tried adding if(mounted): The problem with this is it doesn't tell me if the payment was successful or not, it charges the user the amount without doing anything