@Override
  public void prepareModule() throws Exception {
    Context ctx =
        (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
    Integer merchantid = ctx.getMerchantid();

    ReferenceService rservice =
        (ReferenceService) ServiceFactory.getService(ServiceFactory.ReferenceService);

    Locale locale = getLocale();

    String country = locale.getCountry();
    if (locale.getVariant().equals("EUR")) {
      country = "X1";
    }

    Map packages = ShippingUtil.buildPackageMap(moduleid, locale);
    if (packages != null) {
      setPackageMap(packages);
    }

    // get merchant configs
    MerchantService mservice =
        (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);

    ConfigurationResponse config = mservice.getConfigurationByModule(moduleid, merchantid);
    this.setConfigurations(config);
  }
  @Override
  public void prepareModule() throws Exception {

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

    MerchantService mservice =
        (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);

    String text =
        LabelUtil.getInstance().getText(super.getLocale(), "label.payment.methods.title.papal");
    this.setMessage(text);

    MerchantStore mstore = mservice.getMerchantStore(merchantid);

    if (mstore == null) {
      MessageUtil.addErrorMessage(
          super.getServletRequest(),
          LabelUtil.getInstance().getText("errors.profile.storenotcreated"));
    }

    ConfigurationResponse config = mservice.getConfigurationByModule(moduleid, merchantid);
    this.setConfigurations(config);
  }
  @Override
  public void deleteModule() throws Exception {
    Context ctx =
        (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
    Integer merchantid = ctx.getMerchantid();

    MerchantService mservice =
        (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
    mservice.cleanConfigurationLikeKeyModule("SHP_RT_", moduleid, merchantid);
  }
  @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);
  }
Ejemplo n.º 5
0
  public String deleteFile() {

    super.setPageTitle("label.media.binmanagement");
    Context ctx =
        (Context) super.getServletRequest().getSession().getAttribute(ProfileConstants.context);
    Integer merchantid = ctx.getMerchantid();
    FileModule futil = (FileModule) SpringUtil.getBean("localfile");
    futil.deleteFile(merchantid, new File(deleteFilePath));
    super.setSuccessMessage();
    return SUCCESS;
  }
Ejemplo n.º 6
0
  public String uploadToBin() {

    super.setPageTitle("label.media.binmanagement");

    super.getServletRequest().setAttribute("Type", this.getType());
    if (isBlank()) {
      setErrorMessage(getText("error.upload.required"));
      return INPUT;
    }
    Context ctx = super.getContext();
    Integer merchantid = ctx.getMerchantid();
    FileModule futil = (FileModule) SpringUtil.getBean("localfile");
    ContentCategoryType contentType = FileUtil.getContentCategoryType(uploadContentType);
    if (ContentCategoryType.IMAGE.equals(contentType)) {

      try {
        futil.copyFile(
            merchantid,
            "core.bin.images",
            getUpload(),
            getUploadFileName(),
            getUploadContentType());
      } catch (FileException e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else if (ContentCategoryType.FLASH.equals(contentType)) {
      try {
        futil.copyFile(
            merchantid, "core.bin.flash", getUpload(), getUploadFileName(), getUploadContentType());
      } catch (Exception e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else if (ContentCategoryType.FILE.equals(contentType)) {
      try {
        futil.copyFile(
            merchantid, "core.bin.files", getUpload(), getUploadFileName(), getUploadContentType());
      } catch (Exception e) {
        log.error(e);
        super.setTechnicalMessage();
        return INPUT;
      }
    } else {
      setErrorMessage(getText("error.bin.upload.invalid.type"));
      return INPUT;
    }
    super.setSuccessMessage();
    return SUCCESS;
  }
  @Override
  public void saveModule() throws Exception {
    boolean fielderror = false;
    if (this.getKeys() == null || StringUtils.isBlank(this.getKeys().getKey1())) {
      addFieldError("keys.key1", getText("errors.required.fedexkey"));
      fielderror = true;
    }
    if (StringUtils.isBlank(this.getKeys().getUserid())) {
      addFieldError("keys.userid", getText("errors.required.userid"));
      fielderror = true;
    }
    if (StringUtils.isBlank(this.getKeys().getPassword())) {
      addFieldError("keys.password", getText("errors.required.fedexpassword"));
      fielderror = true;
    }
    if (StringUtils.isBlank(this.getKeys().getKey2())) {
      addFieldError("keys.key2", getText("errors.required.fedexmeter"));
      fielderror = true;
    }

    if (fielderror) {
      throw new ValidationException("Missing fields");
    }

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

    String submitedcredentials = ShippingUtil.buildShippingKeyLine(keys);

    String submitedproperties = ShippingUtil.buildShippingPropertiesLine(this.getProperties());

    String packageOption = getPackageSelection();

    List modulestosave =
        ShippingUtil.arrangeConfigurationsToSave(
            merchantid,
            configurations,
            moduleid,
            submitedcredentials,
            submitedproperties,
            packageOption,
            null,
            null);

    MerchantService mservice =
        (MerchantService) ServiceFactory.getService(ServiceFactory.MerchantService);
    mservice.saveOrUpdateMerchantConfigurations(modulestosave);
  }
  @Override
  public void displayModule() throws Exception {
    // get userid and descriptions

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

    // get payto / address
    ConfigurationResponse vo = this.getConfigurations();
    IntegrationProperties k = (IntegrationProperties) vo.getConfiguration("properties");

    if (k != null) {
      this.setKeys(k);
    } else {
      keys.setProperties1("");
      keys.setProperties2("");
      keys.setProperties3("");
      keys.setProperties5("0");
    }
  }