SAMPLE C# CODE
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 |
//Request System.Collections.Specialized.NameValueCollection MyPost = new System.Collections.Specialized.NameValueCollection(); MyPost.Add("xKey", ""); //Credential MyPost.Add("xVersion", "4.5.5"); 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"]; |