Skip to content
Merged
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
30 changes: 30 additions & 0 deletions Source/BankAccountValidationConfiguration.cs
Original file line number Diff line number Diff line change
@@ -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<string, string> _configurationDictionary = new Dictionary<string, string>();

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

}
}

Binary file added Source/Resource/testcasmerchpd01001.p12
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -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;
}
}
}
}