Amadis

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 23 Next »

That series of tutorials use Kizs as the squeleton to build from scratch a basic payment application.

Use ACE to trace and monitor behavior (open ‘'Console Log’').

Tutorial #1: set communication and traces using ACE

int main(int argc, char** argv)
{
	// Communication
	int port, length;
	char address[50]="";

	// Get communication parameters from ini file
	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);

	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);

	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Initialize running mode
	aceSetMode(pmSDK);
	
	// Set ACE option
	aceSetUIDisplay(bTRUE);

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

	return 0;
}

Tutorial #2: initialize language and payment context

int main(int argc, char** argv)
{
	// Trace for debugging
	char tmp[100]="";

	// Communication
	int port, length;
	char address[50]="";

	// System's language
	tByte availableLanguage=0;
	tByte currentLanguage = 0;

	tPaymentContext* pay = &gPaymentCtx;
	tOutComeParameter* out = &gOutcome;

	// Get Communication parameters from ini file
	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);

	assert(comtcpOpen(&gACEServerCOMTCP, TCP_SERVER, 0, port) == COM_NO_ERROR);
	assert(comtcpOpen(&gACEClientCOMTCP, TCP_CLIENT, address, 1979) == COM_NO_ERROR);

	aceInitializeCommunication(&gACEServerCOMTCP.com,&gACEClientCOMTCP.com);

	// Initialize running mode
	aceSetMode(pmSDK);

	// Set up ACE's options
	aceSetUIDisplay(bTRUE);

	// Tutorial
	aceOut("Training Session - BEGIN\n");
	aceOut("Hello World!\n");// set default language (merchant language indeed)

	// Initialize lines, columns and set string table from lang.ini
	gpiInitializeDisplay("lang.ini",&availableLanguage,NULL); // Assuming that lan.ini supports at least 2 languages
	sprintf(tmp,"Available lang.: %i\n",availableLanguage);
	aceOut(tmp);

	// Initialize payment context and outcome
	pmwInitializePaymentContext(pay);
	pmwSetLanguage(pay,currentLanguage); // Don't forget to propagate language in payment context for further processing
	currentLanguage = pmwGetLanguage(pay);
	pmwInitializeOutComeParameter(out);

	// Important to perform these initializations after pmwInitializePaymentContext
	pay->mAmount = &gAmount;
	pay->mCashBack = &gCashBack;
	pay->mTransactionType = (tTransactionType)0x00;
	gAmount = gCashBack = 0;

	gpiDisplayMessageByID(gpi_true,currentLanguage,WELCOME);
	gpiDisplayMessageByID(gpi_true,currentLanguage+1,THANKS); // Using the next language

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

	return 0;
}

Tutorial #3: manage ACE requests

  • No labels