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
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public class AddPaymentMethodRequest : SecureNetRequest
#region Properties

public string CustomerId { get; set; }
public string PaymentMethodId { get; set; }
public Card Card { get; set; }
public string Phone { get; set; }
public string Notes { get; set; }
Expand Down
2 changes: 1 addition & 1 deletion SecureNetRestApiSDK/Api/Requests/CreateCustomerRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ namespace SecureNetRestApiSDK.Api.Requests
public class CreateCustomerRequest : SecureNetRequest
{
#region Properties

public string CustomerId { get; set; }
public string FirstName { get; set; }
public string LastName { get; set; }
public string PhoneNumber { get; set; }
Expand Down
149 changes: 146 additions & 3 deletions SecureNetRestApiSDK_UnitTest/Controllers/CustomersControllerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@

namespace SecureNetRestApiSDK_UnitTest.Controllers
{
[TestClass]
[TestClass]
public class CustomersControllerTests
{
#region SecureNet Vault
#region SecureNet Vault

/// <summary>
/// Unit Tests for Create, Retrieve, Update and Delete Customer requests. Tests combined in one method to pass the
Expand All @@ -22,7 +22,7 @@ public class CustomersControllerTests
public void SecureNet_Vault_Create_Retrieve_Update_And_Delete_Customer_Requests_Returns_Successfully()
{
// Create the Customer
string customerId = SecureNet_Vault_Create_Customer_Request_Returns_Successfully();
string customerId = SecureNet_Vault_Create_Customer_Request_Returns_Successfully();

// Retrieve the Customer
SecureNet_Vault_Retrieve_Customer_Request_Returns_Successfully(customerId);
Expand All @@ -32,6 +32,93 @@ public void SecureNet_Vault_Create_Retrieve_Update_And_Delete_Customer_Requests_

// Delete the Customer
//TODO
}

[TestMethod]
public void SecureNet_Vault_Create_Retrieve_Update_Customer_Request_Providing_Id()
{
const string custId = "PASSED";
//Create the Customer
var customerId = SecureNet_Vault_Create_Customer_Request_With_Id_Returns_Successfully(custId);
// Retrieve the Customer
SecureNet_Vault_Retrieve_Customer_Request_Returns_Successfully(customerId);
// Update the Customer
SecureNet_Vault_Update_Customer_Request_Returns_Successfully(customerId);
}

/// <summary>
/// Successful response returned from a Create Customer request when customer id is provided.
/// https://apidocs.securenet.com/docs/vault.html?lang=csharp#createcustomer
/// </summary>
public string SecureNet_Vault_Create_Customer_Request_With_Id_Returns_Successfully(string customerId)
{
// Arrange
var request = new CreateCustomerRequest
{
CustomerId = customerId,
FirstName = "Jack",
LastName = "Tester",
PhoneNumber = "402-122-1211",
EmailAddress = "Some@Emailaddress.net",
SendEmailReceipts = true,
Notes = "test notes",
Address = new Address
{
Line1 = "123 Main St.",
City = "Omaha",
State = "NE",
Zip = "68122"
},
Company = "Test Company",
UserDefinedFields = new List<UserDefinedField>
{
new UserDefinedField
{
UdfName = "Udf1",
UdfValue = "Udf1_Value"
},
new UserDefinedField
{
UdfName = "Udf2",
UdfValue = "Udf2_Value"
},
new UserDefinedField
{
UdfName = "Udf3",
UdfValue = "Udf3_Value"
},
new UserDefinedField
{
UdfName = "Udf4",
UdfValue = "Udf4_Value"
},
new UserDefinedField
{
UdfName = "Udf5",
UdfValue = "Udf5_Value"
},
},
DeveloperApplication = new DeveloperApplication
{
DeveloperId = 12345678,
Version = "1.2"
}
};

var apiContext = new APIContext();
var controller = new CustomersController();

// Act
var response = controller.ProcessRequest<CreateCustomerResponse>(apiContext, request);

// Assert
Assert.IsNotNull(response);
Assert.IsTrue(response.Success);
Assert.IsNotNull(response.CustomerId);
Assert.IsTrue(response.CustomerId.Length > 0);
Assert.AreEqual(request.CustomerId, response.CustomerId);
Assert.AreEqual(customerId, response.CustomerId);
return response.CustomerId;
}

/// <summary>
Expand Down Expand Up @@ -228,6 +315,62 @@ public void SecureNet_Vault_Create_Retrieve_Charge_Update_And_Delete_Payment_Acc
// Delete the Customer
//TODO
}
[TestMethod]
public void SecureNet_Vault_Create_Payment_Account_With_Id_Returns_Successfully()
{
const string customerId = "CERT1";
//Create the Payment Account
const string payment = "PAY1";
string paymentMethodId = SecureNet_Value_Create_Payment_Account_Request_With_Payment_Id_Returns_Successfully(customerId, payment);
//Retrieve the Payment Account
SecureNet_Vault_Retrieve_Payment_Account_Request_Returns_Successfully(customerId, paymentMethodId);
}

public string SecureNet_Value_Create_Payment_Account_Request_With_Payment_Id_Returns_Successfully(string customerId, string paymentId)
{
// Arrange
var request = new AddPaymentMethodRequest
{
CustomerId = customerId,
PaymentMethodId = paymentId,
Card = new Card
{
Number = "6011905000000004",
ExpirationDate = "01/2017",
Address = new Address
{
Line1 = "123 Main St.",
City = "Austin",
State = "TX",
Zip = "78759"
},
FirstName = "Jack",
LastName = "Test"
},
Phone = "816-250-7865",
Notes = "Create A Vault Account",
AccountDuplicateCheckIndicator = 0,
Primary = false,
DeveloperApplication = new DeveloperApplication
{
DeveloperId = 12345678,
Version = "1.2"
}
};
var apiContext = new APIContext();
var controller = new CustomersController();

// Act
var response = controller.ProcessRequest<AddPaymentMethodResponse>(apiContext, request);

// Assert
Assert.IsNotNull(response);
Assert.IsTrue(response.Success);
Assert.IsNotNull(response.VaultPaymentMethod);
Assert.IsNotNull(response.VaultPaymentMethod.PaymentId);
Assert.AreEqual(paymentId, response.VaultPaymentMethod.PaymentId);
return response.VaultPaymentMethod.PaymentId;
}

/// <summary>
/// Successful response returned from a Create Payment Account request.
Expand Down