@@ -19,7 +19,15 @@ To install AuthorizeNet, run the following command in the Package Manager Consol
19
19
20
20
21
21
## Usage
22
+ Apart from this README, you can find details and examples of using the SDK in the following places:
23
+
24
+ - [ Github Sample Code Repository] ( https://github.com/AuthorizeNet/sample-code-csharp )
25
+ - [ Developer Center Reference] ( http://developer.authorize.net/api/reference/index.html )
26
+
27
+ ### Charging a Credit Card
22
28
```` csharp
29
+ ApiOperationBase <ANetApiRequest , ANetApiResponse >.RunEnvironment = AuthorizeNet .Environment .SANDBOX ;
30
+
23
31
ApiOperationBase <ANetApiRequest , ANetApiResponse >.MerchantAuthentication = new merchantAuthenticationType ()
24
32
{
25
33
name = ApiLoginID ,
@@ -62,62 +70,11 @@ To install AuthorizeNet, run the following command in the Package Manager Consol
62
70
}
63
71
````
64
72
65
- ## Registration & Configuration
66
-
67
- All the tests can be run against a stub backend using the USELOCAL run configuration.
68
-
69
- Get a sandbox account at https://developer.authorize.net/sandbox/
70
- Update app.config in the AuthorizeNetTest folder to run all the tests against your sandbox account
71
-
72
- For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Transaction Details API and enable it.
73
-
74
-
75
- ## Usage
76
-
77
- ### Advanced Merchant Integration (AIM)
78
-
79
- ```` csharp
80
- ApiOperationBase <ANetApiRequest , ANetApiResponse >.MerchantAuthentication = new merchantAuthenticationType ()
81
- {
82
- name = ApiLoginID ,
83
- ItemElementName = ItemChoiceType .transactionKey ,
84
- Item = ApiTransactionKey ,
85
- };
86
-
87
- var creditCard = new creditCardType
88
- {
89
- cardNumber = " 4111111111111111" ,
90
- expirationDate = " 0718"
91
- };
92
-
93
- var paymentType = new paymentType { Item = creditCard };
94
-
95
- var transactionRequest = new transactionRequestType
96
- {
97
- transactionType = transactionTypeEnum .authOnlyTransaction .ToString (), // authorize only
98
- amount = 35 . 45 m ,
99
- payment = paymentType
100
- };
101
-
102
- var request = new createTransactionRequest { transactionRequest = transactionRequest };
103
-
104
- var controller = new createTransactionController (request );
105
- controller .Execute ();
106
-
107
- var response = controller .GetApiResponse ();
108
-
109
- if (response .messages .resultCode == messageTypeEnum .Ok )
110
- {
111
- if (response .transactionResponse != null )
112
- {
113
- Console .WriteLine (" Success, Auth Code : " + response .transactionResponse .authCode );
114
- }
115
- }
116
- else
117
- {
118
- Console .WriteLine (" Error: " + response .messages .message [0 ].code + " " + response .messages .message [0 ].text );
119
- }
120
- ````
73
+ ### Setting the Production Environment
74
+ Set the appropriate environment constant using the ApiOperationBase RunEnvironment. For example, in the method above, to switch to production environment use:
75
+ ``` csharp
76
+ ApiOperationBase <ANetApiRequest , ANetApiResponse >.RunEnvironment = AuthorizeNet .Environment .PRODUCTION ;
77
+ ```
121
78
122
79
### Direct Post Method (DPM)
123
80
@@ -145,107 +102,15 @@ Place the following code in the default action of a simple MVC application to di
145
102
146
103
````
147
104
148
- ### Automated Recurring Billing (ARB)
149
- ```` csharp
150
- ApiOperationBase <ANetApiRequest , ANetApiResponse >.MerchantAuthentication = new merchantAuthenticationType ()
151
- {
152
- name = ApiLoginID ,
153
- ItemElementName = ItemChoiceType .transactionKey ,
154
- Item = ApiTransactionKey ,
155
- };
156
-
157
- paymentScheduleTypeInterval interval = new paymentScheduleTypeInterval ();
158
-
159
- interval .length = 1 ;
160
- interval .unit = ARBSubscriptionUnitEnum .months ;
161
-
162
- paymentScheduleType schedule = new paymentScheduleType
163
- {
164
- interval = interval ,
165
- startDate = DateTime .Now .AddDays (1 ),
166
- totalOccurrences = 9999 , // 9999 indicates no end date
167
- trialOccurrences = 3
168
- };
169
-
170
- #region Payment Information
171
- var creditCard = new creditCardType
172
- {
173
- cardNumber = " 4111111111111111" ,
174
- expirationDate = " 0718"
175
- };
176
-
177
- paymentType cc = new paymentType { Item = creditCard };
178
- #endregion
179
-
180
- nameAndAddressType addressInfo = new nameAndAddressType ()
181
- {
182
- firstName = " John" ,
183
- lastName = " Doe"
184
- };
185
-
186
- ARBSubscriptionType subscriptionType = new ARBSubscriptionType ()
187
- {
188
- amount = 35 . 55 m ,
189
- trialAmount = 0 . 00 m ,
190
- paymentSchedule = schedule ,
191
- billTo = addressInfo ,
192
- payment = cc
193
- };
194
-
195
- var request = new ARBCreateSubscriptionRequest { subscription = subscriptionType };
196
-
197
- var controller = new ARBCreateSubscriptionController (request );
198
- controller .Execute ();
199
-
200
- ARBCreateSubscriptionResponse response = controller .GetApiResponse ();
201
-
202
- if (response != null && response .messages .resultCode == messageTypeEnum .Ok )
203
- {
204
- if (response != null && response .messages .message != null )
205
- {
206
- Console .WriteLine (" Success, Subscription ID : " + response .subscriptionId .ToString ());
207
- }
208
- }
209
- else
210
- {
211
- Console .WriteLine (" Error: " + response .messages .message [0 ].code + " " + response .messages .message [0 ].text );
212
- }
213
-
214
- ````
215
- ### Customer Information Manager (CIM)
216
- ```` csharp
217
- ApiOperationBase <ANetApiRequest , ANetApiResponse >.MerchantAuthentication = new merchantAuthenticationType ()
218
- {
219
- name = ApiLoginID ,
220
- ItemElementName = ItemChoiceType .transactionKey ,
221
- Item = ApiTransactionKey ,
222
- };
223
-
224
- customerProfileType customerProfile = new customerProfileType ();
225
- customerProfile .merchantCustomerId = " TestCustomerID" ;
226
- customerProfile .
email = " [email protected] " ;
227
105
228
- var request = new createCustomerProfileRequest { profile = customerProfile , validationMode = validationModeEnum . none };
106
+ ## Running the SDK Tests
229
107
230
- var controller = new createCustomerProfileController (request );
231
- controller .Execute ();
232
-
233
- createCustomerProfileResponse response = controller .GetApiResponse ();
234
-
235
- if (response != null && response .messages .resultCode == messageTypeEnum .Ok )
236
- {
237
- if (response != null && response .messages .message != null )
238
- {
239
- Console .WriteLine (" Success, CustomerProfileID : " + response .customerProfileId );
240
- }
241
- }
242
- else
243
- {
244
- Console .WriteLine (" Error: " + response .messages .message [0 ].code + " " + response .messages .message [0 ].text );
245
- }
108
+ All the tests can be run against a stub backend using the USELOCAL run configuration.
246
109
247
- ````
110
+ Get a sandbox account at https://developer.authorize.net/sandbox/
111
+ Update app.config in the AuthorizeNetTest folder to run all the tests against your sandbox account
248
112
113
+ For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Transaction Details API and enable it.
249
114
250
115
251
116
## Credit Card Test Numbers
@@ -264,54 +129,4 @@ the CCV code.
264
129
| Diners Club/ Carte Blanche | 38000000000006 |
265
130
| Visa (Card Present Track 1) | %B4111111111111111^DOE/JOHN^1803101000000000020000831000000? |
266
131
267
- ## New Model
268
-
269
- We’re exploring a new model of maintaining the SDKs which allows us to be more responsive to API changes. This model is consistent across the different SDK languages, which is great for us, however we do not want to sacrifice your productivity by losing the inherent efficiencies in the existing object model or the specific languages. We’re introducing the new model as "supplementary" at this time and we would appreciate your feedback. Let us know what you really think! Here’s an example of a server side call with ApplePay data in the new model.
270
-
271
- ### Apple Pay Example
272
- ```` csharp
273
- static void Main (string [] args )
274
- {
275
- merchantAuthenticationType CustomMerchantAuthenticationType = new merchantAuthenticationType
276
- {
277
- name = " 5KP3u95bQpv" ,
278
- ItemElementName = ItemChoiceType .transactionKey ,
279
- Item = " 4Ktq966gC55GAX7S" ,
280
- };
281
132
282
- ApiOperationBase <ANetApiRequest , ANetApiResponse >.MerchantAuthentication = CustomMerchantAuthenticationType ;
283
- ApiOperationBase <ANetApiRequest , ANetApiResponse >.RunEnvironment = AuthorizeNet .Environment .SANDBOX ;
284
-
285
- // create a transaction
286
- var transactionRequestType = new transactionRequestType
287
- {
288
- transactionType = transactionTypeEnum .authCaptureTransaction .ToString (),
289
- // amount = SetValidTransactionAmount(Counter),
290
- amount = 15 ,
291
- payment = new paymentType { Item = new opaqueDataType { dataDescriptor = "COMMON.APPLE.INAPP.PAYMENT", dataValue = "eyJkYXRhIjoiQkRQTldTdE1tR2V3UVVXR2c0bzdFXC9qKzFjcTFUNzhxeVU4NGI2N2l0amNZSTh3UFlBT2hzaGpoWlBycWRVcjRYd1BNYmo0emNHTWR5KysxSDJWa1BPWStCT01GMjV1YjE5Y1g0bkN2a1hVVU9UakRsbEIxVGdTcjhKSFp4Z3A5ckNnc1NVZ2JCZ0tmNjBYS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U1vMUJQVnJYVFBITmNzTTk5RVBVblBxZGJlR2M4N20wckFnTUJBQUdqWERCYU1GZ0dBMVVkQVFSUk1FK0FFSFpXUHJXdEpkN1laNDMxaENnN1lGU2hLVEFuTVNVd0l3WURWUVFESGh3QVl3Qm9BRzBBWVFCcEFFQUFkZ0JwQUhNQVlRQXVBR01BYndCdGdoQmNsK1BmMytVNHBrMTNuVkQ5bndRUU1Ba0dCU3NPQXdJZEJRQURnWUVBYlVLWUNrdUlLUzlRUTJtRmNNWVJFSW0ybCtYZzhcL0pYditHQlZRSmtPS29zY1k0aU5ERkFcL2JRbG9nZjlMTFU4NFRId05SbnN2VjNQcnY3UlRZODFncTBkdEM4elljQWFBa0NISUkzeXFNbko0QU91NkVPVzlrSmsyMzJnU0U3V2xDdEhiZkxTS2Z1U2dRWDhLWFFZdVpMazJScjYzTjhBcFhzWHdCTDNjSjB4Z2VBd2dkMENBUUV3T3pBbk1TVXdJd1lEVlFRREhod0FZd0JvQUcwQVlRQnBBRUFBZGdCcEFITUFZUUF1QUdNQWJ3QnRBaEJjbCtQZjMrVTRwazEzblZEOW53UVFNQWtHQlNzT0F3SWFCUUF3RFFZSktvWklodmNOQVFFQkJRQUVnWUJhSzNFbE9zdGJIOFdvb3NlREFCZitKZ1wvMTI5SmNJYXdtN2M2VnhuN1phc05iQXEzdEF0OFB0eSt1UUNnc3NYcVprTEE3a3oyR3pNb2xOdHY5d1ltdTlVandhcjFQSFlTK0JcL29Hbm96NTkxd2phZ1hXUnowbk1vNXkzTzFLelgwZDhDUkhBVmE4OFNyVjFhNUpJaVJldjNvU3RJcXd2NXh1WmxkYWc2VHI4dz09In0=" } }
292
-
293
- };
294
-
295
- var createRequest = new createTransactionRequest
296
- {
297
- refId = " 2345" ,
298
- transactionRequest = transactionRequestType ,
299
- };
300
-
301
- var createController = new createTransactionController (createRequest );
302
- createController .Execute ();
303
- var createResponse = createController .GetApiResponse ();
304
-
305
- if (createResponse != null )
306
- {
307
- var tResponse = createResponse .transactionResponse ;
308
-
309
- if ((tResponse != null )&& (tResponse .responseCode == " 1" ))
310
- {
311
- Console .WriteLine (" AUTH CODE : " + tResponse .authCode );
312
- Console .WriteLine (" TRANS ID : " + tResponse .transId );
313
- Console .ReadLine ();
314
- }
315
- }
316
- }
317
- ````
0 commit comments