Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Table of Contents

...

The very step to avoid difficult integration times: unit test the external communication with ACE.

View file
nametutorial#1

Code Block
breakoutModewide
languagec
// NAME.......  Tutorial #1
// PURPOSE....	This code presents how to connect onto ACE and to use aceOut
//
//	Hypothesis and optimizations:
//		Communication between ACE and acceptance device is IP

//
// PROJECT....  Wiki
// REFERENCES.	--
//
// Copyright ©2005-2020 - 9164-4187 QUEBEC INC (“AMADIS”), All Rights Reserved
//
//---------------------------------------------------------
//            Main
//---------------------------------------------------------
int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";

	// Get Communication parameters from ini file
	// These paramerters maybe wired inside the code for training purposes
	xgpiIniSetFilename("agnos.ini");
	xgpiIniGetString("COM", "Address", 50, address, &length);
	xgpiIniGetNumeric("COM", "Port", &port);

	// Initialize ACE
	// Initialize generic communication interface
	assert(tcpInit(0) == TCP_NO_ERROR);
	// Create server and client
	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);
	// Set ACE with server and client 
	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);
	
	// Initialize running mode
	aceSetMode(pmSDK);

	// Set ACE option
	aceSetUIDisplay(bTRUE);

	// Trace into ACE
	aceOut("Training Session - BEGIN\n");
	aceOut("Hello World!\n");
	aceOut("Training Session - END\n");

	return 0;
}

...

For this tutorial, code examples rely on previous tutorial. Let’s focus on how to manage a transaction payment transaction ans set tPaymentContext accordingly. A comprehensive example is provided below.

...

Code Block
breakoutModewide
languagec
// NAME.......  Tutorial #3#4
// PURPOSE....	This code presents how to intializeprocess language anda payment contextsrequest
//
//	Hypothesis and optimizations:
//		Communication between ACE and acceptance device is IP

//
// PROJECT....  Wiki
// REFERENCES.	--
//
// Copyright ©2005-2020 - 9164-4187 QUEBEC INC (“AMADIS”), All Rights Reserved
//

// See comprehensive example to get all functions used by this tutorial

//---------------------------------------------------------
//            Main
//---------------------------------------------------------
int main(int argc, char** argv)
{
 	// See previous examples to get a PAYMENT request from ACE

	// Display contexts BEFORE processing ACE request
	outPaymentContext(pay);
	outOutcomeParameter(out);

	// Process ACE request for a payment. Set pay as per TRD contents
	processRequest(buffer+1,len-1,pay);

	// Display contexts AFTER processing ACE request
	outPaymentContext(pay);
	outOutcomeParameter(out);

	// Acknowledge ACE
	aceSendResponse((unsigned char*)"\x30\x30",2);


	gpiDisplayMessageByID(gpi_true,currentLanguage,THANKS);

	aceOut("Training Session - END\n");

	return 0;
}

Tutorial #5: perform a contactless transaction

View file
nametutorial#5

Code Block
breakoutModewide
// NAME.......  Tutorial #5
// PURPOSE....	This code presents how to excute a contactless payment transaction
//
//	Hypothesis and optimizations:
//		Communication between ACE and acceptance device is IP

//
// PROJECT....  Wiki
// REFERENCES.	--
//
// Copyright ©2005-2020 - 9164-4187 QUEBEC INC (“AMADIS”), All Rights Reserved
//

// See comprehensive example to get all functions used by this tutorial

//---------------------------------------------------------
//            Main
//---------------------------------------------------------
int main(int argc, char** argv)
{	
    // See previous examples to get a PAYMENT request from ACE

	processRequest(buffer+1,len-1,pay);

	char* parameters;
	tStartingPoint sp = spSTART_A; // To initiate contactless transaction at preprocessing step
	char line1[100]="",line2[100]="";
	char *string=NULL;



	// Initialize GPI
	// This is platform dependent. On Kizis AVT, this set PCSC readers' name from agnos.ini
	gpiMain(0,&parameters);

	// Load available kernels
	enpConnectPaymentServices("./AGNOS/");
	
	// Set contactless configurations
	dtmInitializeFromFile("./AGNOS/",NULL,NULL,NULL,NULL,NULL,pay->mTransactionType,bFALSE);

	// Initialization entry point
	enpInitialize("","",bTRUE,bFALSE,bFALSE,pay);

	gpiSetTechnoToDetect(TECHNO_CL_TYPE_EMV); // Right before polling, need to tell which techno to poll on

	sprintf(line1,"PAY");
	gpiGetString(pmwGetLanguage(pay),PRESENT_CARD,&string);
	if(pay->mAmount)
	{
		sprintf(line2,"AMOUNT: %.2f",(*pay->mAmount)/100.0);
	}
	else
	{
		sprintf(line2,"--");
	}

	gpiSetPollingMessage(line1,line2,NULL);

	outPaymentContext(pay); // Trace payment request
	enpExecutePaymentTransaction(sp,pay,out); // Call main entry point primitive to trigger a transaction
	outOutcomeParameter(out); // Trace outcome

	// Acknowledge ACE and sends several tags for receipt printing...
	completePayment(pay,out,((pay->mPOSEntryMode == EMV_CL_MODE) || (pay->mPOSEntryMode == MAG_CL_MODE)));

	// UI stuff..
	gpiClearScreen();
	gpiDisplayMessageByID(gpi_true,currentLanguage+1,THANKS);

	gpiSwitchLED(LED_1,gpi_false,0);
	gpiSwitchLED(LED_2,gpi_false,0);
	gpiSwitchLED(LED_3,gpi_false,0);
	gpiSwitchLED(LED_4,gpi_false,0);

	aceOut("Training Session - END\n");

	return 0;
}

Tutorial #6: add some logs to analyze the transaction