Using PICommander

Using PICommander

Category:Sample codes

Introduction

The following is the Know-How you need to build apps with credit cards processing capabilities (including chip and contactless cards) for any platform (iOS, Android, Windows) for a PAX credit card terminal.

Background

PAX pinpad terminals are PCI compliant devices and certified by many credit card processors to process chip cards, Contacless(ApplePay,SmasungPay, etc.) and magnetic stripe credit cards with semi-integration techniques. To take advantage of semi-integrated devices, and to avoid using a gateway, I developed PI Commander.

PICommander uses PIConnect (See this article), which is an agile and very lean dll. PI Commander maintains a HTTP persistent connection (keep-alive) to provide HTTP GET methods for processing credit and debit cards on your PAX EMV-Enabled device.

Using the code

PICommander by Payment Innovators

Start by downloading a free copy of PICommander from here.

To setup your PICommander HTTP server, enter the IP address of the PC, where PICommand is installed. Enter a port number and set the rest of fields as shown in the figure.

Click on the PICommander button to start your server. Now open a browser and navigate to the  address: e.g.

http://10.0.0.2:7001

At this point you should see the PICommander home page, which has details of commands, parameters and transaction types:

Your local HTTP server is now up and running and it is ready to launch your commands:

CreditSale() Transaction:

This is one of the most commonly performed transaction type. This transaction charges a dollar amount to the card:

http://10.0.0.2:7001/method=CreditSale&amount=10.25&ticketid=12&sn=5313125

Required parameters are method, amount to be charged, ticket (or invoice) number and finally serial number of the PAX device. Send the URL and watch your PAX terminal to fire up. Tap or swipe

a credit card. The following is the JSON response from PI Commander:

{
   "TransactionID":"3",
   "TicketID":"12",
   "TransType":"SALE",
   "Timestamp":"20171221195459",
   "ResponseMsg":"OK",
   "ResponseCode":"000000",
   "ExtraBalance":null,
   "RawResponse":null,
   "RefNum":"88888888",
   "CardHolder":"DOE/JOHN ",
   "HostResponse":"DEMO APPROVED",
   "HostCode":"0",
   "CvResponse":null,
   "CardType":"VISA",
   "AccountNum":"1443",
   "AvsResponse":null,
   "ApprovedAmount":10.25,
   "AmountDue":0.0,
   "TipAmount":0.0,
   "AuthCode":"000000",
   "CVM":null,
   "CID":"40",
   "ARC":"00",
   "IAD":"06010A0360AC02",
   "APPPN":null,
   "APPLab":"VISA CREDIT",
   "ATC":"0061",
   "TSI":"E800",
   "AID":"A0000000031010",
   "TVR":"0080008000",
   "TC":"7B940AFFF1D7D717",
   "CardBin":"406095",
   "SerialNo":" 5313125",
   "EntryMode":"Chip",
   "TransactionResult":true,
   "UniqueId":"5313125-3",
   "Token":null,
   "ExpirationDate":"0321"
}

C# Implemention

The following code demonstrates how you can perform a CreditSale() transaction in C#. Keep in mind that PI Commander is running in the background and maintains a HTTP persistent connection (keep-alive) :

 private async void CreditSale()
{
	string request;
	string result;
	request = "http://10.0.0.2:7001/method=creditsale&amount=10.25&ticketid=12&sn=53132532";
	using (HttpClient client = new HttpClient())
	using (HttpResponseMessage response = await client.GetAsync(request))
	using (HttpContent content = response.Content)
		{
			result = await content.ReadAsStringAsync();
		}
	Console.Write(result);
}

By calling this method, my PAX S300 terminal was fired up and it asked for the credit card. I inserted the chip card and the transaction was approved. The following is the JSON Response:

{
   "TransactionID":"4",
   "TicketID":"12",
   "TransType":"SALE",
   "Timestamp":"20171222124731",
   "ResponseMsg":"OK",
   "ResponseCode":"000000",
   "ExtraBalance":null,
   "RawResponse":null,
   "RefNum":"88888888",
   "CardHolder":"JOHN DOE",
   "HostResponse":"DEMO APPROVED",
   "HostCode":"0",
   "CvResponse":null,
   "CardType":"VISA",
   "AccountNum":"5588",
   "AvsResponse":null,
   "ApprovedAmount":10.25,
   "AmountDue":0.0,
   "TipAmount":0.0,
   "AuthCode":"000000",
   "CVM":null,
   "CID":"40",
   "ARC":"00",
   "IAD":"06010A03602400",
   "APPPN":null,
   "APPLab":"VISA DEBIT",
   "ATC":"00FC",
   "TSI":"6800",
   "AID":"A0000000031010",
   "TVR":"8080008000",
   "TC":"69C76F6EAC915930",
   "CardBin":"480209",
   "SerialNo":"53132532",
   "EntryMode":"Chip",
   "TransactionResult":true,
   "UniqueId":"53132532 -4",
   "Token":null,
   "ExpirationDate":"0320"
}

You can build the same process in any programming language with support for HTTP Request. Here is the same call in php for a web app:

$data=file_get_contents("http://10.0.0.2:7001/method=CreditSale&amount=10.25&ticketid=12&sn=5313125")	;
print_r($data)

As long as you can run PI Commander on a Windows machine on your network, other devices of any platform (iOS, Android) on the same network will be able to make transaction calls and produce the results.

Points of Interest

The need for processing chip and contactless credit cards on semi-integrated devices are on the rise. Two major factor in any viable solution are :

  1. Platform independence, or Platform Agnostic
  2. Credit Card processor independence, or Processor Agnostic

PI Commander brings you both both advantages . PI Commander gives you the freedom to focus on the development without any string attached and as a result you can let your customers to choose their own processor.