Skip to content

Commit

Permalink
Adding a test runner project for Sample code.
Browse files Browse the repository at this point in the history
  • Loading branch information
akankaria committed Jan 29, 2016
1 parent 27d6059 commit 1f006de
Show file tree
Hide file tree
Showing 57 changed files with 916 additions and 253 deletions.
10 changes: 6 additions & 4 deletions ApplePayTransactions/CreateAnApplePayTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@

namespace net.authorize.sample.ApplePayTransactions
{
class CreateAnApplePayTransaction
public class CreateAnApplePayTransaction
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Create Apple Pay Transaction Sample");

Expand Down Expand Up @@ -48,14 +48,14 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)


//validate
if (response.messages.resultCode == messageTypeEnum.Ok)
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
if (response.transactionResponse != null)
{
Console.WriteLine("Successfully made a purchase, authorization code : " + response.transactionResponse.authCode);
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
if (response.transactionResponse != null)
Expand All @@ -64,6 +64,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
}
}

return response;

}
}
}
13 changes: 7 additions & 6 deletions CustomerProfiles/CreateCustomerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace net.authorize.sample
{
class CreateCustomerProfile
public class CreateCustomerProfile
{
public static void Run(string ApiLoginID, string ApiTransactionKey)
public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string emailId)
{
Console.WriteLine("CreateCustomerProfile Sample");

Expand All @@ -29,8 +29,8 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)

var bankAccount = new bankAccountType
{
accountNumber = "0123454321",
routingNumber = "000000204",
accountNumber = "231323342",
routingNumber = "000000224",
accountType = bankAccountTypeEnum.checking,
echeckType = echeckTypeEnum.WEB,
nameOnAccount = "test",
Expand Down Expand Up @@ -69,7 +69,7 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)

customerProfileType customerProfile = new customerProfileType();
customerProfile.merchantCustomerId = "Test CustomerID";
customerProfile.email = "[email protected]";
customerProfile.email = emailId;
customerProfile.paymentProfiles = paymentProfileList.ToArray();
customerProfile.shipToList = addressInfoList.ToArray();

Expand All @@ -90,11 +90,12 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]);
}
}
else
else if(response != null )
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
9 changes: 5 additions & 4 deletions CustomerProfiles/CreateCustomerProfileFromTransaction.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace net.authorize.sample
{
class CreateCustomerProfileFromTransaction
public class CreateCustomerProfileFromTransaction
{
public static void Run(string ApiLoginID, string ApiTransactionKey)
public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string transactionId)
{
Console.WriteLine("CreateCustomerProfileFromTransaction Sample");

Expand All @@ -20,7 +20,7 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
Item = ApiTransactionKey,
};

var request = new createCustomerProfileFromTransactionRequest { transId = "2238147175" };
var request = new createCustomerProfileFromTransactionRequest { transId = transactionId };

var controller = new createCustomerProfileFromTransactionController(request);
controller.Execute();
Expand All @@ -37,11 +37,12 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]);
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
9 changes: 5 additions & 4 deletions CustomerProfiles/CreateCustomerShippingAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace net.authorize.sample
{
class CreateCustomerShippingAddress
public class CreateCustomerShippingAddress
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
{
Console.WriteLine("CreateCustomerShippingAddress Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
Expand All @@ -29,7 +29,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)

var request = new createCustomerShippingAddressRequest
{
customerProfileId = "10000",
customerProfileId = customerProfileId,
address = officeAddress,
};

Expand All @@ -46,11 +46,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Success, customerAddressId : " + response.customerAddressId);
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
12 changes: 7 additions & 5 deletions CustomerProfiles/DeleteCustomerPaymentProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@

namespace net.authorize.sample
{
class DeleteCustomerPaymentProfile
public class DeleteCustomerPaymentProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
string customerPaymentProfileId)
{
Console.WriteLine("DeleteCustomerPaymentProfile Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
Expand All @@ -22,8 +23,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
//please update the subscriptionId according to your sandbox credentials
var request = new deleteCustomerPaymentProfileRequest
{
customerProfileId = "10000",
customerPaymentProfileId = "20000"
customerProfileId = customerProfileId,
customerPaymentProfileId = customerPaymentProfileId
};

//Prepare Request
Expand All @@ -39,11 +40,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString());
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
9 changes: 5 additions & 4 deletions CustomerProfiles/DeleteCustomerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

namespace net.authorize.sample
{
class DeleteCustomerProfile
public class DeleteCustomerProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
{
Console.WriteLine("DeleteCustomerProfile Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
Expand All @@ -22,7 +22,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
//please update the subscriptionId according to your sandbox credentials
var request = new deleteCustomerProfileRequest
{
customerProfileId = "10000"
customerProfileId = customerProfileId
};

//Prepare Request
Expand All @@ -38,11 +38,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString());
}
}
else
else if (response != null && response.messages.message != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
12 changes: 7 additions & 5 deletions CustomerProfiles/DeleteCustomerShippingAddress.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@

namespace net.authorize.sample
{
class DeleteCustomerShippingAddress
public class DeleteCustomerShippingAddress
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
string customerAddressId)
{
Console.WriteLine("DeleteCustomerShippingAddress Sample");
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
Expand All @@ -23,8 +24,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
//please update the subscriptionId according to your sandbox credentials
var request = new deleteCustomerShippingAddressRequest
{
customerProfileId = "10000",
customerAddressId = "20000"
customerProfileId = customerProfileId,
customerAddressId = customerAddressId
};

//Prepare Request
Expand All @@ -40,11 +41,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString());
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
}

return response;
}
}
}
15 changes: 9 additions & 6 deletions CustomerProfiles/GetCustomerPaymentProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,10 @@

namespace net.authorize.sample
{
class GetCustomerPaymentProfile
public class GetCustomerPaymentProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
string customerPaymentProfileId)
{
Console.WriteLine("Get Customer Payment Profile sample");

Expand All @@ -26,8 +27,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
};

var request = new getCustomerPaymentProfileRequest();
request.customerProfileId = "36731856";
request.customerPaymentProfileId = "33211899";
request.customerProfileId = customerProfileId;
request.customerPaymentProfileId = customerPaymentProfileId;

// Set this optional property to true to return an unmasked expiration date
//request.unmaskExpirationDateSpecified = true;
Expand All @@ -41,7 +42,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();

if (response.messages.resultCode == messageTypeEnum.Ok)
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
Console.WriteLine("Customer Payment Profile Id: " + response.paymentProfile.customerPaymentProfileId);
Expand All @@ -51,11 +52,13 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Customer Payment Profile Expiration Date: " + (response.paymentProfile.payment.Item as creditCardMaskedType).expirationDate);
}
}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}

return response;
}
}
}
6 changes: 4 additions & 2 deletions CustomerProfiles/GetCustomerPaymentProfileList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace net.authorize.sample
{
class GetCustomerPaymentProfileList
public class GetCustomerPaymentProfileList
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
{
Console.WriteLine("Get Customer Payment Profile List sample");

Expand Down Expand Up @@ -65,6 +65,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
Console.WriteLine("Null response received : " + controller.GetErrorResponse().messages.message[0].text);
}
}

return response;
}
}
}
12 changes: 7 additions & 5 deletions CustomerProfiles/GetCustomerProfile.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@

namespace net.authorize.sample
{
class GetCustomerProfile
public class GetCustomerProfile
{
public static void Run(String ApiLoginID, String ApiTransactionKey)
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
{
Console.WriteLine("Get Customer Profile sample");

Expand All @@ -26,7 +26,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
};

var request = new getCustomerProfileRequest();
request.customerProfileId = "36731856";
request.customerProfileId = customerProfileId;

// instantiate the controller that will call the service
var controller = new getCustomerProfileController(request);
Expand All @@ -35,17 +35,19 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
// get the response from the service (errors contained if any)
var response = controller.GetApiResponse();

if (response.messages.resultCode == messageTypeEnum.Ok)
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
{
Console.WriteLine(response.messages.message[0].text);
Console.WriteLine("Customer Profile Id: " + response.profile.customerProfileId);

}
else
else if(response != null)
{
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
response.messages.message[0].text);
}

return response;
}
}
}
Loading

0 comments on commit 1f006de

Please sign in to comment.