PaymentErrorCallback typedef
PaymentErrorCallback =
void Function(PaymentException errorMessage)
Callback invoked when an error occurs during the payment process.
This callback receives a PaymentException containing details about the error:
- PaymentException.message: A human-readable error description
- PaymentException.errorType: The type of error that occurred
- PaymentException.statusCode: HTTP status code (for API errors)
- PaymentException.errorCode: Specific error code from the API
Example:
void onPaymentError(PaymentException error) {
switch (error.errorType) {
case PaymentErrorType.network:
showNetworkErrorDialog(error.message);
break;
case PaymentErrorType.invalidOrderId:
showInvalidOrderDialog(error.message);
break;
default:
showGenericErrorDialog(error.message);
}
}
Implementation
typedef PaymentErrorCallback = void Function(PaymentException errorMessage);