diff --git a/Source/AuthenticationData/RequestData.cs b/Source/AuthenticationData/RequestData.cs index 0fb7f5d..0acba81 100644 --- a/Source/AuthenticationData/RequestData.cs +++ b/Source/AuthenticationData/RequestData.cs @@ -1,119 +1,119 @@ -using System; -using System.IO; -using ApiSdk.model; -using Newtonsoft.Json; -using NLog; - -namespace SampleCode.data -{ - public class RequestData - { - private readonly Logger _logger = LogManager.GetCurrentClassLogger(); - - public string JsonFileData(string path) - { - if (string.IsNullOrEmpty(path)) - { - throw new Exception($"Error: Empty/Null Path provided to JsonFileData Function"); - } - - Console.WriteLine($"\n Using Payload of the Json File at:{Path.GetFullPath(path)}"); - _logger.Trace($"Using Payload of the Json File at:{Path.GetFullPath(path)}"); - - try - { - using (var r = new StreamReader(path)) - { - return r.ReadToEnd(); - } - } - catch (FileNotFoundException) - { - throw new Exception($"Error: Request Json File missing. File Path :: {path}"); - } - } - - public string SamplePaymentsData() - { - // Create the Sample Data using Model Classes of Payments API - Console.WriteLine("\n Using sample Payload of Payments"); - _logger.Trace("Using sample Payload of Payments"); - - var clientReferenceInformation = new ClientReferenceInformation { code = "TC50171_3" }; - - var processingInformation = new ProcessingInformation { commerceIndicator = "internet" }; - - var subMerchant = new SubMerchant - { - cardAcceptorID = "1234567890", - country = "US", - phoneNumber = "650-432-0000", - address1 = "900 Metro Center", - postalCode = "94404-2775", - locality = "Foster Cit", - name = "Visa Inc", - administrativeArea = "CA", - region = "PEN", - email = "test@cybs.com" - }; - - var aggregatorInformation = new AggregatorInformation - { - subMerchant = subMerchant, - name = "V-Internatio", - aggregatorID = "123456789" - }; - - var billTo = new BillTo - { - country = "US", - lastName = "VDP", - address2 = "Address 2", - address1 = "201 S. Division St.", - postalCode = "48104-2201", - locality = "Ann Arbor", - administrativeArea = "MI", - firstName = "RTS", - phoneNumber = "999999999", - district = "MI", - buildingNumber = "123", - company = "Visa", - email = "test@cybs.com" - }; - - var amountDetails = new AmountDetails - { - totalAmount = "102.21", - currency = "USD" - }; - - var orderInformation = new OrderInformation - { - billTo = billTo, - amountDetails = amountDetails - }; - - var card = new Card - { - expirationYear = "2031", - number = "5555555555554444", - securityCode = "123", - expirationMonth = "12", - type = "002" - }; - - var paymentInformation = new PaymentInformation { card = card }; - - var payments = new Payments - { - clientReferenceInformation = clientReferenceInformation, - processingInformation = processingInformation, - aggregatorInformation = aggregatorInformation, - orderInformation = orderInformation, - paymentInformation = paymentInformation - }; - - return JsonConvert.SerializeObject(payments, Formatting.Indented); - } - } -} +//using System; +//using System.IO; +//using ApiSdk.model; +//using Newtonsoft.Json; +//using NLog; + +//namespace SampleCode.data +//{ +// public class RequestData +// { +// private readonly Logger _logger = LogManager.GetCurrentClassLogger(); + +// public string JsonFileData(string path) +// { +// if (string.IsNullOrEmpty(path)) +// { +// throw new Exception($"Error: Empty/Null Path provided to JsonFileData Function"); +// } + +// Console.WriteLine($"\n Using Payload of the Json File at:{Path.GetFullPath(path)}"); +// _logger.Trace($"Using Payload of the Json File at:{Path.GetFullPath(path)}"); + +// try +// { +// using (var r = new StreamReader(path)) +// { +// return r.ReadToEnd(); +// } +// } +// catch (FileNotFoundException) +// { +// throw new Exception($"Error: Request Json File missing. File Path :: {path}"); +// } +// } + +// public string SamplePaymentsData() +// { +// // Create the Sample Data using Model Classes of Payments API +// Console.WriteLine("\n Using sample Payload of Payments"); +// _logger.Trace("Using sample Payload of Payments"); + +// var clientReferenceInformation = new ClientReferenceInformation { code = "TC50171_3" }; + +// var processingInformation = new ProcessingInformation { commerceIndicator = "internet" }; + +// var subMerchant = new SubMerchant +// { +// cardAcceptorID = "1234567890", +// country = "US", +// phoneNumber = "650-432-0000", +// address1 = "900 Metro Center", +// postalCode = "94404-2775", +// locality = "Foster Cit", +// name = "Visa Inc", +// administrativeArea = "CA", +// region = "PEN", +// email = "test@cybs.com" +// }; + +// var aggregatorInformation = new AggregatorInformation +// { +// subMerchant = subMerchant, +// name = "V-Internatio", +// aggregatorID = "123456789" +// }; + +// var billTo = new BillTo +// { +// country = "US", +// lastName = "VDP", +// address2 = "Address 2", +// address1 = "201 S. Division St.", +// postalCode = "48104-2201", +// locality = "Ann Arbor", +// administrativeArea = "MI", +// firstName = "RTS", +// phoneNumber = "999999999", +// district = "MI", +// buildingNumber = "123", +// company = "Visa", +// email = "test@cybs.com" +// }; + +// var amountDetails = new AmountDetails +// { +// totalAmount = "102.21", +// currency = "USD" +// }; + +// var orderInformation = new OrderInformation +// { +// billTo = billTo, +// amountDetails = amountDetails +// }; + +// var card = new Card +// { +// expirationYear = "2031", +// number = "5555555555554444", +// securityCode = "123", +// expirationMonth = "12", +// type = "002" +// }; + +// var paymentInformation = new PaymentInformation { card = card }; + +// var payments = new Payments +// { +// clientReferenceInformation = clientReferenceInformation, +// processingInformation = processingInformation, +// aggregatorInformation = aggregatorInformation, +// orderInformation = orderInformation, +// paymentInformation = paymentInformation +// }; + +// return JsonConvert.SerializeObject(payments, Formatting.Indented); +// } +// } +//} 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/Authentication/CallHttpMethods/DeleteMethod.cs b/Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs index 4fc3bf8..d067df9 100644 --- a/Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs @@ -1,59 +1,59 @@ -using System; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; +//using System; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class DeleteMethod - { - // DELETE Request to Delete subscription of (Unsubscribe) a report name by organization - // Below request unsubscribes 'TRR Report' Subscription for Organization ID: testrest - private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class DeleteMethod +// { +// // DELETE Request to Delete subscription of (Unsubscribe) a report name by organization +// // Below request unsubscribes 'TRR Report' Subscription for Organization ID: testrest +// private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; - 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 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() - { - try - { - // Setting up Merchant Config - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.DELETE.ToString() - }; +// public static void Run() +// { +// try +// { +// // Setting up Merchant Config +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.DELETE.ToString() +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.DeletePayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.DeletePayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - if (response.StatusCode == 200 || response.StatusCode == 404) - { - WriteLogAudit(200); - } - else - { - WriteLogAudit(response.StatusCode); - } - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// if (response.StatusCode == 200 || response.StatusCode == 404) +// { +// WriteLogAudit(200); +// } +// else +// { +// WriteLogAudit(response.StatusCode); +// } +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} diff --git a/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs b/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs index 0443fb6..853fd82 100644 --- a/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/GetMethod.cs @@ -1,52 +1,52 @@ -using System; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; +//using System; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class GetMethod - { - // GET request to retrieve the payment details of the provided Payment ID - // Below Request fetches the payment details of payment ID: 5319754772076048103525 - private const string RequestTarget = "/pts/v2/payments/5526383152166546003003"; +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class GetMethod +// { +// // GET request to retrieve the payment details of the provided Payment ID +// // Below Request fetches the payment details of payment ID: 5319754772076048103525 +// private const string RequestTarget = "/pts/v2/payments/5526383152166546003003"; - 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 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() - { - try - { - // Setting up Merchant Config - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.GET.ToString() - }; +// public static void Run() +// { +// try +// { +// // Setting up Merchant Config +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.GET.ToString() +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.GetPayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.GetPayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - WriteLogAudit(response.StatusCode); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} \ No newline at end of file +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// WriteLogAudit(response.StatusCode); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs b/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs index 64b3847..3dc8750 100644 --- a/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/GetObjectMethod.cs @@ -1,56 +1,56 @@ -using System; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class GetObjectMethod - { - // GET request to retrieve the payment details of the provided Payment ID - // Below Request fetches the payment details of payment ID: 5319754772076048103525 - private const string RequestTarget = "/pts/v2/payments/5526478103126428303006"; +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class GetObjectMethod +// { +// // GET request to retrieve the payment details of the provided Payment ID +// // Below Request fetches the payment details of payment ID: 5319754772076048103525 +// private const string RequestTarget = "/pts/v2/payments/5526478103126428303006"; - 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 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() - { - try - { - // Creating a dictionary object which contains the merchant configuration - var config = new Configuration(); +// public static void Run() +// { +// try +// { +// // Creating a dictionary object which contains the merchant configuration +// var config = new Configuration(); - // Passing the dictionary object to the Merchant Config Constructor to bypass the config set up via App.Config File - var merchantConfig = new MerchantConfig(config.GetConfiguration()) - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.GET.ToString() - }; +// // Passing the dictionary object to the Merchant Config Constructor to bypass the config set up via App.Config File +// var merchantConfig = new MerchantConfig(config.GetConfiguration()) +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.GET.ToString() +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.GetPayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.GetPayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - WriteLogAudit(response.StatusCode); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// WriteLogAudit(response.StatusCode); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} diff --git a/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs index 70e2b68..818b06f 100644 --- a/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PostMethod.cs @@ -1,58 +1,58 @@ -using System; -using System.IO; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using System.IO; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class PostMethod - { - // POST Request to Authorize the payment for a transaction. - // Transaction details provided in the JSON File are sent along with the Request as Request Body - private const string RequestTarget = "/pts/v2/payments/"; - private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json").ToString(); +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class PostMethod +// { +// // POST Request to Authorize the payment for a transaction. +// // Transaction details provided in the JSON File are sent along with the Request as Request Body +// private const string RequestTarget = "/pts/v2/payments/"; +// private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json").ToString(); - 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 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() - { - try - { - var requestData = new RequestData(); +// public static void Run() +// { +// try +// { +// var requestData = new RequestData(); - // Setting up Merchant Config - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.POST.ToString(), - RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) - }; +// // Setting up Merchant Config +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.POST.ToString(), +// RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.PostPayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.PostPayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - WriteLogAudit(response.StatusCode); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} \ No newline at end of file +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// WriteLogAudit(response.StatusCode); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs index d84389a..bca22cd 100644 --- a/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PostObjectMethod.cs @@ -1,59 +1,59 @@ -using System; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class PostObjectMethod - { - // POST Request to Authorize the payment for a transaction. - // Transaction details are sent along with the Request as Request Body - private const string RequestTarget = "/pts/v2/payments/"; +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class PostObjectMethod +// { +// // POST Request to Authorize the payment for a transaction. +// // Transaction details are sent along with the Request as Request Body +// private const string RequestTarget = "/pts/v2/payments/"; - 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 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() - { - try - { - // Setting up Merchant Config - var config = new Configuration(); +// public static void Run() +// { +// try +// { +// // Setting up Merchant Config +// var config = new Configuration(); - // Setting RequestJson Data using the sample payments data (instead of reading a JSON file) - var requestData = new RequestData(); +// // Setting RequestJson Data using the sample payments data (instead of reading a JSON file) +// var requestData = new RequestData(); - var merchantConfig = new MerchantConfig(config.GetConfiguration()) - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.POST.ToString(), - RequestJsonData = requestData.SamplePaymentsData() - }; +// var merchantConfig = new MerchantConfig(config.GetConfiguration()) +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.POST.ToString(), +// RequestJsonData = requestData.SamplePaymentsData() +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.PostPayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.PostPayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - WriteLogAudit(response.StatusCode); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} \ No newline at end of file +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// WriteLogAudit(response.StatusCode); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs b/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs index 7d8f64d..b8d1bca 100644 --- a/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs +++ b/Source/Samples/Authentication/CallHttpMethods/PutMethod.cs @@ -1,59 +1,59 @@ -using System; -using System.IO; -using ApiSdk.controller; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using System.IO; +//using ApiSdk.controller; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class PutMethod - { - // PUT Request to Create Report Subscription for a report name by organization - // Report Details provided in the JSON File are sent along with the Request as Request Body - // Below request subscribes 'TRR Report' for Organization ID: testrest - private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; - private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/TRRReport.json"); +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class PutMethod +// { +// // PUT Request to Create Report Subscription for a report name by organization +// // Report Details provided in the JSON File are sent along with the Request as Request Body +// // Below request subscribes 'TRR Report' for Organization ID: testrest +// private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; +// private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/TRRReport.json"); - 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 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() - { - try - { - // Setting up Merchant Config - var requestData = new RequestData(); +// public static void Run() +// { +// try +// { +// // Setting up Merchant Config +// var requestData = new RequestData(); - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.PUT.ToString(), - RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) - }; +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.PUT.ToString(), +// RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) +// }; - // Call to the Controller of API_SDK - var apiController = new APIController(merchantConfig); - var response = apiController.PutPayment(); +// // Call to the Controller of API_SDK +// var apiController = new APIController(merchantConfig); +// var response = apiController.PutPayment(); - // printing the response details - if (response != null) - { - Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); - Console.WriteLine("\n Response Code:{0}", response.StatusCode); - Console.WriteLine("\n Response Message:{0}", response.Data); - WriteLogAudit(response.StatusCode); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - } - } - } -} \ No newline at end of file +// // printing the response details +// if (response != null) +// { +// Console.WriteLine("\n v-c-correlation-id:{0}", response.GetResponseHeaderValue(response.Headers, "v-c-correlation-id")); +// Console.WriteLine("\n Response Code:{0}", response.StatusCode); +// Console.WriteLine("\n Response Message:{0}", response.Data); +// WriteLogAudit(response.StatusCode); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs index df4d1c9..e927a9b 100644 --- a/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PostGenerateHeaders.cs @@ -1,69 +1,69 @@ -using System; -using System.IO; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using System.IO; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class PostGenerateHeaders - { - // POST Request to Authorize the payment for a transaction. - // Transaction details provided in the JSON File are sent along with the Request as Request Body - private const string RequestTarget = "/pts/v2/payments"; - private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json"); +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class PostGenerateHeaders +// { +// // POST Request to Authorize the payment for a transaction. +// // Transaction details provided in the JSON File are sent along with the Request as Request Body +// private const string RequestTarget = "/pts/v2/payments"; +// private static string RequestJsonFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../Source/Resource/request_payments.json"); - 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 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() - { - try - { - var requestData = new RequestData(); +// public static void Run() +// { +// try +// { +// var requestData = new RequestData(); - // Setting up Merchant Config - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.POST.ToString(), - RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) - }; +// // Setting up Merchant Config +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.POST.ToString(), +// RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) +// }; - // Call to the Authorize class of AuthSDK to get the signature and token objects - var authorizeObj = new Authorize(merchantConfig); +// // Call to the Authorize class of AuthSDK to get the signature and token objects +// var authorizeObj = new Authorize(merchantConfig); - if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.HTTP_SIGNATURE.ToString(), StringComparison.OrdinalIgnoreCase)) - { - var requestHeaders = authorizeObj.GetSignature(); +// if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.HTTP_SIGNATURE.ToString(), StringComparison.OrdinalIgnoreCase)) +// { +// var requestHeaders = authorizeObj.GetSignature(); - Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); - Console.WriteLine("{0} {1}", "v-c-merchant-id:", requestHeaders.MerchantId); - Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); - Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); - Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); - Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); - WriteLogAudit(200); - } - else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) - { - var requestHeaders = authorizeObj.GetToken(); +// Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); +// Console.WriteLine("{0} {1}", "v-c-merchant-id:", requestHeaders.MerchantId); +// Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); +// Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); +// Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); +// Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); +// WriteLogAudit(200); +// } +// else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) +// { +// var requestHeaders = authorizeObj.GetToken(); - Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); - Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); - WriteLogAudit(200); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - WriteLogAudit(400); - } - } - } -} \ No newline at end of file +// Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); +// Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); +// WriteLogAudit(200); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// WriteLogAudit(400); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs index 832bf31..6f95efd 100644 --- a/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs +++ b/Source/Samples/Authentication/GenerateHttpRequestHeaders/PutGenerateHeaders.cs @@ -1,68 +1,68 @@ -using System; -using AuthenticationSdk.core; -using AuthenticationSdk.util; -using SampleCode.data; +//using System; +//using AuthenticationSdk.core; +//using AuthenticationSdk.util; +//using SampleCode.data; -namespace Cybersource_rest_samples_dotnet.Samples.Authentication -{ - public class PutGenerateHeaders - { - // PUT Request to Create Report Subscription for a report name by organization - // Report Details provided in the JSON File are sent along with the Request as Request Body - // Below request subscribes 'TRR Report' for Organization ID: testrest - private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; +//namespace Cybersource_rest_samples_dotnet.Samples.Authentication +//{ +// public class PutGenerateHeaders +// { +// // PUT Request to Create Report Subscription for a report name by organization +// // Report Details provided in the JSON File are sent along with the Request as Request Body +// // Below request subscribes 'TRR Report' for Organization ID: testrest +// private const string RequestTarget = "/reporting/v2/reportSubscriptions/TRRReport?organizationId=testrest"; - 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() - { - string RequestJsonFilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../", "Source/Resource/TRRReport.json"); - try - { - // Setting up Merchant Config - var requestData = new RequestData(); +// 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() +// { +// string RequestJsonFilePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../../", "Source/Resource/TRRReport.json"); +// try +// { +// // Setting up Merchant Config +// var requestData = new RequestData(); - var merchantConfig = new MerchantConfig - { - RequestTarget = RequestTarget, - RequestType = Enumerations.RequestType.PUT.ToString(), - RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) - }; +// var merchantConfig = new MerchantConfig +// { +// RequestTarget = RequestTarget, +// RequestType = Enumerations.RequestType.PUT.ToString(), +// RequestJsonData = requestData.JsonFileData(RequestJsonFilePath) +// }; - // Call to the Authorize class of AuthSDK to get the signature and token objects - var authorizeObj = new Authorize(merchantConfig); +// // Call to the Authorize class of AuthSDK to get the signature and token objects +// var authorizeObj = new Authorize(merchantConfig); - if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.HTTP_SIGNATURE.ToString(), StringComparison.OrdinalIgnoreCase)) - { - var requestHeaders = authorizeObj.GetSignature(); +// if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.HTTP_SIGNATURE.ToString(), StringComparison.OrdinalIgnoreCase)) +// { +// var requestHeaders = authorizeObj.GetSignature(); - Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); - Console.WriteLine("{0} {1}", "v-c-merchant-id:", requestHeaders.MerchantId); - Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); - Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); - Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); - Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); - WriteLogAudit(200); - } - else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) - { - var requestHeaders = authorizeObj.GetToken(); +// Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); +// Console.WriteLine("{0} {1}", "v-c-merchant-id:", requestHeaders.MerchantId); +// Console.WriteLine("{0} {1}", "Date:", requestHeaders.GmtDateTime); +// Console.WriteLine("{0} {1}", "Host:", requestHeaders.HostName); +// Console.WriteLine("{0} {1}", "digest:", requestHeaders.Digest); +// Console.WriteLine("{0} {1}", "signature:", requestHeaders.SignatureParam); +// WriteLogAudit(200); +// } +// else if (string.Equals(merchantConfig.AuthenticationType, Enumerations.AuthenticationType.JWT.ToString(), StringComparison.OrdinalIgnoreCase)) +// { +// var requestHeaders = authorizeObj.GetToken(); - Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); - Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); - WriteLogAudit(200); - } - } - catch (Exception e) - { - Console.WriteLine(e.Message); - Console.WriteLine(e.StackTrace); - WriteLogAudit(400); - } - } - } -} \ No newline at end of file +// Console.WriteLine("{0} {1}", "Content-Type:", "application/json"); +// Console.WriteLine("{0} {1}", "Authorization:", requestHeaders.BearerToken); +// WriteLogAudit(200); +// } +// } +// catch (Exception e) +// { +// Console.WriteLine(e.Message); +// Console.WriteLine(e.StackTrace); +// WriteLogAudit(400); +// } +// } +// } +//} \ No newline at end of file diff --git a/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs index 6ad5a22..e2bcf2d 100644 --- a/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs +++ b/Source/Samples/RecurringBillingSubscriptions/Plans/GetPlan.cs @@ -1,7 +1,4 @@ using System; -using System.Collections.Generic; -using System.Globalization; -using ApiSdk.model; using CyberSource.Api; using CyberSource.Model; 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/Source/lib/net461/ApiSdk.dll b/Source/lib/net461/ApiSdk.dll deleted file mode 100644 index f41c381..0000000 Binary files a/Source/lib/net461/ApiSdk.dll and /dev/null differ diff --git a/Source/lib/netstandard/ApiSdk.dll b/Source/lib/netstandard/ApiSdk.dll deleted file mode 100644 index ce21e60..0000000 Binary files a/Source/lib/netstandard/ApiSdk.dll and /dev/null differ 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 @@ + +