onWebViewEasySuccess method

void onWebViewEasySuccess(
  1. JavaScriptMessage message
)

Implementation

void onWebViewEasySuccess(JavaScriptMessage message) {
  // BootpayPrint('onWebViewEasySuccess: ${requestType}, ${message.message}');

  NextJob job = NextJob();
  if([BioConstants.REQUEST_PASSWORD_TOKEN,
    BioConstants.REQUEST_PASSWORD_TOKEN_FOR_ADD_CARD,
    BioConstants.REQUEST_PASSWORD_TOKEN_DELETE_CARD,
    BioConstants.REQUEST_PASSWORD_TOKEN_FOR_BIO_FOR_PAY,
    BioConstants.REQUEST_PASSWORD_TOKEN_FOR_PASSWORD_FOR_PAY
  ].contains(requestType.value)) {
    job.type = requestType.value;
    job.token = message.message.replaceAll("\"", "");
    if(requestType.value != BioConstants.REQUEST_PASSWORD_TOKEN_DELETE_CARD) {
      job.nextType = BioConstants.NEXT_JOB_RETRY_PAY;
    } else {
      job.nextType = BioConstants.REQUEST_DELETE_CARD;
    }
    if (onCallbackNextJob != null) onCallbackNextJob!(job);

  } else if(requestType.value == BioConstants.REQUEST_ADD_BIOMETRIC_FOR_PAY) {
    BioMetric bioMetric = BioMetric.fromJson(json.decode(message.message));

    // NextJob job = NextJob();
    job.type = requestType.value;
    job.nextType = BioConstants.NEXT_JOB_GET_WALLET_LIST;
    job.biometricSecretKey = bioMetric.biometricSecretKey ?? '';
    job.biometricDeviceUuid = bioMetric.biometricDeviceUuid ?? '';
    job.serverUnixtime = bioMetric.serverUnixtime ?? 0;
    if (onCallbackNextJob != null) onCallbackNextJob!(job);
    // onNextJob(job);
  } else {
    if([
        BioConstants.REQUEST_PASSWORD_FOR_PAY,
        BioConstants.REQUEST_ADD_CARD,
      ].contains(requestType.value)) {
      job.initToken = true;
      // onNextJob(job);
      if (onCallbackNextJob != null) onCallbackNextJob!(job);
      // if (widget.onNextJob != null) widget.onNextJob!(job);
    }

    if([
      BioConstants.REQUEST_DELETE_CARD,
      BioConstants.REQUEST_ADD_CARD,
    ].contains(requestType.value)) {
      //카드 등록과 삭제시에는 confirm을 보내지 않는다
      getWalletList(payload?.userToken ?? '');
      isShowWebView.value = false; //카드 선택화면으로 돌아간다
      return;
    }

    if(payload?.extra?.separatelyConfirmedBio == true) {
      if(onCallbackConfirm != null) {
        onCallbackConfirm!(message.message);
      } else if(onCallbackConfirmAsync != null) {
        onCallbackConfirmAsync!(message.message);
      }
    } else {
      //redirect 가 아니고, 분리승인일 수 있음  (통합결제)
      if(payload?.extra?.openType != 'redirect') {
        final data = json.decode(message.message);
        switch(data["event"]) {
          case "confirm":
            goConfirmEvent(message);
            break;
          case "done":
            if(onCallbackDone != null) onCallbackDone!(message.message);
            if(payload?.extra?.displaySuccessResult != true) {
              if(onCallbackDebounceClose != null) onCallbackDebounceClose!();
            }
            break;
        }
        return;
      }

      //그 외 처리
      if(onCallbackDone != null) onCallbackDone!(message.message);
      if(onCallbackDebounceClose != null) onCallbackDebounceClose!(); //생체인증 결제시 가끔 done보다 close가 빨리 떨어져서, 여기서 close이벤트를 보낸다
      // if(requestType.value == BioConstants.REQUEST_BIO_FOR_PAY) { //생체인증 결제시 가끔 done보다 close가 빨리 떨어져서, 여기서 close이벤트를 보낸다
      //   if(payload?.extra?.displaySuccessResult != true) {
      //
      //
      //   }
      // }
    }
  }
}