onEasySuccess method

JavascriptChannel onEasySuccess(
  1. BuildContext context
)

Implementation

JavascriptChannel onEasySuccess(BuildContext context) {
  return JavascriptChannel(
      name: 'BootpayEasySuccess',
      onMessageReceived: (JavascriptMessage message) {
        BootpayPrint('BootpayEasySuccess: ${c.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
        ].contains(c.requestType.value)) {
          job.type = c.requestType.value;
          job.token = message.message.replaceAll("\"", "");
          if (widget.onNextJob != null) widget.onNextJob!(job);
        } else if(c.requestType.value == BioConstants.REQUEST_ADD_BIOMETRIC_FOR_PAY) {
          BioMetric bioMetric = BioMetric.fromJson(json.decode(message.message));

          // NextJob job = NextJob();
          job.type = c.requestType.value;
          job.nextType = BioConstants.NEXT_JOB_GET_WALLET_LIST;
          job.biometricSecretKey = bioMetric.biometricSecretKey ?? '';
          job.biometricDeviceUuid = bioMetric.biometricDeviceUuid ?? '';
          if (widget.onNextJob != null) widget.onNextJob!(job);
        } else {
          if(c.requestType.value == BioConstants.REQUEST_PASSWORD_FOR_PAY) {
            job.initToken = true;
            if (widget.onNextJob != null) widget.onNextJob!(job);
          }
          c.requestType.value = BioConstants.REQUEST_TYPE_NONE;
          if (widget.onDone != null) widget.onDone!(message.message);
        }
      });
}