@@ -33,14 +33,46 @@ For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Tra
33
33
### Advanced Merchant Integration (AIM)
34
34
35
35
```` 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
+ };
37
48
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 };
41
50
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 . 45 m ,
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
+ }
44
76
````
45
77
46
78
### Direct Post Method (DPM)
@@ -71,46 +103,101 @@ Place the following code in the default action of a simple MVC application to di
71
103
72
104
### Automated Recurring Billing (ARB)
73
105
```` 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
+ };
75
112
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 ();
82
114
115
+ interval .length = 1 ;
116
+ interval .unit = ARBSubscriptionUnitEnum .months ;
83
117
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
+ };
84
125
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 . 55 m ,
145
+ trialAmount = 0 . 00 m ,
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 ();
89
155
90
- ISubscriptionRequest actual = null ;
156
+ ARBCreateSubscriptionResponse response = controller . GetApiResponse ();
91
157
92
- try
158
+ if ( response != null && response . messages . resultCode == messageTypeEnum . Ok )
93
159
{
94
- actual = target .CreateSubscription (subscription );
160
+ if (response != null && response .messages .message != null )
161
+ {
162
+ Console .WriteLine (" Success, Subscription ID : " + response .subscriptionId .ToString ());
163
+ }
95
164
}
96
- catch ( Exception e )
165
+ else
97
166
{
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 );
100
168
}
101
169
102
170
````
103
171
### Customer Information Manager (CIM)
104
172
```` 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] " ;
106
183
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 )
108
192
{
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
+ }
110
197
}
111
- catch ( Exception e )
198
+ else
112
199
{
113
- string s = e . Message ;
200
+ Console . WriteLine ( " Error: " + response . messages . message [ 0 ]. code + " " + response . messages . message [ 0 ]. text ) ;
114
201
}
115
202
116
203
````
0 commit comments