Skip to content
ahwm edited this page Oct 22, 2018 · 5 revisions

Charge a Credit Card (Sale)

Note: You may either pass a CardNum with a CVV and an expiration date OR pass a Token OR pass the raw card data (as MagStripe). The API will not accept multiple.

The order of preference for the API wrapper:

  1. Card Number, Expiration Date, CVV (optional)
  2. Token
  3. Mag Stripe.
using CardknoxApi;
using CardknoxApi.Operations;

CCSale save = new CCSale
{
    CardNum = "4444333322221111",
    CVV = "123", // optional, requirement determined by software security settings
    Exp = "1222" // Expiration Date: MMyy
};
Cardknox c = new  Cardknox(new CardknoxRequest("CardknoxKey", "SoftwareName", "SoftwareVersion"));
CardknoxResponse resp = c.CCSale(sale);

if (resp.HasError)
    throw new Exception(resp.Error);

string transactionId = resp.RefNum; // Always returned regardless of outcome
StatusType status = resp.Status; // Approved, Declined, Error
ResultType result = resp.Result; // A, D, E
string cardNum = resp.MaskedCardNumber; // eg 4xxxxxxxxxxx1111
string token = resp.Token; // Token returned for use with future transaction.
CardType cardType = resp.CardType; // Visa, Discover, etc
Clone this wiki locally