onRedirectJS method

Future<void> onRedirectJS(
  1. JavaScriptMessage message
)

Implementation

Future<void> onRedirectJS(JavaScriptMessage message) async {
  print("flutterWebView : ${message.message}");

  try {
    // final data = json.decode(message.message);
    Map<String, dynamic> data = jsonDecode(message.message);

    // print("onRedirectJS : $data");

    switch(data["event"]) {
      case "cancel":
        onProgressShow(false);
        widget.paymentResult = BootpayPaymentResult.CANCEL;
        if (this.widget.onCancel != null) this.widget.onCancel!(message.message);
        debounceClose();
        break;
      case "error":
        onProgressShow(false);
        widget.paymentResult = BootpayPaymentResult.ERROR;
        if (this.widget.onError != null) this.widget.onError!(message.message);
        if(this.widget.payload?.extra?.displayErrorResult != true) {
          debounceClose();
        }
        break;
      case "close":
        onProgressShow(false);
        debounceClose();
        break;
      case "issued":
        onProgressShow(false);

        if (this.widget.onIssued != null) this.widget.onIssued!(message.message);
        if(this.widget.payload?.extra?.displaySuccessResult != true) {
          debounceClose();
        }
        break;
      case "confirm":
        onProgressShow(true);
        await goConfirmEvent(message);
        break;
      case "done":
        onProgressShow(false);
        widget.paymentResult = BootpayPaymentResult.DONE;

        if (this.widget.onDone != null) this.widget.onDone!(message.message);
        if(this.widget.payload?.extra?.displaySuccessResult != true) {
          debounceClose();
        } else {
          if(this.widget.isWidget != true) { // 위젯이 아닌 생체인증 결제일 경우에는 닫아버리면 됨
            final content = data["data"]["method_origin_symbol"];
            if(content == "card_rebill_rest") {
              debounceClose();
            }
          }
        }

        // if(this.widget.payload?.widgetKey != null) {
        //   //widget 처리 방식
        //   // if (this.widget.onDone != null) this.widget.onDone!(message.message);
        // } else {
        //   //기존 결제 처리 방식
        //   if (this.widget.onDone != null) this.widget.onDone!(message.message);
        //   if(this.widget.payload?.extra?.displaySuccessResult != true) {
        //     debounceClose();
        //   } else {
        //     final content = data["data"]["method_origin_symbol"];
        //     if(content == "card_rebill_rest") {
        //       debounceClose();
        //     }
        //   }
        // }


        break;
      case "bootpayWidgetFullSizeScreen":
        if (this.widget.onFullSizeScreen != null) this.widget.onFullSizeScreen!(message.message);
        break;

      case "bootpayWidgetRevertScreen":
        print("bootpayWidgetRevertScreen called");
        if (this.widget.onRevertScreen != null) this.widget.onRevertScreen!(message.message);
        break;
    }
  } catch (e) {
    print("Error parsing JSON: $e");
  }

}