handleCreditCardPayment method

void handleCreditCardPayment(
  1. AppModel app,
  2. BuildContext theContext,
  3. AssignmentModel? theAssignmentModel,
  4. PaymentStatus status,
)

Implementation

void handleCreditCardPayment(AppModel app, BuildContext theContext,
    AssignmentModel? theAssignmentModel, PaymentStatus status) {
  if (status is PaymentSucceeded) {
    // now store in results status.reference;
    finishTask(
        app,
        theContext,
        theAssignmentModel!,
        ExecutionResults(ExecutionStatus.success, results: [
          AssignmentResultModel(
              documentID: newRandomKey(),
              key: payTaskFieldPaymentType,
              value: 'Credit card'),
          AssignmentResultModel(
              documentID: newRandomKey(),
              key: payTaskFieldPaymentReference,
              value: status.reference)
        ]),
        null);
  } else if (status is PaymentFailure) {
    finishTask(
        app,
        theContext,
        theAssignmentModel!,
        ExecutionResults(ExecutionStatus.failure, results: [
          AssignmentResultModel(
              documentID: newRandomKey(),
              key: payTaskFieldPaymentType,
              value: 'Credit card'),
          AssignmentResultModel(
              documentID: newRandomKey(),
              key: payTaskFieldPaymentReference,
              value: status.reference),
          AssignmentResultModel(
              documentID: newRandomKey(),
              key: payTaskFieldError,
              value: status.error)
        ]),
        null);
  }
}