Skip to content

Commit

Permalink
Added: EBT Wic (eWic), Gift Card, Fraud Submit. Introduced AvsResultT…
Browse files Browse the repository at this point in the history
…ype, which may break current implementations. API implementation complete.
  • Loading branch information
ahwm committed Oct 30, 2018
1 parent 32f58db commit fe85ea3
Show file tree
Hide file tree
Showing 9 changed files with 954 additions and 17 deletions.
716 changes: 716 additions & 0 deletions src/Cardknox.NET/Cardknox.cs

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions src/Cardknox.NET/Cardknox.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@
<Product>Cardknox.API.Wrapper</Product>
<GeneratePackageOnBuild>false</GeneratePackageOnBuild>
<RootNamespace>CardknoxApi</RootNamespace>
<Version>3.1.1</Version>
<Version>4.0</Version>
<PackageProjectUrl>https://cardknox.adamh.us/</PackageProjectUrl>
<PackageLicenseUrl>https://github.com/ahwm/Cardknox-API-Wrapper/blob/master/LICENSE</PackageLicenseUrl>
<Description>API Wrapper for Cardknox Payment Processor written in C#

Refer to https://kb.cardknox.com/api for full API reference.</Description>
<PackageReleaseNotes>Maintenance release to fix an issue with logging</PackageReleaseNotes>
<PackageTags>cardknox gateway processor payment api</PackageTags>
<PackageReleaseNotes>Added: EBT Wic (eWic), Gift Card, Fraud Submit. Introduced AvsResultType, which may break current implementations. API implementation complete.</PackageReleaseNotes>
<PackageTags>cardknox gateway processor payment api ebt mastercard payments american express amex jcb diners club giftcard gift card discover</PackageTags>
<Copyright>© 2018 Adam Humpherys</Copyright>
<AssemblyVersion>3.0.0.0</AssemblyVersion>
<AssemblyVersion>4.0.0.0</AssemblyVersion>
</PropertyGroup>

<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|AnyCPU'">
Expand Down
4 changes: 1 addition & 3 deletions src/Cardknox.NET/CardknoxRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,7 @@ public CardknoxRequest(string key, string software, string softwareVersion, stri
/// <returns></returns>
public static CardknoxRequest BeginRequest(string key, string software, string softwareVersion, string cardknoxVer = null)
{
CardknoxRequest r = new CardknoxRequest(key, software, softwareVersion, cardknoxVer);

return r;
return new CardknoxRequest(key, software, softwareVersion, cardknoxVer);
}
}
}
4 changes: 2 additions & 2 deletions src/Cardknox.NET/CardknoxResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public class CardknoxResponse
/// <summary>
///
/// </summary>
public string AvsResultCode { get; }
public AvsResponseType AvsResultCode { get; }
/// <summary>
///
/// </summary>
Expand Down Expand Up @@ -96,7 +96,7 @@ public CardknoxResponse(NameValueCollection _values)
if (_values.AllKeys.Contains("xBatch"))
Batch = _values["xBatch"];
if (_values.AllKeys.Contains("xAvsResultCode"))
AvsResultCode = _values["xAvsResultCode"];
AvsResultCode = (AvsResponseType)Enum.Parse(typeof(AvsResponseType), _values["xAvsResultCode"]);
if (_values.AllKeys.Contains("xAvsResult"))
AvsResult = HttpUtility.UrlDecode(_values["xAvsResult"]);
if (_values.AllKeys.Contains("xAuthAmount"))
Expand Down
77 changes: 77 additions & 0 deletions src/Cardknox.NET/Operations/EBTW.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

namespace CardknoxApi.Operations
{
/// <summary>
/// The Sale command is used to make a purchase on an EBTW cardholder's cash benefit account.
/// </summary>
public class EBTWSale : Sale
{
internal string Operation => "ebtw:sale";

/// <summary>
/// Items included in the sale transaction operation
/// </summary>
public EBTWItems Items { get; set; }
}
/// <summary>
/// The Cash Balance enables a cash withdrawal from on an EBTW cardholder's cash benefit account.
/// </summary>
public class EBTWBalance : OperationBase
{
internal string Operation => "ebtw:balance";
}
/// <summary>
/// Void a transaction
/// </summary>
public class EBTWVoid : OperationBase
{
internal string Operation => "ebtw:void";

/// <summary>
/// Used to reference a previous transaction when doing a follow-up transaction, typically a refund, void, or capture. (Note: xRefnum can be a 64-bit number and should be stored as BIGINT, Long, Int64 or String)
/// </summary>
public string RefNum { get; set; }
}
/// <summary>
///
/// </summary>
public class EBTWItems : IEnumerable<EBTWItem>
{
private List<EBTWItem> _items = new List<EBTWItem>();

public int Count => _items.Count;
public void Add(EBTWItem item) => _items.Add(item);

public IEnumerator<EBTWItem> GetEnumerator()
{
return _items.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
/// <summary>
///
/// </summary>
public class EBTWItem
{
/// <summary>
/// Unit price for item specified in xUPC
/// </summary>
public decimal UnitPrice { get; set; }
/// <summary>
/// Quantity of item specified in xUPC.
/// </summary>
public int Qty { get; set; }
/// <summary>
/// Universal Product Code.
/// </summary>
public string Upc { get; set; }
}
}
44 changes: 44 additions & 0 deletions src/Cardknox.NET/Operations/Fraud.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CardknoxApi.Operations
{
/// <summary>
/// The Submit command is used in conjunction with a valid FraudWatch account to submit ecommerce transactions for a fraud verification check.
/// </summary>
public class FraudSubmit : Sale
{
internal string Operation => "fraud:submit";

/// <summary>
/// Masked Card number with BIN and last 4 digits exposed
/// </summary>
public new string CardNum { get; set; }

/// <summary>
/// Transaction RefNum received from Gateway for FraudWatch verification.
/// </summary>
public string GatewayRefNum { get; set; }
/// <summary>
/// Transaction status received from gateway for FraudWatch verification.
/// </summary>
public StatusType GatewayResult { get; set; }
/// <summary>
/// CVV for for FraudWatch verification. (M or N)
/// </summary>
public string GatewayCVV { get; set; }
/// <summary>
/// Street Address for FraudWatch verification.
/// </summary>
public AvsResponseType GatewayAVS { get; set; }
/// <summary>
/// Transaction RefNum received from Gateway for FraudWatch verification.
/// </summary>
public string GatewayError { get; set; }
/// <summary>
/// Specifies if the order origin is Internet OR Phone for FraudWatch verification.
/// </summary>
public OrderType OrderType { get; set; }
}
}
28 changes: 28 additions & 0 deletions src/Cardknox.NET/Operations/GiftCard.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace CardknoxApi.Operations
{
/// <summary>
/// The Issue command is used to issue funds to a Cardknox gift card.
/// </summary>
public class GCIssue : Sale
{
internal string Operation => "gift:issue";
}
/// <summary>
/// The Redeem command is used to debit funds from a Cardknox gift card.
/// </summary>
public class GCRedeem : Sale
{
internal string Operation => "gift:redeem";
}
/// <summary>
/// The Balance command is used to check the available balance on a Cardknox gift card.
/// </summary>
public class GCBalance : Sale
{
internal string Operation => "gift:balance";
}
}
27 changes: 27 additions & 0 deletions src/Cardknox.NET/Operations/OperationBase.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;

Expand Down Expand Up @@ -101,5 +102,31 @@ public class OperationBase : Customer
/// True/False value indicating if the email address specificied in xEmail should receive a receipt containing the transaction details. (CC/Check operations only)
/// </summary>
public bool CustReceipt { get; set; } = false;

public CardknoxCustomFields CustomFields { get; set; } = new CardknoxCustomFields();
}
public class CardknoxCustomFields : IEnumerable<string>
{
private List<string> _fields = new List<string>();

public int Count => _fields.Count;

public void Add(string val)
{
if (_fields.Count >= 20)
throw new InvalidOperationException("A maximum of 20 entries can be specified through custom fields.");

_fields.Add(val);
}

public IEnumerator<string> GetEnumerator()
{
return _fields.GetEnumerator();
}

IEnumerator IEnumerable.GetEnumerator()
{
return this.GetEnumerator();
}
}
}
63 changes: 55 additions & 8 deletions src/Cardknox.NET/ResultType.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,14 +45,61 @@ public enum StatusType
/// </summary>
public enum CardType
{
Unknown,
EBT,
GiftCard,
Amex,
Visa,
MasterCard,
Discover,
Diners,
Unknown,
EBT,
GiftCard,
Amex,
Visa,
MasterCard,
Discover,
Diners,
JCB
}
/// <summary>
/// The Address Verification Service (AVS) response code
/// </summary>
public enum AvsResponseType
{
/// <summary>
/// Address: Match & 5 Digit Zip: Match
/// </summary>
YYY,
/// <summary>
/// Address: No Match & 5 Digit Zip: Match
/// </summary>
NYZ,
/// <summary>
/// Address: Match & 5 Digit Zip: No Match
/// </summary>
YNA,
/// <summary>
/// Address: No Match & 5 Digit Zip: No Match
/// </summary>
NNN,
/// <summary>
/// Address Information not verified for domestic transaction
/// </summary>
XXU,
/// <summary>
/// Address: Match & 9 Digit Zip: Match
/// </summary>
YYX,
/// <summary>
/// Address: No Match & 9 Digit Zip: Match
/// </summary>
NYW,
/// <summary>
/// Retry / System Unavailable
/// </summary>
XXR,
/// <summary>
/// Service Not Supported
/// </summary>
XXS
}
public enum OrderType
{
Internet,
Phone
}
}

0 comments on commit fe85ea3

Please sign in to comment.