Skip to content

Commit f9637da

Browse files
committed
Merge pull request AuthorizeNet#98 from rahulrnitc/master
ReadMe and test case for
2 parents dd66dd4 + 45be2ac commit f9637da

File tree

2 files changed

+134
-28
lines changed

2 files changed

+134
-28
lines changed

AuthorizeNETtest/CustomerGatewayTest.cs

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1107,5 +1107,24 @@ public void TestSdkUpgradeCustomerOrder()
11071107
Assert.IsTrue(result.Approved);
11081108
Assert.IsFalse(result.Declined);
11091109
}
1110+
/// <summary>
1111+
/// GetCustomerProfileIds - success
1112+
/// </summary>
1113+
[Test]
1114+
public void GetCustomerProfileIds()
1115+
{
1116+
string[] customerIds = null;
1117+
try
1118+
{
1119+
customerIds = _target.GetCustomerIDs();
1120+
}
1121+
catch (Exception e)
1122+
{
1123+
1124+
Console.WriteLine("CustomerGateway.GetCustomerIDs() failed: " + e.Message);
1125+
}
1126+
1127+
Assert.IsNotNull(customerIds);
1128+
}
11101129
}
11111130
}

README.md

Lines changed: 115 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,46 @@ For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Tra
3333
### Advanced Merchant Integration (AIM)
3434

3535
````csharp
36-
Gateway target = new Gateway(ApiLogin, TransactionKey, true);
36+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
37+
{
38+
name = ApiLoginID,
39+
ItemElementName = ItemChoiceType.transactionKey,
40+
Item = ApiTransactionKey,
41+
};
42+
43+
var creditCard = new creditCardType
44+
{
45+
cardNumber = "4111111111111111",
46+
expirationDate = "0718"
47+
};
3748

38-
IGatewayRequest request = new AuthorizationRequest("5424000000000015", "0224", (decimal)20.10, "AuthCap transaction approved testing", true);
39-
string description = "AuthCap transaction approved testing";
40-
IGatewayResponse actual = target.Send(request, description);
49+
var paymentType = new paymentType { Item = creditCard };
4150

42-
Assert.IsTrue(actual.AuthorizationCode.Trim().Length > 0);
43-
Assert.IsTrue(actual.TransactionID.Trim().Length > 0);
51+
var transactionRequest = new transactionRequestType
52+
{
53+
transactionType = transactionTypeEnum.authOnlyTransaction.ToString(), // authorize only
54+
amount = 35.45m,
55+
payment = paymentType
56+
};
57+
58+
var request = new createTransactionRequest { transactionRequest = transactionRequest };
59+
60+
var controller = new createTransactionController(request);
61+
controller.Execute();
62+
63+
var response = controller.GetApiResponse();
64+
65+
if (response.messages.resultCode == messageTypeEnum.Ok)
66+
{
67+
if (response.transactionResponse != null)
68+
{
69+
Console.WriteLine("Success, Auth Code : " + response.transactionResponse.authCode);
70+
}
71+
}
72+
else
73+
{
74+
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
75+
}
4476
````
4577

4678
### Direct Post Method (DPM)
@@ -71,46 +103,101 @@ Place the following code in the default action of a simple MVC application to di
71103

72104
### Automated Recurring Billing (ARB)
73105
````csharp
74-
SubscriptionGateway target = new SubscriptionGateway(ApiLogin, TransactionKey);
106+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
107+
{
108+
name = ApiLoginID,
109+
ItemElementName = ItemChoiceType.transactionKey,
110+
Item = ApiTransactionKey,
111+
};
75112

76-
ISubscriptionRequest subscription = SubscriptionRequest.CreateMonthly("[email protected]",
77-
"ARB Subscription Test 5", (decimal)5.50,
78-
12);
79-
subscription.CardNumber = "4111111111111111";
80-
subscription.CardExpirationMonth = 1;
81-
subscription.CardExpirationYear = 20;
113+
paymentScheduleTypeInterval interval = new paymentScheduleTypeInterval();
82114

115+
interval.length = 1;
116+
interval.unit = ARBSubscriptionUnitEnum.months;
83117

118+
paymentScheduleType schedule = new paymentScheduleType
119+
{
120+
interval = interval,
121+
startDate = DateTime.Now.AddDays(1),
122+
totalOccurrences = 9999, // 9999 indicates no end date
123+
trialOccurrences = 3
124+
};
84125

85-
Address billToAddress = new Address();
86-
billToAddress.First = "John";
87-
billToAddress.Last = "Doe";
88-
subscription.BillingAddress = billToAddress;
126+
#region Payment Information
127+
var creditCard = new creditCardType
128+
{
129+
cardNumber = "4111111111111111",
130+
expirationDate = "0718"
131+
};
132+
133+
paymentType cc = new paymentType { Item = creditCard };
134+
#endregion
135+
136+
nameAndAddressType addressInfo = new nameAndAddressType()
137+
{
138+
firstName = "John",
139+
lastName = "Doe"
140+
};
141+
142+
ARBSubscriptionType subscriptionType = new ARBSubscriptionType()
143+
{
144+
amount = 35.55m,
145+
trialAmount = 0.00m,
146+
paymentSchedule = schedule,
147+
billTo = addressInfo,
148+
payment = cc
149+
};
150+
151+
var request = new ARBCreateSubscriptionRequest { subscription = subscriptionType };
152+
153+
var controller = new ARBCreateSubscriptionController(request);
154+
controller.Execute();
89155

90-
ISubscriptionRequest actual = null;
156+
ARBCreateSubscriptionResponse response = controller.GetApiResponse();
91157

92-
try
158+
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
93159
{
94-
actual = target.CreateSubscription(subscription);
160+
if (response != null && response.messages.message != null)
161+
{
162+
Console.WriteLine("Success, Subscription ID : " + response.subscriptionId.ToString());
163+
}
95164
}
96-
catch (Exception e)
165+
else
97166
{
98-
string s = e.Message;
99-
Console.WriteLine("Failed to create SUB: "+e.ToString());
167+
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
100168
}
101169

102170
````
103171
### Customer Information Manager (CIM)
104172
````csharp
105-
CustomerGateway target = new CustomerGateway(ApiLogin, TransactionKey);
173+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
174+
{
175+
name = ApiLoginID,
176+
ItemElementName = ItemChoiceType.transactionKey,
177+
Item = ApiTransactionKey,
178+
};
179+
180+
customerProfileType customerProfile = new customerProfileType();
181+
customerProfile.merchantCustomerId = "TestCustomerID";
182+
customerProfile.email = "[email protected]";
106183

107-
try
184+
var request = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.none};
185+
186+
var controller = new createCustomerProfileController(request);
187+
controller.Execute();
188+
189+
createCustomerProfileResponse response = controller.GetApiResponse();
190+
191+
if (response != null && response.messages.resultCode == messageTypeEnum.Ok)
108192
{
109-
actual = target.CreateCustomer("[email protected]", "new customer profile");
193+
if (response != null && response.messages.message != null)
194+
{
195+
Console.WriteLine("Success, CustomerProfileID : " + response.customerProfileId);
196+
}
110197
}
111-
catch (Exception e)
198+
else
112199
{
113-
string s = e.Message;
200+
Console.WriteLine("Error: " + response.messages.message[0].code + " " + response.messages.message[0].text);
114201
}
115202

116203
````

0 commit comments

Comments
 (0)