Skip to content

Commit 65ba966

Browse files
committed
Conflicts: .travis.yml
2 parents e961bb9 + 0908228 commit 65ba966

File tree

6 files changed

+44
-224
lines changed

6 files changed

+44
-224
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "sample-code-csharp"]
2+
path = sample-code-csharp
3+
url = https://github.com/Authorizenet/sample-code-csharp.git

.travis.yml

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -2,28 +2,19 @@ language:
22
csharp
33

44
install:
5-
- nuget restore ./AuthorizeNET.sln
6-
#- chmod +x ./src/packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe
75
- sudo apt-get install nunit-console
8-
- sudo apt-get install gtk-sharp2
9-
- curl -sS https://api.nuget.org/packages/mono.cecil.0.9.5.4.nupkg > /tmp/mono.cecil.0.9.5.4.nupkg.zip
10-
- unzip /tmp/mono.cecil.0.9.5.4.nupkg.zip -d /tmp/cecil
11-
- cp /tmp/cecil/lib/net40/Mono.Cecil.dll .
12-
- cp /tmp/cecil/lib/net40/Mono.Cecil.dll /tmp/cecil/
13-
- git clone --depth=50 git://github.com/csMACnz/monocov.git ../../csMACnz/monocov
14-
- cd ../../csMACnz/monocov
15-
- cp /tmp/cecil/Mono.Cecil.dll .
16-
- ./configure
17-
- make
18-
- sudo make install
19-
- cd ../../namanbansal/sdk-dotnet
206

7+
before_script:
8+
- git submodule update --recursive
9+
2110
script:
2211
- xbuild ./Authorize.NET/AuthorizeNET.csproj
2312
- xbuild ./AuthorizeNETtest/AuthorizeNETtest.csproj
2413
# make mono happy by copying the config file with project name
2514
- cp AuthorizeNETtest/App.config AuthorizeNETtest/AuthorizeNETtest.config
26-
- nunit-console --debug --profile=monocov:outfile=monocovCoverage.cov,+[AuthorizeNET],+[AuthorizeNet.Api.Controllers.MockTest] ./AuthorizeNETtest/AuthorizeNETtest.csproj -run=AuthorizeNet.Api.Controllers.MockTest -exclude Integration
27-
- export LD_LIBRARY_PATH=/usr/local/lib
28-
#- mono --debug --profile=monocov:outfile=monocovCoverage.cov,+[AuthorizeNET],+[AuthorizeNet.Api.Controllers.MockTest] ./src/packages/xunit.runners.1.9.2/tools/xunit.console.clr4.exe ./src/GameOfLife.xUnit.Tests/bin/Release/GameOfLife.xUnit.Tests.dll /noshadow
29-
- monocov --export-xml=monocovCoverage monocovCoverage.cov
15+
- nunit-console ./AuthorizeNETtest/AuthorizeNETtest.csproj -run=AuthorizeNet.Api.Controllers.MockTest -exclude Integration,NotWorkingOnMono
16+
17+
- cp ./Authorize.NET/bin/Debug/AuthorizeNet.dll ./sample-code-csharp/
18+
- xbuild ./sample-code-csharp/SampleCode.csproj
19+
- xbuild ./sample-code-csharp/SampleCodeTest/SampleCodeTest.csproj
20+
- nunit-console ./sample-code-csharp/SampleCodeTest/SampleCodeTest.csproj -run=SampleCodeTest

Authorize.NET/Api/Contracts/V1/RequestFactoryWithSpecified.cs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -725,15 +725,24 @@ public static void ARBSubscriptionType(ARBSubscriptionType argument)
725725
if (null != argument)
726726
{
727727
paymentScheduleType(argument.paymentSchedule);
728-
if (0 <= argument.amount) { argument.amountSpecified = true; }
729-
if (0 <= argument.trialAmount) { argument.trialAmountSpecified = true; }
728+
if (0 < argument.amount) { argument.amountSpecified = true; }
729+
730730
paymentType(argument.payment);
731731
orderType(argument.order);
732732
customerType(argument.customer);
733733
nameAndAddressType(argument.billTo);
734734
nameAndAddressType(argument.shipTo);
735735
}
736736
}
737+
738+
public static void ARBSubscriptionTypeSetTrialAmountSpecified(ARBSubscriptionType argument)
739+
{
740+
if (null != argument)
741+
{
742+
if (0 <= argument.trialAmount) { argument.trialAmountSpecified = true; }
743+
}
744+
}
745+
737746
public static void paymentDetails(paymentDetails argument)
738747
{
739748
if (null != argument)
@@ -826,6 +835,7 @@ public static void ARBCreateSubscriptionRequest(ARBCreateSubscriptionRequest arg
826835
if (null != argument)
827836
{
828837
ARBSubscriptionType(argument.subscription);
838+
ARBSubscriptionTypeSetTrialAmountSpecified(argument.subscription);
829839
}
830840
}
831841
public static void ARBCreateSubscriptionResponse(ARBCreateSubscriptionResponse argument)

AuthorizeNet.nuspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<package xmlns="http://schemas.microsoft.com/packaging/2010/07/nuspec.xsd">
33
<metadata>
44
<id>AuthorizeNet</id>
5-
<version>1.8.8</version>
5+
<version>1.8.9</version>
66
<title>AuthorizeNet</title>
77
<authors>Authorize.Net</authors>
88
<owners>AuthorizeNet</owners>

README.md

Lines changed: 18 additions & 203 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,15 @@ To install AuthorizeNet, run the following command in the Package Manager Consol
1919

2020

2121
## 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
2228
````csharp
29+
ApiOperationBase<ANetApiRequest, ANetApiResponse>.RunEnvironment = AuthorizeNet.Environment.SANDBOX;
30+
2331
ApiOperationBase<ANetApiRequest, ANetApiResponse>.MerchantAuthentication = new merchantAuthenticationType()
2432
{
2533
name = ApiLoginID,
@@ -62,62 +70,11 @@ To install AuthorizeNet, run the following command in the Package Manager Consol
6270
}
6371
````
6472

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.45m,
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+
```
12178

12279
### Direct Post Method (DPM)
12380

@@ -145,107 +102,15 @@ Place the following code in the default action of a simple MVC application to di
145102

146103
````
147104

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.55m,
189-
trialAmount = 0.00m,
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]";
227105

228-
var request = new createCustomerProfileRequest { profile = customerProfile, validationMode = validationModeEnum.none};
106+
## Running the SDK Tests
229107

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.
246109

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
248112

113+
For reporting tests, go to https://sandbox.authorize.net/ under Account tab->Transaction Details API and enable it.
249114

250115

251116
## Credit Card Test Numbers
@@ -264,54 +129,4 @@ the CCV code.
264129
| Diners Club/ Carte Blanche | 38000000000006 |
265130
| Visa (Card Present Track 1) | %B4111111111111111^DOE/JOHN^1803101000000000020000831000000? |
266131

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-
};
281132

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 = "eyJkYXRhIjoiQkRQTldTd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dz09In0=" } }
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-
````

sample-code-csharp

Submodule sample-code-csharp added at 40526f6

0 commit comments

Comments
 (0)