Skip to content

Commit 88d3ae1

Browse files
authored
Merge pull request #1 from broadvoice/feature/netcore_target
Feature/netcore target
2 parents de42bc7 + bd0d5f8 commit 88d3ae1

File tree

122 files changed

+21533
-37
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

122 files changed

+21533
-37
lines changed

.gitignore

Lines changed: 106 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,15 @@
44
# User-specific files
55
*.suo
66
*.user
7+
*.userosscache
78
*.sln.docstates
9+
tests.unit
10+
sql.bootstrap
11+
build.txt
12+
nohup.out
13+
14+
# User-specific files (MonoDevelop/Xamarin Studio)
15+
*.userprefs
816

917
# Build results
1018
[Dd]ebug/
@@ -17,15 +25,17 @@ build/
1725
bld/
1826
[Bb]in/
1927
[Oo]bj/
28+
[Ll]og/
29+
*.rpm
2030

21-
# Roslyn cache directories
22-
*.ide/
31+
# Visual Studio 2015 cache/options directory
32+
.vs/
2333

2434
# MSTest test Results
2535
[Tt]est[Rr]esult*/
2636
[Bb]uild[Ll]og.*
2737

28-
#NUNIT
38+
# NUNIT
2939
*.VisualState.xml
3040
TestResult.xml
3141

@@ -34,6 +44,11 @@ TestResult.xml
3444
[Rr]eleasePS/
3545
dlldata.c
3646

47+
# DNX
48+
project.lock.json
49+
project.fragment.lock.json
50+
artifacts/
51+
3752
*_i.c
3853
*_p.c
3954
*_i.h
@@ -69,11 +84,14 @@ ipch/
6984
*.opensdf
7085
*.sdf
7186
*.cachefile
87+
*.VC.db
88+
*.VC.VC.opendb
7289

7390
# Visual Studio profiler
7491
*.psess
7592
*.vsp
7693
*.vspx
94+
*.sap
7795

7896
# TFS 2012 Local Workspace
7997
$tf/
@@ -86,7 +104,7 @@ _ReSharper*/
86104
*.[Rr]e[Ss]harper
87105
*.DotSettings.user
88106

89-
# JustCode is a .NET coding addin-in
107+
# JustCode is a .NET coding add-in
90108
.JustCode
91109

92110
# TeamCity is a build add-in
@@ -98,6 +116,7 @@ _TeamCity*
98116
# NCrunch
99117
_NCrunch_*
100118
.*crunch*.local.xml
119+
nCrunchTemp_*
101120

102121
# MightyMoose
103122
*.mm.*
@@ -136,19 +155,29 @@ publish/
136155
**/packages/*
137156
# except build/, which is used as an MSBuild target.
138157
!**/packages/build/
139-
# If using the old MSBuild-Integrated Package Restore, uncomment this:
140-
#!**/packages/repositories.config
158+
# Uncomment if necessary however generally it will be regenerated when needed
159+
!**/packages/repositories.config
160+
# NuGet v3's project.json files produces more ignoreable files
161+
*.nuget.props
162+
*.nuget.targets
141163

142164
# Windows Azure Build Output
143165
csx/
144166
*.build.csdef
145167

146168
# Windows Store app package directory
147169
AppPackages/
170+
BundleArtifacts/
171+
Package.StoreAssociation.xml
172+
_pkginfo.txt
173+
174+
# Visual Studio cache files
175+
# files ending in .cache can be ignored
176+
*.[Cc]ache
177+
# but keep track of directories ending in .cache
178+
!*.[Cc]ache/
148179

149180
# Others
150-
sql/
151-
*.Cache
152181
ClientBin/
153182
[Ss]tyle[Cc]op.*
154183
~$*
@@ -158,6 +187,11 @@ ClientBin/
158187
*.pfx
159188
*.publishsettings
160189
node_modules/
190+
orleans.codegen.cs
191+
192+
# Since there are multiple workflows, uncomment next line to ignore bower_components
193+
# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
194+
bower_components/
161195

162196
# RIA/Silverlight projects
163197
Generated_Code/
@@ -173,6 +207,7 @@ UpgradeLog*.htm
173207
# SQL Server files
174208
*.mdf
175209
*.ldf
210+
dump.rdb
176211

177212
# Business Intelligence projects
178213
*.rdl.data
@@ -181,3 +216,66 @@ UpgradeLog*.htm
181216

182217
# Microsoft Fakes
183218
FakesAssemblies/
219+
220+
# GhostDoc plugin setting file
221+
*.GhostDoc.xml
222+
223+
# Node.js Tools for Visual Studio
224+
.ntvs_analysis.dat
225+
226+
# Visual Studio 6 build log
227+
*.plg
228+
229+
# Visual Studio 6 workspace options file
230+
*.opt
231+
232+
#MonoDevelop
233+
*.pidb
234+
235+
# Paket dependency manager
236+
.paket/paket.exe
237+
paket-files/
238+
239+
# FAKE - F# Make
240+
.fake/
241+
242+
# JetBrains Rider
243+
.idea/
244+
*.sln.iml
245+
246+
# VS Code (we want to allow this!)
247+
#.vscode/ #we want to allo
248+
249+
# Java
250+
*.class
251+
252+
# Mobile Tools for Java (J2ME)
253+
.mtj.tmp/
254+
255+
# Java Package Files #
256+
*.jar
257+
*.war
258+
*.ear
259+
260+
# JVM crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
261+
hs_err_pid*
262+
263+
#Grunt
264+
.grunt
265+
266+
#Node
267+
node_modules
268+
jspm_packages
269+
.npm
270+
.node_repl_history
271+
272+
#Rider
273+
.idea.*
274+
doxygen.exe
275+
published/
276+
TestResult.xml
277+
TestResult.xml
278+
TestResult.xml
279+
TestResult.xml
280+
tests.unit
281+
nil

Authorize.NET/AuthorizeNET.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
<AppDesignerFolder>Properties</AppDesignerFolder>
1111
<RootNamespace>AuthorizeNet</RootNamespace>
1212
<AssemblyName>AuthorizeNet</AssemblyName>
13-
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
13+
<TargetFrameworkVersion>v4.5</TargetFrameworkVersion>
1414
<FileAlignment>512</FileAlignment>
1515
<TargetFrameworkProfile />
1616
<FileUpgradeFlags>

Authorize.NET/Environment.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ namespace AuthorizeNet
1818

1919
public class Environment {
2020
public static readonly Environment SANDBOX = new Environment("https://test.authorize.net", "https://apitest.authorize.net", "https://test.authorize.net");
21+
//public static readonly Environment SANDBOX = new Environment("https://apitest.authorize.net", "https://apitest.authorize.net", "https://apitest.authorize.net");
2122
public static readonly Environment PRODUCTION = new Environment("https://secure2.authorize.net","https://api2.authorize.net","https://cardpresent.authorize.net");
2223
public static readonly Environment LOCAL_VM = new Environment(null, null, null);
2324
public static readonly Environment HOSTED_VM = new Environment(null, null, null);

Authorize.NET/Utility/HttpXmlUtility.cs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ public ANetApiResponse Send(ANetApiRequest apiRequest) {
5454
//Authenticate it
5555
AuthenticateRequest(apiRequest);
5656

57+
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
58+
59+
5760
HttpWebRequest webRequest = (HttpWebRequest)WebRequest.Create(_serviceUrl);
5861
webRequest.Method = "POST";
5962
webRequest.ContentType = "text/xml";
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<TargetFramework>netcoreapp1.1</TargetFramework>
5+
</PropertyGroup>
6+
7+
<ItemGroup>
8+
<PackageReference Include="Microsoft.Extensions.DependencyInjection" Version="1.1.1" />
9+
<PackageReference Include="Microsoft.Extensions.Logging" Version="1.1.2" />
10+
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />
11+
<PackageReference Include="xunit" Version="2.2.0" />
12+
<PackageReference Include="xunit.runner.visualstudio" Version="2.2.0" />
13+
</ItemGroup>
14+
15+
<ItemGroup>
16+
<ProjectReference Include="..\AuthorizeNETnetcore\AuthorizeNETnetcore.csproj" />
17+
</ItemGroup>
18+
19+
<ItemGroup>
20+
<Service Include="{82a7f48d-3b50-4b1e-b82e-3ada8210c358}" />
21+
</ItemGroup>
22+
23+
<ItemGroup>
24+
<None Update="appSettings.json">
25+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
26+
</None>
27+
</ItemGroup>
28+
</Project>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Security.Cryptography;
4+
using System.Text;
5+
6+
namespace AuthorizeNET_xunit
7+
{
8+
public class RandomStringGenerator
9+
{
10+
readonly Random _rand;
11+
12+
public RandomStringGenerator(int seed = 0)
13+
{
14+
_rand = new Random(seed);
15+
}
16+
17+
public string Len(int min, int max = Int32.MaxValue)
18+
{
19+
int size = _rand.Next(min, max);
20+
string resultString = GetRandomBase64EncodedData(size);
21+
if (resultString.Length > size)
22+
{
23+
return resultString.Substring(0, size);
24+
}
25+
return resultString;
26+
}
27+
28+
private static string GetRandomBase64EncodedData(int size)
29+
{
30+
return Convert.ToBase64String(GetRandomByteArray(size));
31+
}
32+
33+
private static Byte[] GetRandomByteArray(int size)
34+
{
35+
byte[] value = new byte[size];
36+
var random = RandomNumberGenerator.Create();
37+
random.GetBytes(value);
38+
return value;
39+
}
40+
}
41+
}

AuthorizeNET-xunit/UnitTest1.cs

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
using System;
2+
using AuthorizeNet;
3+
using Xunit;
4+
5+
6+
namespace AuthorizeNET_xunit
7+
{
8+
public class UnitTest1
9+
{
10+
protected string ApiLogin;
11+
protected string TransactionKey;
12+
private CustomerGateway _target;
13+
14+
[Fact]
15+
public void ClientConnection_Success()
16+
{
17+
var sError = CheckApiLoginTransactionKey();
18+
Assert.True(sError == "", sError);
19+
20+
_target = new CustomerGateway(ApiLogin, TransactionKey);
21+
var result = _target.GetCustomerIDs();
22+
Assert.NotNull(result);
23+
}
24+
25+
[Fact]
26+
public void AuthorizeCharge_Success()
27+
{
28+
var sError = CheckApiLoginTransactionKey();
29+
Assert.True(sError == "", sError);
30+
31+
_target = new CustomerGateway(ApiLogin, TransactionKey);
32+
33+
RandomStringGenerator generator = new RandomStringGenerator();
34+
var email = generator.Len(10, 55) + "@visa.com";
35+
const string description = "Authorization Test";
36+
var customer = CreateCustomer(email, description);
37+
Assert.NotNull(customer);
38+
Assert.True(!string.IsNullOrWhiteSpace(customer.ProfileID), "Unable to create customer");
39+
40+
string paymentProfileId = CreateCustomerPaymentProfile(customer.ProfileID, "4111111111111111", 1, 2030);
41+
Assert.NotNull(paymentProfileId);
42+
Assert.True(!string.IsNullOrWhiteSpace(paymentProfileId), "Unable to create payment profile Id");
43+
44+
decimal chargeAmount = 3;
45+
var response = _target.Authorize(customer.ProfileID, paymentProfileId, chargeAmount);
46+
47+
Assert.True(response.Approved, "Charge was not approved");
48+
Assert.NotNull(response.AuthorizationCode);
49+
}
50+
51+
private string CreateCustomerPaymentProfile(string custProfileId, string cardNumber, int expirationMonth, int expirationYear)
52+
{
53+
string custPaymentProfileId = null;
54+
custPaymentProfileId = _target.AddCreditCard(custProfileId, cardNumber, expirationMonth, expirationYear);
55+
Assert.NotNull(custPaymentProfileId);
56+
return custPaymentProfileId;
57+
}
58+
59+
private Customer CreateCustomer(string email, string description, string custId = "")
60+
{
61+
Customer customer = null;
62+
customer = _target.CreateCustomer(email, description, custId);
63+
Assert.NotNull(customer);
64+
return customer;
65+
}
66+
67+
/// <summary>
68+
/// CheckApiLoginTransactionKey - make sure that we are not using the default invalid ApiLogin and TransactionKey.
69+
/// </summary>
70+
protected string CheckApiLoginTransactionKey()
71+
{
72+
ApiLogin = AuthorizeNet.Test.UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvApiLoginid, AuthorizeNet.Util.Constants.PropApiLoginid);
73+
TransactionKey = AuthorizeNet.Test.UnitTestData.GetPropertyFromNames(AuthorizeNet.Util.Constants.EnvTransactionKey, AuthorizeNet.Util.Constants.PropTransactionKey);
74+
75+
string sRet = "";
76+
//if ((string.IsNullOrEmpty(ApiLogin)) || (ApiLogin.Trim().Length == 0)
77+
// || (string.IsNullOrEmpty(TransactionKey)) || (TransactionKey.Trim().Length == 0))
78+
//{
79+
// LoadLoginTranskey();
80+
//}
81+
82+
if ((string.IsNullOrEmpty(ApiLogin)) || (ApiLogin.Trim().Length == 0)
83+
|| (string.IsNullOrEmpty(TransactionKey)) || (TransactionKey.Trim().Length == 0))
84+
{
85+
sRet = "Invalid Login / Password: blank \n";
86+
}
87+
88+
#if !USELOCAL
89+
if ((ApiLogin == "ApiLogin") || (TransactionKey == "TransactionKey"))
90+
{
91+
sRet += "Invalid Login / Password \n";
92+
}
93+
#endif
94+
return sRet;
95+
}
96+
}
97+
}

0 commit comments

Comments
 (0)