handlePayment method

void handlePayment(
  1. BuildContext context,
  2. bool success,
  3. AssignmentModel assignmentModel
)

Implementation

void handlePayment(
    BuildContext context, bool success, AssignmentModel assignmentModel) {
  var myPaymentBloc = BlocProvider.of<PaymentBloc>(context);
  var myState = myPaymentBloc.state;
  if (myState is PayOrder) {
    var myOrder = myState.order;
    if (success) {
      String? value = AssignmentHelper.getResultFor(
          assignmentModel, PayTaskModel.payTaskFieldPaymentReference);
      if (value != null) {
        myPaymentBloc.add(PaymentDoneWithSuccess(myOrder, value));
      } else {
        print("No result found for payment");
      }
    } else {
      String? value = AssignmentHelper.getResultFor(
          assignmentModel, PayTaskModel.payTaskFieldError);
      if (value != null) {
        myPaymentBloc.add(PaymentDoneWithFailure(myOrder, value));
      } else {
        print("No result found for payment");
      }
    }
  }
}