コード例 #1
0
  public GetRecurringPaymentsProfileDetailsResposta getRecurringPaymentsProfileDetails(
      Map<String, String[]> parametros) throws IllegalStateException {

    StringBuilder param = new StringBuilder();
    GetRecurringPaymentsProfileDetailsResposta resp = null;

    try {
      HttpsURLConnection conn =
          Util.getConexaoHttps((String) parametros.get("NAOENVIAR_ENDPOINT")[0]);

      logger.info("Parametros da chamada GetRecurringPaymentsProfileDetails:");
      for (Map.Entry<String, String[]> item : parametros.entrySet()) {
        if (podeEnviarParametro(item.getKey(), item.getValue()[0])) {
          param.append(item.getKey() + "=" + URLEncoder.encode(item.getValue()[0], "UTF-8") + "&");
          logger.info("     " + item.getKey() + ": " + item.getValue()[0] + "&");
        }
      }

      OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
      logger.info("Chamada a: " + conn.getURL() + " com os parametros: " + param.toString());

      writer.write(param.toString());
      writer.flush();
      writer.close();

      InputStreamReader in = new InputStreamReader(conn.getInputStream());

      param = null;
      param = new StringBuilder();

      BufferedReader reader = new BufferedReader(in);

      String data;

      logger.info("Retorno da chamada: ");
      while ((data = reader.readLine()) != null) {
        param.append(data);
      }

      /*if (data.contains("TOKEN")) {
      param.append("==================================================");
      }*/

      data = param.toString();

      GetRecurringPaymentsProfileDetailsParser parser =
          GetRecurringPaymentsProfileDetailsParser.getInstance();
      resp = parser.parse(data);

      logger.info(data);

    } catch (IOException ex) {
      logger.fatal(
          "Erro ao executar GetRecurringPaymentsProfileDetails: " + ex.getLocalizedMessage(), ex);
    }

    return resp;
  }
コード例 #2
0
  /**
   * Executa o metodo SetExpressCheckout
   *
   * @param parametros Parametros recebido do formulario ou do sistema do cliente
   */
  public SetExpressCheckoutResposta setExpressCheckout(Map<String, String[]> parametros)
      throws IllegalStateException {

    StringBuilder param = new StringBuilder();
    SetExpressCheckoutResposta resp = null;

    if (this.getCredenciais() == null) {
      throw new IllegalStateException("As credencais do merchant nao foram informadas.");
    }

    try {
      HttpsURLConnection conn =
          Util.getConexaoHttps((String) parametros.get("NAOENVIAR_ENDPOINT")[0]);

      logger.info("Parametros da chamada:");
      logger.info("Conectando-se a " + conn.getURL());
      for (Map.Entry<String, String[]> item : parametros.entrySet()) {
        if (podeEnviarParametro(item.getKey(), item.getValue()[0])) {
          param.append(item.getKey() + "=" + URLEncoder.encode(item.getValue()[0], "UTF-8") + "&");
          logger.info("     " + item.getKey() + ": " + item.getValue()[0] + "&");
        }
      }

      OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
      // logger.info("Chamada: " + param.toString());

      writer.write(param.toString());
      writer.flush();
      writer.close();

      InputStreamReader in = new InputStreamReader(conn.getInputStream());

      param = null;
      param = new StringBuilder();

      BufferedReader reader = new BufferedReader(in);

      String data;

      logger.info("Retorno da chamada: ");
      while ((data = reader.readLine()) != null) {
        param.append(data);
      }

      data = param.toString();

      SetExpressCheckoutParser parser = SetExpressCheckoutParser.getInstance();
      resp = parser.parse(data);

      // logger.debug("Resposta do SetExpressCheckout: " + resp.toString());

    } catch (IOException ex) {
      logger.fatal("Erro ao executar SetExpressCheckout: " + ex.getLocalizedMessage(), ex);
    }

    return resp;
  }