|
8 | 8 |
|
9 | 9 | namespace AuthorizeNETtest
|
10 | 10 | {
|
| 11 | + using System.Text; |
| 12 | + |
11 | 13 | /// <summary>
|
12 | 14 | /// This is a test class for CustomerGatewayTest and is intended to contain all CustomerGateway Unit Tests
|
13 | 15 | /// </summary>
|
@@ -995,5 +997,104 @@ public void TestCheckForErrorscreateCustomerProfileTransactionResponse()
|
995 | 997 | var response = gateway.AuthorizeAndCapture(order);
|
996 | 998 | Assert.IsNotNull(response);
|
997 | 999 | }
|
| 1000 | + |
| 1001 | + [Test] |
| 1002 | + public void TestSdkUpgradeCustomerOrder() |
| 1003 | + { |
| 1004 | + var random = new Random(); |
| 1005 | + var counter = random.Next(1, (int)(Math.Pow(2, 24))); |
| 1006 | + const int maxAmount = 10000;// 214747; |
| 1007 | + var amount = new decimal(counter > maxAmount ? (counter % maxAmount) : counter); |
| 1008 | + var email = string.Format("user.{0}@authorize.net", counter); |
| 1009 | + var description = string.Format("Description for Customer: {0}", counter); |
| 1010 | + var merchantCustomerId = string.Format("CustomerId: {0}", counter); |
| 1011 | + const string cardNumber = "4111111111111111"; |
| 1012 | + const string cvv = ""; |
| 1013 | + var address = new Address |
| 1014 | + { |
| 1015 | + First = string.Format("FName:{0}", counter), |
| 1016 | + Last = string.Format("LName:{0}", counter), |
| 1017 | + Company = "Visa", |
| 1018 | + Street = "123 Elm Street", |
| 1019 | + City = "Bellevue", |
| 1020 | + State = "WA", |
| 1021 | + Country = "US", |
| 1022 | + Zip = "98006" |
| 1023 | + }; |
| 1024 | + |
| 1025 | + //Save the customer first |
| 1026 | + var gw = new CustomerGateway(ApiLogin, TransactionKey); |
| 1027 | + |
| 1028 | + var customer = gw.CreateCustomer(email, description, merchantCustomerId); |
| 1029 | + var creditCardToken = gw.AddCreditCard(customer.ProfileID, cardNumber, DateTime.UtcNow.Month, DateTime.UtcNow.AddYears(1).Year, cvv, address); |
| 1030 | + |
| 1031 | + //Create order |
| 1032 | + var order = new Order(customer.ProfileID, creditCardToken, ""); |
| 1033 | + order.Amount = amount; |
| 1034 | + order.CardCode = cvv; |
| 1035 | + order.ExtraOptions = "x_duplicate_window=0"; |
| 1036 | + |
| 1037 | + var result = (GatewayResponse)gw.AuthorizeAndCapture(order); |
| 1038 | + Assert.IsNotNull(result, "GateWay response for Order AuthCapture is null"); |
| 1039 | + |
| 1040 | + var buffer = new StringBuilder(); |
| 1041 | + |
| 1042 | + buffer.Append( "IGateWayResponse->"); |
| 1043 | + buffer.AppendFormat( " SplitTenderId:{0}", result.SplitTenderId); |
| 1044 | + buffer.AppendFormat( ", MD5Hash:{0}", result.MD5Hash); |
| 1045 | + buffer.AppendFormat( ", CCVResponse:{0}", result.CCVResponse); |
| 1046 | + buffer.AppendFormat( ", Code:{0}", result.Code); |
| 1047 | + buffer.AppendFormat( ", TransactionType:{0}", result.TransactionType); |
| 1048 | + buffer.AppendFormat( ", AuthorizationCode:{0}", result.AuthorizationCode); |
| 1049 | + buffer.AppendFormat( ", Method:{0}", result.Method); |
| 1050 | + buffer.AppendFormat( ", Amount:{0}", result.Amount); |
| 1051 | + buffer.AppendFormat( ", Tax:{0}", result.Tax); |
| 1052 | + buffer.AppendFormat( ", TransactionID:{0}", result.TransactionID); |
| 1053 | + buffer.AppendFormat( ", InvoiceNumber:{0}", result.InvoiceNumber); |
| 1054 | + buffer.AppendFormat( ", Description:{0}", result.Description); |
| 1055 | + buffer.AppendFormat( ", ResponseCode:{0}", result.ResponseCode); |
| 1056 | + buffer.AppendFormat( ", CardNumber:{0}", result.CardNumber); |
| 1057 | + buffer.AppendFormat( ", CardType:{0}", result.CardType); |
| 1058 | + buffer.AppendFormat( ", CAVResponse:{0}", result.CAVResponse); |
| 1059 | + buffer.AppendFormat( ", AVSResponse:{0}", result.AVSResponse); |
| 1060 | + buffer.AppendFormat( ", SubCode:{0}", result.SubCode); |
| 1061 | + buffer.AppendFormat( ", Message:{0}", result.Message); |
| 1062 | + buffer.AppendFormat( ", Approved:{0}", result.Approved); |
| 1063 | + buffer.AppendFormat( ", Declined:{0}", result.Declined); |
| 1064 | + buffer.AppendFormat( ", Error:{0}", result.Error); |
| 1065 | + buffer.AppendFormat( ", HeldForReview:{0}", result.HeldForReview); |
| 1066 | + buffer.AppendFormat( ", FirstName:{0}", result.FirstName); |
| 1067 | + buffer.AppendFormat( ", LastName:{0}", result.LastName); |
| 1068 | + buffer.AppendFormat( ", Email:{0}", result.Email); |
| 1069 | + buffer.AppendFormat( ", Company:{0}", result.Company); |
| 1070 | + buffer.AppendFormat( ", Address:{0}", result.Address); |
| 1071 | + buffer.AppendFormat( ", City:{0}", result.City); |
| 1072 | + buffer.AppendFormat( ", State:{0}", result.State); |
| 1073 | + buffer.AppendFormat( ", ZipCode:{0}", result.ZipCode); |
| 1074 | + buffer.AppendFormat( ", Country:{0}", result.Country); |
| 1075 | + buffer.AppendFormat( ", ShipFirstName:{0}", result.ShipFirstName); |
| 1076 | + buffer.AppendFormat( ", ShipLastName:{0}", result.ShipLastName); |
| 1077 | + buffer.AppendFormat( ", ShipCompany:{0}", result.ShipCompany); |
| 1078 | + buffer.AppendFormat( ", ShipAddress:{0}", result.ShipAddress); |
| 1079 | + buffer.AppendFormat( ", ShipCity:{0}", result.ShipCity); |
| 1080 | + buffer.AppendFormat( ", ShipState:{0}", result.ShipState); |
| 1081 | + buffer.AppendFormat( ", ShipZipCode:{0}", result.ShipZipCode); |
| 1082 | + buffer.AppendFormat( ", ShipCountry:{0}", result.ShipCountry); |
| 1083 | + |
| 1084 | + Console.WriteLine(buffer); |
| 1085 | + |
| 1086 | + Assert.IsNotNull(result.MD5Hash); |
| 1087 | + Assert.IsNotNullOrEmpty(result.TransactionType); |
| 1088 | + Assert.IsNotNullOrEmpty(result.AuthorizationCode); |
| 1089 | + Assert.IsNotNullOrEmpty(result.Method); |
| 1090 | + Assert.AreEqual("CC", result.Method); |
| 1091 | + Assert.IsNotNullOrEmpty(result.TransactionID); |
| 1092 | + Assert.AreEqual("1", result.ResponseCode); |
| 1093 | + Assert.AreEqual( "XXXX1111", result.CardNumber); |
| 1094 | + Assert.AreEqual( "Visa", result.CardType); |
| 1095 | + Assert.AreEqual("This transaction has been approved.", result.Message); |
| 1096 | + Assert.IsTrue(result.Approved); |
| 1097 | + Assert.IsFalse(result.Declined); |
| 1098 | + } |
998 | 1099 | }
|
999 | 1100 | }
|
0 commit comments