Skip to content

Commit 1f006de

Browse files
committed
Adding a test runner project for Sample code.
1 parent 27d6059 commit 1f006de

File tree

57 files changed

+916
-253
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+916
-253
lines changed

ApplePayTransactions/CreateAnApplePayTransaction.cs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@
88

99
namespace net.authorize.sample.ApplePayTransactions
1010
{
11-
class CreateAnApplePayTransaction
11+
public class CreateAnApplePayTransaction
1212
{
13-
public static void Run(String ApiLoginID, String ApiTransactionKey)
13+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
1414
{
1515
Console.WriteLine("Create Apple Pay Transaction Sample");
1616

@@ -48,14 +48,14 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
4848

4949

5050
//validate
51-
if (response.messages.resultCode == messageTypeEnum.Ok)
51+
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
5252
{
5353
if (response.transactionResponse != null)
5454
{
5555
Console.WriteLine("Successfully made a purchase, authorization code : " + response.transactionResponse.authCode);
5656
}
5757
}
58-
else
58+
else if(response != null)
5959
{
6060
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
6161
if (response.transactionResponse != null)
@@ -64,6 +64,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
6464
}
6565
}
6666

67+
return response;
68+
6769
}
6870
}
6971
}

CustomerProfiles/CreateCustomerProfile.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace net.authorize.sample
88
{
9-
class CreateCustomerProfile
9+
public class CreateCustomerProfile
1010
{
11-
public static void Run(string ApiLoginID, string ApiTransactionKey)
11+
public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string emailId)
1212
{
1313
Console.WriteLine("CreateCustomerProfile Sample");
1414

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

3030
var bankAccount = new bankAccountType
3131
{
32-
accountNumber = "0123454321",
33-
routingNumber = "000000204",
32+
accountNumber = "231323342",
33+
routingNumber = "000000224",
3434
accountType = bankAccountTypeEnum.checking,
3535
echeckType = echeckTypeEnum.WEB,
3636
nameOnAccount = "test",
@@ -69,7 +69,7 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
6969

7070
customerProfileType customerProfile = new customerProfileType();
7171
customerProfile.merchantCustomerId = "Test CustomerID";
72-
customerProfile.email = "[email protected]";
72+
customerProfile.email = emailId;
7373
customerProfile.paymentProfiles = paymentProfileList.ToArray();
7474
customerProfile.shipToList = addressInfoList.ToArray();
7575

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

98+
return response;
9899
}
99100
}
100101
}

CustomerProfiles/CreateCustomerProfileFromTransaction.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace net.authorize.sample
88
{
9-
class CreateCustomerProfileFromTransaction
9+
public class CreateCustomerProfileFromTransaction
1010
{
11-
public static void Run(string ApiLoginID, string ApiTransactionKey)
11+
public static ANetApiResponse Run(string ApiLoginID, string ApiTransactionKey, string transactionId)
1212
{
1313
Console.WriteLine("CreateCustomerProfileFromTransaction Sample");
1414

@@ -20,7 +20,7 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
2020
Item = ApiTransactionKey,
2121
};
2222

23-
var request = new createCustomerProfileFromTransactionRequest { transId = "2238147175" };
23+
var request = new createCustomerProfileFromTransactionRequest { transId = transactionId };
2424

2525
var controller = new createCustomerProfileFromTransactionController(request);
2626
controller.Execute();
@@ -37,11 +37,12 @@ public static void Run(string ApiLoginID, string ApiTransactionKey)
3737
Console.WriteLine("Success, CustomerShippingProfileID : " + response.customerShippingAddressIdList[0]);
3838
}
3939
}
40-
else
40+
else if(response != null)
4141
{
4242
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
4343
}
4444

45+
return response;
4546
}
4647
}
4748
}

CustomerProfiles/CreateCustomerShippingAddress.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace net.authorize.sample
88
{
9-
class CreateCustomerShippingAddress
9+
public class CreateCustomerShippingAddress
1010
{
11-
public static void Run(String ApiLoginID, String ApiTransactionKey)
11+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
1212
{
1313
Console.WriteLine("CreateCustomerShippingAddress Sample");
1414
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
@@ -29,7 +29,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
2929

3030
var request = new createCustomerShippingAddressRequest
3131
{
32-
customerProfileId = "10000",
32+
customerProfileId = customerProfileId,
3333
address = officeAddress,
3434
};
3535

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

54+
return response;
5455
}
5556
}
5657
}

CustomerProfiles/DeleteCustomerPaymentProfile.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@
66

77
namespace net.authorize.sample
88
{
9-
class DeleteCustomerPaymentProfile
9+
public class DeleteCustomerPaymentProfile
1010
{
11-
public static void Run(String ApiLoginID, String ApiTransactionKey)
11+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
12+
string customerPaymentProfileId)
1213
{
1314
Console.WriteLine("DeleteCustomerPaymentProfile Sample");
1415
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
@@ -22,8 +23,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
2223
//please update the subscriptionId according to your sandbox credentials
2324
var request = new deleteCustomerPaymentProfileRequest
2425
{
25-
customerProfileId = "10000",
26-
customerPaymentProfileId = "20000"
26+
customerProfileId = customerProfileId,
27+
customerPaymentProfileId = customerPaymentProfileId
2728
};
2829

2930
//Prepare Request
@@ -39,11 +40,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
3940
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString());
4041
}
4142
}
42-
else
43+
else if(response != null)
4344
{
4445
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
4546
}
4647

48+
return response;
4749
}
4850
}
4951
}

CustomerProfiles/DeleteCustomerProfile.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@
66

77
namespace net.authorize.sample
88
{
9-
class DeleteCustomerProfile
9+
public class DeleteCustomerProfile
1010
{
11-
public static void Run(String ApiLoginID, String ApiTransactionKey)
11+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
1212
{
1313
Console.WriteLine("DeleteCustomerProfile Sample");
1414
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
@@ -22,7 +22,7 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
2222
//please update the subscriptionId according to your sandbox credentials
2323
var request = new deleteCustomerProfileRequest
2424
{
25-
customerProfileId = "10000"
25+
customerProfileId = customerProfileId
2626
};
2727

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

46+
return response;
4647
}
4748
}
4849
}

CustomerProfiles/DeleteCustomerShippingAddress.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77

88
namespace net.authorize.sample
99
{
10-
class DeleteCustomerShippingAddress
10+
public class DeleteCustomerShippingAddress
1111
{
12-
public static void Run(String ApiLoginID, String ApiTransactionKey)
12+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
13+
string customerAddressId)
1314
{
1415
Console.WriteLine("DeleteCustomerShippingAddress Sample");
1516
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
@@ -23,8 +24,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
2324
//please update the subscriptionId according to your sandbox credentials
2425
var request = new deleteCustomerShippingAddressRequest
2526
{
26-
customerProfileId = "10000",
27-
customerAddressId = "20000"
27+
customerProfileId = customerProfileId,
28+
customerAddressId = customerAddressId
2829
};
2930

3031
//Prepare Request
@@ -40,11 +41,12 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
4041
Console.WriteLine("Success, ResultCode : " + response.messages.resultCode.ToString());
4142
}
4243
}
43-
else
44+
else if(response != null)
4445
{
4546
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
4647
}
4748

49+
return response;
4850
}
4951
}
5052
}

CustomerProfiles/GetCustomerPaymentProfile.cs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010

1111
namespace net.authorize.sample
1212
{
13-
class GetCustomerPaymentProfile
13+
public class GetCustomerPaymentProfile
1414
{
15-
public static void Run(String ApiLoginID, String ApiTransactionKey)
15+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId,
16+
string customerPaymentProfileId)
1617
{
1718
Console.WriteLine("Get Customer Payment Profile sample");
1819

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

2829
var request = new getCustomerPaymentProfileRequest();
29-
request.customerProfileId = "36731856";
30-
request.customerPaymentProfileId = "33211899";
30+
request.customerProfileId = customerProfileId;
31+
request.customerPaymentProfileId = customerPaymentProfileId;
3132

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

44-
if (response.messages.resultCode == messageTypeEnum.Ok)
45+
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
4546
{
4647
Console.WriteLine(response.messages.message[0].text);
4748
Console.WriteLine("Customer Payment Profile Id: " + response.paymentProfile.customerPaymentProfileId);
@@ -51,11 +52,13 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
5152
Console.WriteLine("Customer Payment Profile Expiration Date: " + (response.paymentProfile.payment.Item as creditCardMaskedType).expirationDate);
5253
}
5354
}
54-
else
55+
else if(response != null)
5556
{
5657
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
5758
response.messages.message[0].text);
5859
}
60+
61+
return response;
5962
}
6063
}
6164
}

CustomerProfiles/GetCustomerPaymentProfileList.cs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
namespace net.authorize.sample
1212
{
13-
class GetCustomerPaymentProfileList
13+
public class GetCustomerPaymentProfileList
1414
{
15-
public static void Run(String ApiLoginID, String ApiTransactionKey)
15+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey)
1616
{
1717
Console.WriteLine("Get Customer Payment Profile List sample");
1818

@@ -65,6 +65,8 @@ public static void Run(String ApiLoginID, String ApiTransactionKey)
6565
Console.WriteLine("Null response received : " + controller.GetErrorResponse().messages.message[0].text);
6666
}
6767
}
68+
69+
return response;
6870
}
6971
}
7072
}

CustomerProfiles/GetCustomerProfile.cs

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010

1111
namespace net.authorize.sample
1212
{
13-
class GetCustomerProfile
13+
public class GetCustomerProfile
1414
{
15-
public static void Run(String ApiLoginID, String ApiTransactionKey)
15+
public static ANetApiResponse Run(String ApiLoginID, String ApiTransactionKey, string customerProfileId)
1616
{
1717
Console.WriteLine("Get Customer Profile sample");
1818

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

2828
var request = new getCustomerProfileRequest();
29-
request.customerProfileId = "36731856";
29+
request.customerProfileId = customerProfileId;
3030

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

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

4343
}
44-
else
44+
else if(response != null)
4545
{
4646
Console.WriteLine("Error: " + response.messages.message[0].code + " " +
4747
response.messages.message[0].text);
4848
}
49+
50+
return response;
4951
}
5052
}
5153
}

0 commit comments

Comments
 (0)