Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
238 changes: 119 additions & 119 deletions Source/AuthenticationData/RequestData.cs
Original file line number Diff line number Diff line change
@@ -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);
// }
// }
//}
15 changes: 15 additions & 0 deletions Source/Configuration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,21 @@ public Dictionary<string, string> GetIntermediateConfiguration()
// _configurationDictionary.Add("proxyUsername", string.Empty);
// _configurationDictionary.Add("proxyPassword", string.Empty);
return _configurationDictionary;
}

public Dictionary<string, string> 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;
}


}
}
5 changes: 5 additions & 0 deletions Source/Resource/batchapiTest.csv
Original file line number Diff line number Diff line change
@@ -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
Binary file added Source/Resource/qaebc2.p12
Binary file not shown.
108 changes: 54 additions & 54 deletions Source/Samples/Authentication/CallHttpMethods/DeleteMethod.cs
Original file line number Diff line number Diff line change
@@ -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);
// }
// }
// }
//}
Loading