Skip to content
This repository has been archived by the owner on Jun 2, 2024. It is now read-only.

Commit

Permalink
Added NimbusResult - Now correctly interprets the result from the API…
Browse files Browse the repository at this point in the history
… and returns a NimbusResult object.

Updated Required Data Points.
  • Loading branch information
adamreed90 committed Feb 23, 2016
1 parent b8706d9 commit 60e1e05
Show file tree
Hide file tree
Showing 4 changed files with 91 additions and 13 deletions.
79 changes: 79 additions & 0 deletions Data/NimbusResult.cs
Original file line number Diff line number Diff line change
@@ -1,12 +1,91 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;

namespace NimbusSharp.Data
{
public class NimbusResult
{
public NimbusResult(string resultData)
{
NimbusCode resultCode;
var regex = new Regex("\\[\"(?<result>.*)\\\"]");
var match = regex.Match(resultData);
var result = match.Groups["result"].ToString();

if (Enum.TryParse(result, true, out resultCode))
{
ResultCode = resultCode;
}
else
{
ResultCode = NimbusCode.Approved;
AuthCode = result;
}
}

public string AuthCode { get; set; }

public NimbusCode ResultCode { get; set; }

}

public enum NimbusCode : int
{
Declined = 100,
MerchantNumberRequired = 101,
CardNumberRequired = 102,
PurchaseTotalRequired = 103,
EmployeeNameRequired = 104,
EmployeeNumberRequired = 105,
RequiresTotaltoReload = 106,
RequiresauthNum = 107,
AuthNumNotfound = 108,
EmailorPhoneRequired = 109,
FunctionRequired = 110,
UsernameRequired = 111,
PasswordRequired = 112,
UserTeamRequired = 113,
UserActivityRequired = 114,
UserFullNameRequired = 115,
UserEmailRequired = 116,
UserHashRequired = 117,
UserFlagRequired = 118,
UserNotFound = 119,
EftTransactionTypeRequired = 120,
CardCannotBeVerified = 152,
InvalidCardDataSent = 153,
NameonCardRequired = 154,
CardExpirationDateRequired = 155,
CardSecurityCodeRequired = 156,
CardZipcodeRequired = 157,
MerchantNotFound = 199,
Approved = 200,
CardDoesNotExsist = 201,
AmountisRequiredtoProcess = 202,
EmailAlreadybeingusedbyMerchant = 295,
PhoneAlreadybeingused = 296,
CardAlreadyRegistered = 297,
MerchantIsAlreadyUsingCardNumber = 298,
MerchantLoyaltyProgramisnotactive = 299,
Success = 300,
Merchantisalreadyusingthatusername = 305,
Userdatatyperequired = 306,
UsermustberegisteredinLoyaltyProgram = 307,
Failuretoadduser = 308,
Oneidentifiermustbesupplied = 309,
CardSuccessfullyVerified = 352,
UndefinedError = 500,
MerchantmusthaveanactiveGiftCardProgram = 501,
GpsCoordinatesRequired = 600,
MerchantBoarded = 650,
TestAccountStatusRequired = 700,
Userisnotactive = 998,
MerchantisInactive = 999,

}
}
11 changes: 8 additions & 3 deletions Data/Void.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,13 @@ public class Void : NimbusFunction
public string EmployeeTeam { get; set; }
[Property("in", false)]
public string InvoiceId { get; set; }



[Property("en", false)]
public string EmployeeName { get; set; }
[Property("cUnum", true)]
public string EmployeeId { get; set; }
[Property("amt", true)]
public decimal Amount{ get; set; }
[Property("ip", false)]
public string IpAddress { get; set; }
}
}
12 changes: 3 additions & 9 deletions NimbusSharp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,8 @@ public NimbusSharp(string merchantId, string apiKey)
_merchantId = merchantId;
_apiKey = apiKey;
}


public async Task<string> Execute(NimbusFunction function)

public async Task<NimbusResult> Execute(NimbusFunction function)
{
CheckRequiredProperties(function);

Expand Down Expand Up @@ -73,14 +72,9 @@ public async Task<string> Execute(NimbusFunction function)
};
var response = await client.SendAsync(httpContent);
var result = await response.Content.ReadAsStringAsync();
return result;
return new NimbusResult(result);
}






private static void CheckRequiredProperties(NimbusFunction function)
{
//Check for Required Data
Expand Down
2 changes: 1 addition & 1 deletion NimbusSharp.nuspec
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<projectUrl>https://github.com/adamreed90/NimbusSharp</projectUrl>
<iconUrl>https://github.com/adamreed90/NimbusSharp</iconUrl>
<requireLicenseAcceptance>true</requireLicenseAcceptance>
<description>A drag and drop library for Nimbus Processing, .NET Universal PCL</description>
<description>NimbusSharp is a .NET Universal Library for use with Nimbus Processing</description>
<releaseNotes>First Release Package.</releaseNotes>
<copyright>Copyright ©2016 Adam E. Reed. All rights reserved.</copyright>
<tags>nimbus nimbusprocessing payment processing</tags>
Expand Down

0 comments on commit 60e1e05

Please sign in to comment.