Code Samples

Programming Language

C#

//Request
  System.Collections.Specialized.NameValueCollection 
  MyPost = new System.Collections.Specialized.NameValueCollection();
  MyPost.Add("xKey", ""); // Credential
  MyPost.Add("xVersion", "4.5.5"); // API version
  MyPost.Add("xSoftwareName", My.Application.Info.Title); // Name of your software
  MyPost.Add("xSoftwareVersion", My.Application.Info.Version.ToString); // Version of your software
  MyPost.Add("xCommand", "cc:sale");
  MyPost.Add("xCardNum", "");
  MyPost.Add("xExp", "");
  MyPost.Add("xName", "");
  MyPost.Add("xAmount", "");
  MyPost.Add("xAccount", "");
  MyPost.Add("xMagstripe", "");
  MyPost.Add("xToken", "");
  MyPost.Add("xCustom01", "");
  MyPost.Add("xCVV", "");
  MyPost.Add("xStreet", "");
  MyPost.Add("xZip", "");
  MyPost.Add("xBillFirstName", "");
  MyPost.Add("xBillMiddleName", "");
  MyPost.Add("xBillLastName", "");
  MyPost.Add("xBillCompany", "");
  MyPost.Add("xBillStreet", "");
  MyPost.Add("xBillStreet2", "");
  MyPost.Add("xBillCity", "");
  MyPost.Add("xBillZip", "");	
  MyPost.Add("xBillCountry", "");
  MyPost.Add("xBillPhone", "");
  MyPost.Add("xBillMobile", "");
  MyPost.Add("xShipFirstName", "");
  MyPost.Add("xShipMiddleName", "");
  MyPost.Add("xShipLastName", "");
  MyPost.Add("xShipCompany", ""); 
  MyPost.Add("xShipStreet", "");
  MyPost.Add("xShipStreet2", "");
  MyPost.Add("xShipCity", "");
  MyPost.Add("xShipState", "");
  MyPost.Add("xShipZip", "");
  MyPost.Add("xShipCountry", "");
  MyPost.Add("xShipPhone", "");
  MyPost.Add("xShipMobile", "");
  MyPost.Add("xRefNum", "");
  MyPost.Add("xAuthCode", "");
  MyPost.Add("xIP", "");
  MyPost.Add("xRouting", "");
  MyPost.Add("xCardpresent", "");
  MyPost.Add("xDUKPT", "");
  MyPost.Add("xTax", "");
  MyPost.Add("xTip", "");
  MyPost.Add("xInvoice", "");
  MyPost.Add("xPONum", "");
  MyPost.Add("xComments", "");
  MyPost.Add("xDescription", "");
  MyPost.Add("xEmail", "");
  MyPost.Add("xFax", "");
  MyPost.Add("xBillState", "");
  MyPost.Add("xAllowPartialAuth", "");
  MyPost.Add("xRxAmount", "");
  MyPost.Add("xDentalAmount", "");
  MyPost.Add("xVisionAmount", "");
  MyPost.Add("xTransitAmount", "");
  MyPost.Add("xCopayAmount", "");
  MyPost.Add("xClinicalAmount", "");
  MyPost.Add("xOrderID", "");
  MyPost.Add("xExistingCustomer", "");
  MyPost.Add("xAllowDuplicate", "");
  MyPost.Add("xMICR", "");
  MyPost.Add("xCheckNum", "");
  MyPost.Add("xCheckImageFront", "");
  MyPost.Add("xCheckImageBack", "");
  MyPost.Add("xVoucherApproval", "");
  MyPost.Add("xVoucherSerial", "");
  MyPost.Add("xGatewayRefNum", "");
  MyPost.Add("xGatewayResult", "");
  MyPost.Add("xGatewayError", "");
  MyPost.Add("xGatewayCVV", "");
  MyPost.Add("xGatewayAVS", "");
  MyPost.Add("xOrderItems", "");
  MyPost.Add("xOrderType", "");
  MyPost.Add("xCustomerComments", "");
  MyPost.Add("xShipMethod", "");
  MyPost.Add("xShipAmount", "");
  
  System.Net.WebClient MyClient = new System.Net.WebClient();
  string MyResponse = System.Text.UTF8Encoding.ASCII.GetString(MyClient.UploadValues("https://x1.cardknox.com/gateway", MyPost));
  // Response
  System.Collections.Specialized.NameValueCollection MyResponseData = System.Web.HttpUtility.ParseQueryString(MyResponse); // If necessary, add reference to System.Web
  string MyResult = "";
  if (MyResponseData.AllKeys.Contains("xResult"))
  MyResult = MyResponseData["xResult"];
  string MyStatus = "";
  if (MyResponseData.AllKeys.Contains("xStatus"))
    MyStatus = MyResponseData["xStatus"];
    string MyError = "";
  if (MyResponseData.AllKeys.Contains("xError"))
    MyError = MyResponseData["xError"];
    string MyRefNum = "";
  if (MyResponseData.AllKeys.Contains("xRefNum"))
    MyRefNum = MyResponseData["xRefNum"];

Java/Android

public void postData() 
  { 
    // Create a new HttpClient and Post Header Java/Android
    HttpClient httpclient = new DefaultHttpClient(); 
    HttpPost httppost = new HttpPost("https://x1.cardknox.com/gateway"); 
    try 
      { 
        // Add your data 
        List nameValuePairs = new ArrayList(9); 
        nameValuePairs.add(new BasicNameValuePair("xKey", "")); // Credential 
        nameValuePairs.add(new BasicNameValuePair("xVersion", "4.5.5")); // API Version
        nameValuePairs.add(new BasicNameValuePair("xSoftwareName", "")); // Name of your software
        nameValuePairs.add(new BasicNameValuePair("xSoftwareVersion", "")); // Version of your software 
        nameValuePairs.add(new BasicNameValuePair("xCommand", "cc:sale")); 
        nameValuePairs.add(new BasicNameValuePair("xCardNum", "")); 
        nameValuePairs.add(new BasicNameValuePair("xExp", "")); 
        nameValuePairs.add(new BasicNameValuePair("xName", "")); 
        nameValuePairs.add(new BasicNameValuePair("xAmount", ""));
        nameValuePairs.add(new BasicNameValuePair("xAccount", ""));
        nameValuePairs.add(new BasicNameValuePair("xMagstripe", "")); 
        nameValuePairs.add(new BasicNameValuePair("xToken", "")); 
        nameValuePairs.add(new BasicNameValuePair("xCustom01", "")); 
        nameValuePairs.add(new BasicNameValuePair("xCVV", "")); 
        nameValuePairs.add(new BasicNameValuePair("xStreet", "")); 
        nameValuePairs.add(new BasicNameValuePair("xZip", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillFirstName", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillMiddleName", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillLastName", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillCompany", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillStreet", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillStreet2", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillCity", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillZip", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillCountry", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillPhone", "")); 
        nameValuePairs.add(new BasicNameValuePair("xBillMobile", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipFirstName", "")); 
	nameValuePairs.add(new BasicNameValuePair("xShipMiddleName", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipLastName", "")); 
	nameValuePairs.add(new BasicNameValuePair("xShipCompany", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipStreet", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipStreet2", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipCity", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipState", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipZip", "")); 
	nameValuePairs.add(new BasicNameValuePair("xShipCountry", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipPhone", "")); 
        nameValuePairs.add(new BasicNameValuePair("xShipMobile", "")); 
        nameValuePairs.add(new BasicNameValuePair("xRefNum", "")); 
	nameValuePairs.add(new BasicNameValuePair("xAuthCode", "")); 
	nameValuePairs.add(new BasicNameValuePair("xIP", "")); 
	nameValuePairs.add(new BasicNameValuePair("xRouting", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCardpresent", "")); 
	nameValuePairs.add(new BasicNameValuePair("xDUKPT", "")); 
	nameValuePairs.add(new BasicNameValuePair("xTax", "")); 
	nameValuePairs.add(new BasicNameValuePair("xTip", "")); 
	nameValuePairs.add(new BasicNameValuePair("xInvoice", "")); 
	nameValuePairs.add(new BasicNameValuePair("xPONum", "")); 
	nameValuePairs.add(new BasicNameValuePair("xComments", "")); 
	nameValuePairs.add(new BasicNameValuePair("xDescription", "")); 
	nameValuePairs.add(new BasicNameValuePair("xEmail", "")); 
	nameValuePairs.add(new BasicNameValuePair("xFax", "")); 
	nameValuePairs.add(new BasicNameValuePair("xBillState", "")); 
	nameValuePairs.add(new BasicNameValuePair("xAllowPartialAuth", "")); 
	nameValuePairs.add(new BasicNameValuePair("xRxAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xDentalAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xVisionAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xTransitAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCopayAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xClinicalAmount", "")); 
	nameValuePairs.add(new BasicNameValuePair("xOrderID", "")); 
	nameValuePairs.add(new BasicNameValuePair("xExistingCustomer", "")); 
	nameValuePairs.add(new BasicNameValuePair("xAllowDuplicate", "")); 
	nameValuePairs.add(new BasicNameValuePair("xMICR", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCheckNum", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCheckImageFront", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCheckImageBack", "")); 
	nameValuePairs.add(new BasicNameValuePair("xVoucherApproval", "")); 
	nameValuePairs.add(new BasicNameValuePair("xVoucherSerial", "")); 
	nameValuePairs.add(new BasicNameValuePair("xGatewayRefNum", "")); 
	nameValuePairs.add(new BasicNameValuePair("xGatewayResult", "")); 
	nameValuePairs.add(new BasicNameValuePair("xGatewayError", "")); 
	nameValuePairs.add(new BasicNameValuePair("xGatewayCVV", "")); 
	nameValuePairs.add(new BasicNameValuePair("xGatewayAVS", "")); 
	nameValuePairs.add(new BasicNameValuePair("xOrderItems", "")); 
	nameValuePairs.add(new BasicNameValuePair("xOrderType", "")); 
	nameValuePairs.add(new BasicNameValuePair("xCustomerComments", "")); 
	nameValuePairs.add(new BasicNameValuePair("xShipMethod", "")); 
	nameValuePairs.add(new BasicNameValuePair("xShipAmount", "")); 
	httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs)); 
        // Execute HTTP Post Request 
        HttpResponse response = httpclient.execute(httppost); 
        System.out.println("response = " + EntityUtils.toString(response.getEntity())); 
      } 
    catch (ClientProtocolException e) 
      { 
        // TODO Auto-generated catch block 
      } 
    catch (IOException e) 
      { 
        // TODO Auto-generated catch block 
      } 
  }

Node.js

// Node.Js
var request = require("request");
var querystring = require('querystring');
request.post({
  url: 'https://x1.cardknox.com/gateway',
  form: {
    xKey: '', // Credential
    xVersion: '', // API Version
    xSoftwareName: '', // Name of your software
    xSoftwareVersion: '', // Version of your software
    xCommand: '',
    xCardNum: '',
    xExp: '',
    xAmount: '',
    xAccount:'',
    xMagstripe:'',
    xToken:'',
    xCustom01:'',
    xCVV:'',
    xStreet:'',
    xZip:'',
    xBillFirstName:'',
    xBillMiddleName:'',
    xBillLastName:'',
    xBillCompany:'',
    xBillStreet:'',
    xBillStreet2:'',
    xBillCity:'',
    xBillCountry:'',
    xBillPhone:'',
    xShipFirstName:'',
    xShipMiddleName:'',
    xShipCompany:'',
    xShipStreet:'',
    xShipStreet2:'',
    xShipCity:'',
    xShipState:'',
    xShipZip:'',
    xShipCountry:'',
    xShipPhone:'',
    xShipMobile:'',
    xRefNum:'',
    xAuthCode:'',
    xRouting:'',
    xCardpresent:'',
    xDUKPT:'',
    xTax:'',
    xTip:'',
    xInvoice:'',
    xPONum:'',
    xComments:'',
    xDescription:'',
    xEmail:'',
    xFax:'',
    xBillState:'',
    xAllowPartialAuth:'',
    xRxAmount:'',
    xDentalAmount:'',
    xVisionAmount:'',
    xTransitAmount:'',
    xCopayAmount:'',
    xClinicalAmount:'',
    xOrderID:'',
    xExistingCustomer:'',
    xAllowDuplicate:'',
    xMICR:'',
    xCheckNum:'',
    xCheckImageFront:'',
    xCheckImageBack:'',
    xVoucherApproval:'',
    xVoucherSerial:'',
    xGatewayRefNum:'',
    xGatewayResult:'',
    xGatewayError:'',
    xGatewayCVV:'',
    xGatewayAVS:'',
    xOrderItems:'',
    xOrderType:'',
    xCustomerComments:'',
    xShipMethod:'',
    xShipAmount:'',
  }
},
  function (error, response, body) {
    if (error) throw new Error(error);
    console.log(querystring.parse(body));
  });

PHP

<?php
	// Request 
	$data = array();
	$data["xKey"] = ""; // Credential
	$data["xVersion"] = ""; // API Version
	$data["xSoftwareName"] = ""; // Name of your software
	$data["xSoftwareVersion"] = ""; // Version of your software
	$data["xCommand"] = "";
	$data["xCardNum"] = "";
	$data["xExp"] = "";
	$data["xName"] = "";
	$data["xAmount"] = "";
	$data["xAccount"] = "";
	$data["xMagstripe"] = "";
	$data["xToken"] = "";
	$data["xCustom01"] = "";
	$data["xCVV"] = "";
	$data["xStreet"] = "";
	$data["xZip"] = "";
	$data["xBillFirstName"] = "";
	$data["xBillMiddleName"] = "";
	$data["xBillLastName"] = "";
	$data["xBillCompany"] = "";
	$data["xBillStreet"] = "";
	$data["xBillStreet2"] = "";
	$data["xBillState"] = "";
	$data["xBillCity"] = "";
	$data["xBillZip"] = "";
	$data["xBillCountry"] = "";
	$data["xBillPhone"] = "";
	$data["xBillMobile"] = "";
	$data["xShipFirstName"] = "";
	$data["xShipMiddleName"] = "";
	$data["xShipLastName"] = "";
	$data["xShipCompany"] = "";
	$data["xShipStreet"] = "";
	$data["xShipStreet2"] = "";
	$data["xShipCity"] = "";
	$data["xShipState"] = "";
	$data["xShipZip"] = "";
	$data["xShipCountry"] = "";
	$data["xShipPhone"] = "";
	$data["xShipMobile"] = "";
	$data["xRefNum"] = "";
	$data["xAuthCode"] = ""; 
	$data["xIP"] = ""; 
	$data["xRouting"] = ""; 
	$data["xCardpresent"] = "";	
	$data["xDUKPT"] = "";
	$data["xTax"] = "";  
	$data["xTip"] = "";
	$data["xInvoice"] = "";	
	$data["xPONum"] = "";	
	$data["xComments"] = "";
	$data["xDescription"] = "";  
	$data["xEmail"] = "";
	$data["xFax"] = "";	
	$data["xBillState"] = "";	
	$data["xAllowPartialAuth"] = "";
	$data["xRxAmount"] = "";  
	$data["xDentalAmount"] = "";
	$data["xVisionAmount"] = "";	
	$data["xTransitAmount"] = "";	
	$data["xCopayAmount"] = "";
	$data["xClinicalAmount"] = "";  
	$data["xOrderID"] = "";
	$data["xExistingCustomer"] = "";	
	$data["xAllowDuplicate"] = "";	
	$data["xMICR"] = "";  
	$data["xCheckNum"] = "";
	$data["xCheckImageFront"] = "";	
	$data["xCheckImageBack"] = "";	
	$data["xVoucherApproval"] = "";  
	$data["xVoucherSerial"] = "";
	$data["xGatewayRefNum"] = "";	
	$data["xGatewayResult"] = "";	
	$data["xGatewayError"] = "";  
	$data["xGatewayCVV"] = "";
	$data["xGatewayAVS"] = "";	
	$data["xOrderItems"] = "";	
	$data["xOrderType"] = "";  
	$data["xCustomerComments"] = "";
	$data["xShipMethod"] = "";	
	$data["xShipAmount"] = "";	
	
    function buildQuery($data)
      { 
        if(function_exists('http_build_query') && ini_get('arg_separator.output')=='&') return http_build_query($data); 
        $tmp = array(); 
        foreach($data as $key=>$val) $tmp[] = rawurlencode($key) . '=' . rawurlencode($val); 
        return implode('&', $tmp); 
      }
    $data = buildQuery($data); 
    $ch = curl_init("https://x1.cardknox.com/gateway"); 
    if(!is_resource($ch)) 
      { 
        echo "Error: Unable to initialize CURL ($ch)"; 
        exit; 
      } 
    curl_setopt($ch, CURLOPT_HEADER, 1); 
    curl_setopt($ch, CURLOPT_POST,1); 
    curl_setopt($ch, CURLOPT_TIMEOUT, 45); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    $raw_result = curl_exec($ch); 
    if(curl_error($ch) != "") 
      { 
        echo curl_error($ch); 
      } 
    elseif(!strlen($raw_result)) 
      {
        echo "Error reading from card processing gateway. Please contact the merchant to verify whether transaction has been processed."; 
        curl_close($ch); 
        exit; 
      } 
    elseif($raw_result == false)
      { 
        echo "Blank response from card processing gateway."; 
        curl_close($ch); 
        exit; 
      } 
    else 
      { 
        // SUCCESS 
        curl_close($ch); 
        // result will be on the last line of the return 
        $tmp = explode("\n",$raw_result); 
        $result_string = $tmp[count($tmp)-1]; 
        parse_str($result_string, $result_array);  
        print_r($result_array); 
      }
	  ?>

Python 2

# Python 2
import urllib2, urllib
from urlparse import parse_qs
data = {}
data["xKey"] = "" # Credential
data["xVersion"] = "" # API Version
data["xSoftwareName"] = "" # Name of your software
data["xSoftwareVersion"] = "" # Version of your software
data["xCommand"] = ""
data["xCardNum"] = ""
data["xExp"] = ""
data["xName"] = ""
data["xAmount"] = ""
data["xAccount"] = ""
data["xMagstripe"] = ""
data["xToken"] = ""
data["xCustom01"] = ""
data["xCVV"] = ""
data["xStreet"] = ""
data["xZip"] = ""
data["xBillFirstName"] = ""
data["xBillMiddleName"] = ""
data["xBillLastName"] = ""
data["xBillCompany"] = ""
data["xBillStreet"] = ""
data["xBillStreet2"] = ""
data["xBillCity"] = ""
data["xBillCountry"] = ""
data["xBillPhone"] = ""
data["xBillMobile"] = ""
data["xShipFirstName"] = ""
data["xShipMiddleName"] = ""
data["xShipCompany"] = ""
data["xShipStreet"] = ""
data["xShipStreet2"] = ""
data["xShipCity"] = ""
data["xShipState"] = ""
data["xShipZip"] = ""
data["xShipCountry"] = ""
data["xShipPhone"] = ""
data["xShipMobile"] = ""
data["xRefNum"] = ""
data["xAuthCode"] = ""
data["xIP"] = ""
data["xRouting"] = ""
data["xCardpresent"] = ""
data["xDUKPT"] = ""
data["xTax"] = ""
data["xTip"] = ""
data["xInvoice"] = ""
data["xPONum"] = ""
data["xComments"] = ""
data["xDescription"] = ""
data["xEmail"] = ""
data["xFax"] = ""
data["xBillState"] = ""
data["xAllowPartialAuth"] = ""
data["xRxAmount"] = ""
data["xDentalAmount"] = ""
data["xVisionAmount"] = ""
data["xTransitAmount"] = ""
data["xCopayAmount"] = ""
data["xClinicalAmount"] = ""
data["xOrderID"] = ""
data["xExistingCustomer"] = ""
data["xAllowDuplicate"] = ""
data["xMICR"] = ""
data["xCheckNum"] = ""
data["xCheckImageFront"] = ""
data["xCheckImageBack"] = ""
data["xVoucherApproval"] = ""
data["xVoucherSerial"] = ""
data["xGatewayRefNum"] = ""
data["xGatewayResult"] = ""
data["xGatewayError"] = ""
data["xGatewayCVV"] = ""
data["xGatewayAVS"] = ""
data["xOrderItems"] = ""
data["xOrderType"] = ""
data["xCustomerComments"] = ""
data["xShipMethod"] = ""
data["xShipAmount"] = ""

request = urllib2.Request("https://x1.cardknox.com/gateway", urllib.urlencode(data).encode('utf-8'))
rawResponse = urllib2.urlopen(request).read().decode('utf-8')
response = parse_qs(rawResponse, keep_blank_values=True)
print("xRefNum: " + "".join(response.get("xRefNum","")));
print("xResult: " + "".join(response.get("xResult","")));
print("xStatus: " + "".join(response.get("xStatus","")));
print("xError:  " + "".join(response.get("xError","")));

Python 3

# Python 3
import urllib.request
from urllib.parse import parse_qs
data = {}
data["xKey"] = "" # Credential
data["xVersion"] = "" # API Version
data["xSoftwareName"] = "" # Name of your software
data["xSoftwareVersion"] = "" # Version of your software
data["xCommand"] = ""
data["xCardNum"] = ""
data["xExp"] = ""
data["xName"] = ""
data["xAmount"] = ""
data["xAccount"] = ""
data["xMagstripe"] = ""
data["xToken"] = ""
data["xCustom01"] = ""
data["xCVV"] = ""
data["xStreet"] = ""
data["xZip"] = ""
data["xBillFirstName"] = ""
data["xBillMiddleName"] = ""
data["xBillLastName"] = ""
data["xBillCompany"] = ""
data["xBillStreet"] = ""
data["xBillStreet2"] = ""
data["xBillCity"] = ""
data["xBillCountry"] = ""
data["xBillPhone"] = ""
data["xBillMobile"] = ""
data["xShipFirstName"] = ""
data["xShipMiddleName"] = ""
data["xShipCompany"] = ""
data["xShipStreet"] = ""
data["xShipStreet2"] = ""
data["xShipCity"] = ""
data["xShipState"] = ""
data["xShipZip"] = ""
data["xShipCountry"] = ""
data["xShipPhone"] = ""
data["xShipMobile"] = ""
data["xRefNum"] = ""
data["xAuthCode"] = ""
data["xIP"] = ""
data["xRouting"] = ""
data["xCardpresent"] = ""
data["xDUKPT"] = ""
data["xTax"] = ""
data["xTip"] = ""
data["xInvoice"] = ""
data["xPONum"] = ""
data["xComments"] = ""
data["xDescription"] = ""
data["xEmail"] = ""
data["xFax"] = ""
data["xBillState"] = ""
data["xAllowPartialAuth"] = ""
data["xRxAmount"] = ""
data["xDentalAmount"] = ""
data["xVisionAmount"] = ""
data["xTransitAmount"] = ""
data["xCopayAmount"] = ""
data["xClinicalAmount"] = ""
data["xOrderID"] = ""
data["xExistingCustomer"] = ""
data["xAllowDuplicate"] = ""
data["xMICR"] = ""
data["xCheckNum"] = ""
data["xCheckImageFront"] = ""
data["xCheckImageBack"] = ""
data["xVoucherApproval"] = ""
data["xVoucherSerial"] = ""
data["xGatewayRefNum"] = ""
data["xGatewayResult"] = ""
data["xGatewayError"] = ""
data["xGatewayCVV"] = ""
data["xGatewayAVS"] = ""
data["xOrderItems"] = ""
data["xOrderType"] = ""
data["xCustomerComments"] = ""
data["xShipMethod"] = ""
data["xShipAmount"] = ""
request = urllib.request.Request("https://x1.cardknox.com/gateway", urllib.parse.urlencode(data).encode('utf-8'))
rawResponse = urllib.request.urlopen(request).read().decode('utf-8')
response = parse_qs(rawResponse, keep_blank_values=True)
print("xRefNum: " + "".join(response.get("xRefNum","")));
print("xResult: " + "".join(response.get("xResult","")));
print("xStatus: " + "".join(response.get("xStatus","")));
print("xError:  " + "".join(response.get("xError","")));

VB.NET

  'Request
  Dim MyPost As New System.Collections.Specialized.NameValueCollection 
  MyPost.Add("xKey", "") ‘Credential
  MyPost.Add("xVersion", "4.5.5") ‘API Version
  MyPost.Add("xSoftwareName", My.Application.Info.Title) ‘Name of your software
  MyPost.Add("xSoftwareVersion", My.Application.Info.Version.ToString) ‘Version of your software 
  MyPost.Add("xCommand", "cc:sale")
  MyPost.Add("xCardNum", "")
  MyPost.Add("xExp", "")
  MyPost.Add("xName", "")
  MyPost.Add("xAmount", "")
  MyPost.Add("xAccount", "")
  MyPost.Add("xMagstripe", "")
  MyPost.Add("xToken", "")
  MyPost.Add("xCustom01", "")
  MyPost.Add("xCVV", "")
  MyPost.Add("xStreet", "")
  MyPost.Add("xZip", "")
  MyPost.Add("xBillFirstName", "")
  MyPost.Add("xBillMiddleName", "")
  MyPost.Add("xBillLastName", "")
  MyPost.Add("xBillCompany", "")
  MyPost.Add("xBillStreet", "")
  MyPost.Add("xBillStreet2", "")
  MyPost.Add("xBillCity", "")
  MyPost.Add("xBillZip", "")
  MyPost.Add("xBillCountry", "")
  MyPost.Add("xBillPhone", "")
  MyPost.Add("xBillMobile", "")
  MyPost.Add("xShipFirstName", "")
  MyPost.Add("xShipMiddleName", "")
  MyPost.Add("xShipLastName", "")
  MyPost.Add("xShipCompany", "");
  MyPost.Add("xShipStreet", "")
  MyPost.Add("xShipStreet2", "")
  MyPost.Add("xShipCity", "")
  MyPost.Add("xShipState", "")
  MyPost.Add("xShipZip", "")
  MyPost.Add("xShipCountry", "")
  MyPost.Add("xShipPhone", "")
  MyPost.Add("xShipMobile", "")
  MyPost.Add("xRefNum", "")
  MyPost.Add("xAuthCode", "")
  MyPost.Add("xIP", "")
  MyPost.Add("xRouting", "")
  MyPost.Add("xCardpresent", "")
  MyPost.Add("xDUKPT", "")
  MyPost.Add("xTax", "")
  MyPost.Add("xTip", "")
  MyPost.Add("xInvoice", "")
  MyPost.Add("xPONum", "")
  MyPost.Add("xComments", "")
  MyPost.Add("xDescription", "")
  MyPost.Add("xEmail", "")
  MyPost.Add("xFax", "")
  MyPost.Add("xBillState", "")
  MyPost.Add("xAllowPartialAuth", "")
  MyPost.Add("xRxAmount", "")
  MyPost.Add("xDentalAmount", "")
  MyPost.Add("xVisionAmount", "")
  MyPost.Add("xTransitAmount", "")
  MyPost.Add("xCopayAmount", "")
  MyPost.Add("xClinicalAmount", "")
  MyPost.Add("xOrderID", "")
  MyPost.Add("xExistingCustomer", "")
  MyPost.Add("xAllowDuplicate", "")
  MyPost.Add("xMICR", "")
  MyPost.Add("xCheckNum", "")
  MyPost.Add("xCheckImageFront", "")
  MyPost.Add("xCheckImageBack", "")
  MyPost.Add("xVoucherApproval", "")
  MyPost.Add("xVoucherSerial", "")
  MyPost.Add("xGatewayRefNum", "")
  MyPost.Add("xGatewayResult", "")
  MyPost.Add("xGatewayError", "")
  MyPost.Add("xGatewayCVV", "")
  MyPost.Add("xGatewayAVS", "")     
  MyPost.Add("xOrderItems", "")
  MyPost.Add("xOrderType", "")
  MyPost.Add("xCustomerComments", "")
  MyPost.Add("xShipMethod", "")
  MyPost.Add("xShipAmount", "")    
  Dim MyClient As New Net.WebClient
  Dim MyResponse As String = System.Text.UTF8Encoding.ASCII.GetString(MyClient.UploadValues("https://x1.cardknox.com/gateway", MyPost))
  'Response
  Dim MyResponseData As System.Collections.Specialized.NameValueCollection = System.Web.HttpUtility.ParseQueryString(MyResponse) 'If necessary, add reference to System.Web
  Dim MyResult As String = ""
  If MyResponseData.AllKeys.Contains("xResult") Then MyResult = MyResponseData("xResult")
  Dim MyStatus As String = ""
  If MyResponseData.AllKeys.Contains("xStatus") Then MyStatus = MyResponseData("xStatus")
  Dim MyError As String = ""
  If MyResponseData.AllKeys.Contains("xError") Then MyError = MyResponseData("xError")
  Dim MyRefNum As String = ""
  If MyResponseData.AllKeys.Contains("xRefNum") Then MyRefNum = MyResponseData("xRefNum")

Last updated