public static void main(String[] args) {

    // Substitute the code below with a notification code for your transaction.
    // You receive this notification code through a post on the URL that you specify in
    // this page:
    /** @link https://pagseguro.uol.com.br/integracao/notificacao-de-transacoes.jhtml */
    String notificationCode = "512AF8-49E2FBE2FB71-799426FFAC58-90F5C1";

    Transaction transaction = null;
    try {
      // Check transaction
      transaction =
          NotificationService.checkTransaction(
              new AccountCredentials(
                  "*****@*****.**", "95112EE828D94278BD394E91C4388F20"),
              notificationCode);
    } catch (PagSeguroServiceException e) {
      System.err.println(e.toString());
    }

    if (transaction != null) {
      System.out.println("transaction code: " + transaction.getCode());
      System.out.println("transaction status: " + transaction.getStatus());
    }
  }
  /**
   * Finds a transaction with a matching transaction code
   *
   * @param credentials
   * @param transactionCode
   * @return a transaction in PagSeguro
   * @see Transaction
   * @throws PagSeguroServiceException
   */
  public static Transaction searchByCode(Credentials credentials, String transactionCode)
      throws PagSeguroServiceException {

    log.info(
        "TransactionSearchService.SearchByCode(transactionCode=" + transactionCode + ") - begin");

    if (transactionCode == null || transactionCode.trim().equals("")) {
      throw new IllegalArgumentException("transaction code can not be null");
    }

    // calling transaction search web service
    HttpURLConnection connection =
        HttpsURLConnectionUtil.getHttpsGetConnection(
            buildURLByCode(credentials, transactionCode), CONTENT_TYPE);

    try {
      // parsing transaction
      Transaction transaction = TransactionParser.readTransaction(connection.getInputStream());
      log.info(
          "TransactionSearchService.SearchByCode(transactionCode="
              + transactionCode
              + ") - end - "
              + transaction.toString());
      return transaction;
    } catch (Exception e) {
      log.error(
          "TransactionSearchService.SearchByCode(transactionCode=" + transactionCode + ") - error",
          e);
      throw new RuntimeException(e);
    } finally {
      connection.disconnect();
    }
  }