getBootpayJS method

String getBootpayJS()

Implementation

String getBootpayJS() {
  String requestMethod = 'requestPayment';
  if(this.widget.requestType == BootpayConstant.REQUEST_TYPE_SUBSCRIPT) {
    requestMethod = 'requestSubscription';
  } else if(this.widget.requestType == BootpayConstant.REQUEST_TYPE_AUTH) {
    requestMethod = 'requestAuthentication';
  } else if(this.widget.requestType == BootpayConstant.REQUEST_TYPE_PASSWORD) {
    this.widget.payload?.method = "카드간편";
    this.widget.payload?.extra?.separatelyConfirmed = false;
  }

  String script = "Bootpay.${requestMethod}(" +
      "${this.widget.payload.toString()}" +
      ")" +
      ".then( function (res) {" +
      widget.confirmEventHandler +
      widget.issuedEventHandler +
      widget.doneEventHandler +
      "}, function (res) {" +
      widget.errorEventHandler +
      widget.cancelEventHandler +
      "})";

  return script;
}