Example #1
0
        public static void Run()
        {
            var id = "12345";

            // Provide the File Name
            const string fileName = "BatchDetailsReport.csv";

            // Provide the path where the file needs to be downloaded
            // This can be either a relative path or an absolute path
            const string downloadFilePath = @".\Resource\" + fileName;

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new TransactionBatchesApi(clientConfig);
                var content     = apiInstance.GetTransactionBatchDetailsWithHttpInfo(id);

                File.WriteAllText(downloadFilePath, CreateXml(content.Data));

                Console.WriteLine("\nDetails downloaded at the below location:");
                Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
            }
        }
        public static void Run()
        {
            var id = "12345";

            const string fileName         = "BatchDetailsReport.csv";
            const string downloadFilePath = @".\Resource\" + fileName;
            var          uploadDate       = DateTime.ParseExact("2019-08-30", "yyyy-MM-dd", CultureInfo.InvariantCulture);
            string       status           = "Rejected";

            try
            {
                var configDictionary = new Configuration().GetConfiguration();
                var clientConfig     = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary);

                var apiInstance = new TransactionBatchesApi(clientConfig);
                var content     = apiInstance.GetTransactionBatchDetailsWithHttpInfo(id, uploadDate, status);

                // START : FILE DOWNLOAD FUNCTIONALITY
                File.WriteAllText(downloadFilePath, CreateXml(content.Data));

                Console.WriteLine("\nFile Downloaded at the following location : ");
                Console.WriteLine($"{Path.GetFullPath(downloadFilePath)}\n");
                // END : FILE DOWNLOAD FUNCTIONALITY
            }
            catch (FileNotFoundException)
            {
                Console.WriteLine("File Not Found : Kindly verify the path.");
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception on calling the API : " + e.Message);
            }
        }