コード例 #1
0
  @Override
  public void saveModule() throws Exception {

    Context ctx =
        (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
    Integer merchantid = ctx.getMerchantid();

    // need validation
    boolean hasError = false;

    if (StringUtils.isBlank(this.getKeys().getProperties1())) {
      addFieldError("keys.properties1", getText("error.payment.paypal.userid.required"));
      hasError = true;
    }

    if (StringUtils.isBlank(this.getKeys().getProperties2())) {
      addFieldError("keys.properties2", getText("error.payment.paypal.password.required"));
      hasError = true;
    }

    if (StringUtils.isBlank(this.getKeys().getProperties3())) {
      addFieldError("keys.properties3", getText("error.payment.paypal.signature.required"));
      hasError = true;
    }

    String value2 = this.getKeys().getProperties5();
    this.getKeys().setProperties5("");

    String value1 = MerchantConfigurationUtil.getConfigurationValue(this.getKeys(), "|");

    ConfigurationResponse vo = this.getConfigurations();
    MerchantConfiguration conf = null;
    if (vo != null) {
      conf = (MerchantConfiguration) vo.getConfiguration(PaymentConstants.PAYMENT_PAYPALNAME);
    }
    if (conf != null) {
      conf.setConfigurationValue(value1);
      conf.setConfigurationValue1(value2);

    } else {

      conf = new MerchantConfiguration();
      conf.setMerchantId(merchantid);

      conf.setConfigurationModule(moduleid);
      conf.setConfigurationKey(
          PaymentConstants.MODULE_PAYMENT + PaymentConstants.PAYMENT_PAYPALNAME);
      conf.setConfigurationValue(value1); // userid | password | signature
      conf.setConfigurationValue1(value2); // environment
    }

    MerchantService mservice =
        (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
    mservice.saveOrUpdateMerchantConfiguration(conf);
  }