Esempio n. 1
0
        /*
         * Sends the file.
         */
        public string SendToCnp()
        {
            var useEncryption     = config.GetValue("useEncryption");
            var vantivPublicKeyId = config.GetValue("vantivPublicKeyId");

            // Serialize the file.
            var requestFilePath      = this.Serialize();
            var batchRequestDir      = requestDirectory;
            var finalRequestFilePath = requestFilePath;

            // Encrypt the file.
            if ("true".Equals(useEncryption))
            {
                batchRequestDir = Path.Combine(requestDirectory, "encrypted");
                Console.WriteLine(batchRequestDir);
                finalRequestFilePath =
                    Path.Combine(batchRequestDir, Path.GetFileName(requestFilePath) + ".encrypted");
                cnpFile.CreateDirectory(finalRequestFilePath);
                PgpHelper.EncryptFile(requestFilePath, finalRequestFilePath, vantivPublicKeyId);
            }

            // Drop off the file.
            communication.FtpDropOff(batchRequestDir, Path.GetFileName(finalRequestFilePath), config);

            // Return the file name.
            return(Path.GetFileName(finalRequestFilePath));
        }
Esempio n. 2
0
        //public cnpResponse sendToCnpWithStream()
        //{
        //    var requestFilePath = this.Serialize();
        //    var batchName = Path.GetFileName(requestFilePath);

        //    var responseFilePath = communication.SocketStream(requestFilePath, responseDirectory, config);

        //    var cnpResponse = (cnpResponse)cnpXmlSerializer.DeserializeObjectFromFile(responseFilePath);
        //    return cnpResponse;
        //}

        public string sendToCnp()
        {
            var useEncryption     = config.ContainsKey("useEncryption")? config["useEncryption"] : "false";
            var vantivPublicKeyId = config.ContainsKey("vantivPublicKeyId")? config["vantivPublicKeyId"] : "";

            var requestFilePath      = this.Serialize();
            var batchRequestDir      = requestDirectory;
            var finalRequestFilePath = requestFilePath;

            if ("true".Equals(useEncryption))
            {
                batchRequestDir = Path.Combine(requestDirectory, "encrypted");
                Console.WriteLine(batchRequestDir);
                finalRequestFilePath =
                    Path.Combine(batchRequestDir, Path.GetFileName(requestFilePath) + ".encrypted");
                cnpFile.createDirectory(finalRequestFilePath);
                PgpHelper.EncryptFile(requestFilePath, finalRequestFilePath, vantivPublicKeyId);
            }

            communication.FtpDropOff(batchRequestDir, Path.GetFileName(finalRequestFilePath), config);

            return(Path.GetFileName(finalRequestFilePath));
        }