diff --git a/Source/Configuration.cs b/Source/Configuration.cs index e11d837..dc8452f 100644 --- a/Source/Configuration.cs +++ b/Source/Configuration.cs @@ -118,6 +118,21 @@ public Dictionary GetIntermediateConfiguration() // _configurationDictionary.Add("proxyUsername", string.Empty); // _configurationDictionary.Add("proxyPassword", string.Empty); return _configurationDictionary; + } + + public Dictionary GetMerchantDetailsForBatchUploadSample() + { + _configurationDictionary.Add("authenticationType", "JWT"); + _configurationDictionary.Add("merchantID", "qaebc2"); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + + _configurationDictionary.Add("keyAlias", "qaebc2"); + _configurationDictionary.Add("keyPass", "?Test1234"); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", "qaebc2"); + return _configurationDictionary; } + + } } diff --git a/Source/Resource/batchapiTest.csv b/Source/Resource/batchapiTest.csv new file mode 100644 index 0000000..0b8df03 --- /dev/null +++ b/Source/Resource/batchapiTest.csv @@ -0,0 +1,5 @@ +merchantID=qaebc2,batchID=rgdltnd0,recordCount=2,statusEmail=ynachire@visa.com,targetAPIVersion=1.86,creationDate=2025-03-05,reference= +merchantID,merchantReferenceCode,merchantDefinedData_field1,ccAuthService_run,billTo_firstName,billTo_lastName,billTo_email,billTo_street1,billTo_city,billTo_state,billTo_country,billTo_postalCode,card_accountNumber,card_expirationMonth,card_expirationYear,card_cardType,purchaseTotals_currency,purchaseTotals_grandTotalAmount,item_#_productCode +qaebc2,1,4837,true,Jay,Smith,ynachire@visa.com,8 Mission Street,San Francisco,CA,US,94101,4111111111111111,12,2036,001,GBP,8.00,1 +qaebc2,2,7209,true,Jay,Smith,ynachire@visa.com,8 Mission Street,San Francisco,CA,US,94101,4111111111111111,12,2036,001,GBP,8.00,1 +END,SUM=16.00 \ No newline at end of file diff --git a/Source/Resource/qaebc2.p12 b/Source/Resource/qaebc2.p12 new file mode 100644 index 0000000..a66a4e2 Binary files /dev/null and b/Source/Resource/qaebc2.p12 differ diff --git a/Source/Samples/TransactionBatches/UploadTransactionBatch.cs b/Source/Samples/TransactionBatches/UploadTransactionBatch.cs new file mode 100644 index 0000000..c8ac11b --- /dev/null +++ b/Source/Samples/TransactionBatches/UploadTransactionBatch.cs @@ -0,0 +1,55 @@ +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; +using Cybersource_rest_samples_dotnet; +using System; +using System.Collections.Generic; +using System.Configuration; +using System.IO; +using System.Text; + +namespace Cybersource_rest_samples_dotnet.Samples.TransactionBatches +{ + public class UploadTransactionBatch + { + public static void WriteLogAudit(int status) + { + var filePath = System.Reflection.MethodBase.GetCurrentMethod().DeclaringType.ToString().Split('.'); + var filename = filePath[filePath.Length - 1]; + Console.WriteLine($"[Sample Code Testing] [{filename}] {status}"); + } + + public static void Run() + { + // Get the file path from the resources folder + String filename = "batchapiTest.csv"; + + Stream file = null; + try + { + string filePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource", filename); + file = new FileStream(filePath, FileMode.Open, FileAccess.Read); + } + catch (FileNotFoundException) + { + Console.WriteLine("File Not Found : Kindly verify the path."); + } + + try + { + var configDictionary = new Cybersource_rest_samples_dotnet.Configuration().GetMerchantDetailsForBatchUploadSample(); + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + var apiInstance = new TransactionBatchesApi(clientConfig); + ApiResponse result = apiInstance.UploadTransactionBatchWithHttpInfo(file); + Console.WriteLine(result); + WriteLogAudit(result.StatusCode); + } + catch (ApiException e) + { + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + } + } + + } +} diff --git a/cybersource-rest-samples-csharp.csproj b/cybersource-rest-samples-csharp.csproj index 7709777..abedbc7 100644 --- a/cybersource-rest-samples-csharp.csproj +++ b/cybersource-rest-samples-csharp.csproj @@ -376,6 +376,7 @@ + @@ -446,6 +447,8 @@ + +