diff --git a/Source/BankAccountValidationConfiguration.cs b/Source/BankAccountValidationConfiguration.cs new file mode 100644 index 0000000..c4552f2 --- /dev/null +++ b/Source/BankAccountValidationConfiguration.cs @@ -0,0 +1,30 @@ +using System; +using System.Collections.Generic; +using System.IO; +using System.Text; +using Cybersource_rest_samples_dotnet.Samples.Payments; + +namespace Cybersource_rest_samples_dotnet +{ + class BankAccountValidationConfiguration + { + // initialize dictionary object + private readonly Dictionary _configurationDictionary = new Dictionary(); + + public Dictionary GetConfiguration() + { + _configurationDictionary.Add("authenticationType", "JWT"); //mle only support with JWT Auth Type + _configurationDictionary.Add("merchantID", "testcasmerchpd01001"); + _configurationDictionary.Add("keysDirectory", Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "..\\..\\..\\Source\\Resource")); + _configurationDictionary.Add("keyFilename", "testcasmerchpd01001"); + _configurationDictionary.Add("runEnvironment", "apitest.cybersource.com"); + _configurationDictionary.Add("keyAlias", "testcasmerchpd01001"); + _configurationDictionary.Add("keyPass", "Authnet101!"); + + + return _configurationDictionary; + } + + } +} + diff --git a/Source/Resource/testcasmerchpd01001.p12 b/Source/Resource/testcasmerchpd01001.p12 new file mode 100644 index 0000000..c48f328 Binary files /dev/null and b/Source/Resource/testcasmerchpd01001.p12 differ diff --git a/Source/Samples/VisaBankAccountValidation/BankAccountValidationValidated.cs b/Source/Samples/VisaBankAccountValidation/BankAccountValidationValidated.cs new file mode 100644 index 0000000..020e23d --- /dev/null +++ b/Source/Samples/VisaBankAccountValidation/BankAccountValidationValidated.cs @@ -0,0 +1,81 @@ +using System; +using System.Collections.Generic; +using System.Globalization; +using ApiSdk.model; +using CyberSource.Api; +using CyberSource.Client; +using CyberSource.Model; + +// The Bank Account Validation API requires encrypted requests as a mandatory requirement. The SDK by default sends encrypted requests for APIs where Request MLE (Message Level Encryption) is mandatory. +//MLE is supported only on the JWT authentication type +// For additional configuration options related to MLE, refer to the documentation at https://github.com/CyberSource/cybersource-rest-client-dotnet/blob/master/MLE.md +// For MLE related sample codes look in the folder Samples/MLEFeature + +namespace Cybersource_rest_samples_dotnet.Samples.VisaBankAccountValidation +{ + public class BankAccountValidationValidated + { + 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 InlineResponse20013 Run() + { + string clientReferenceInformationCode = "TC50171_100"; + Bavsv1accountvalidationsClientReferenceInformation clientReferenceInformation = new Bavsv1accountvalidationsClientReferenceInformation( + Code: clientReferenceInformationCode + ); + + int processingInformationValidationLevel = 1; + Bavsv1accountvalidationsProcessingInformation processingInformation = new Bavsv1accountvalidationsProcessingInformation( + ValidationLevel: processingInformationValidationLevel + ); + + string paymentInformationBankRoutingNumber = "041210163"; + string paymentInformationBankAccountNumber = "99970"; + Bavsv1accountvalidationsPaymentInformationBankAccount paymentInformationBankAccount = new Bavsv1accountvalidationsPaymentInformationBankAccount( + Number: paymentInformationBankAccountNumber + ); + + Bavsv1accountvalidationsPaymentInformationBank paymentInformationBank = new Bavsv1accountvalidationsPaymentInformationBank( + RoutingNumber: paymentInformationBankRoutingNumber, + Account: paymentInformationBankAccount + ); + + Bavsv1accountvalidationsPaymentInformation paymentInformation = new Bavsv1accountvalidationsPaymentInformation( + Bank: paymentInformationBank + ); + + var requestObj = new AccountValidationsRequest( + ClientReferenceInformation: clientReferenceInformation, + ProcessingInformation: processingInformation, + PaymentInformation: paymentInformation + ); + + try + { + var configDictionary = new BankAccountValidationConfiguration().GetConfiguration(); + //MLE is supported only on the JWT authentication type + //Refer BankAccountValidationConfiguration for more details + var clientConfig = new CyberSource.Client.Configuration(merchConfigDictObj: configDictionary); + + var apiInstance = new BankAccountValidationApi(clientConfig); + InlineResponse20013 result = apiInstance.BankAccountValidationRequest(requestObj); + Console.WriteLine(result); + WriteLogAudit(apiInstance.GetStatusCode()); + return result; + } + catch (ApiException e) + { + Console.WriteLine("Error Code: " + e.ErrorCode); + Console.WriteLine("Error Message: " + e.Message); + Console.WriteLine("Exception on calling the API : " + e.Message); + WriteLogAudit(e.ErrorCode); + return null; + } + } + } +} \ No newline at end of file