Table of Contents |
---|
...
The very step to avoid difficult integration times: unit test the external communication with ACE.
View file | ||
---|---|---|
|
Code Block | ||||
---|---|---|---|---|
| ||||
//--------------------------------------------------------- // Main //-- 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 // //--------------------------------------------------------- int// main(int argc, char** argv) { // Communication int port, length; char address[50]=""; // Get Communication parameters from ini file 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); assert(comtcpOpen( // 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); // TutorialTrace into ACE aceOut("Training Session - BEGIN\n"); aceOut("Hello World!\n"); aceOut("Training Session - END\n"); return 0; } |
Tutorial #2: initialize language and payment context
...
Code Block | ||||
---|---|---|---|---|
| ||||
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
View file | ||
---|---|---|
|
Code Block | ||
---|---|---|
| ||
// NAME....... Tutorial #2
// PURPOSE.... This code presents how to intialize language and payment contexts
//
// 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]="";
// Trace for debugging
char tmp[100]="";
// Payment Contexts
tPaymentContext* pay = &gPaymentCtx;
tOutComeParameter* out = &gOutcome;
// System's language
tByte availableLanguage=0;
tByte currentLanguage = 0;
// 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 up ACE's options
aceSetUIDisplay(bTRUE);
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);
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); // Assuming that there are at least 2 languages
aceOut("Training Session - END\n");
return 0;
} |
Tutorial #3: manage ACE requests
View file | ||
---|---|---|
|
Code Block | ||
---|---|---|
| ||
// NAME....... Tutorial #3 // PURPOSE.... This code presents how to intialize language and payment contexts // // 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 // //--------------------------------------------------------- // CreateFile //--------------------------------------------------------- void createFile(char* fileName, tByte* buffer, tWord len) { tFileHandler ifp = 0; if (fileName) { gpiFileDelete(fileName); if(gpiFileOpen(fileName,&ifp,CREATE|BINARY)==filNO_ERROR) { gpiFileWrite(ifp,buffer,len); gpiFileClose(ifp); } } } //--------------------------------------------------------- // Main //-------------- Main //------------------------------------------- // Main function: // - Initialize the platform // - Wait for payment trigger // - Initialize the data model // - Perform a payment // // Visibility: Public // Hypothesis: -- // Reference: -- // ---------------- int main(int argc, char** argv) { // Communication int port, length; char address[50]=""; // Trace for debugging char tmp[100]=""; // Payment Communicationcontexts int port, lengthtPaymentContext* pay = &gPaymentCtx; char address[50]=""; tOutComeParameter* out = &gOutcome; // System's language tByte availableLanguage=0, 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); // 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 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); 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; tByte *buffer = NULL; tDataFileSize size=0; tWord len=0; char c, workingString[1000]=""; gpiGetTotalRAM(&buffer,&size); if (!buffer) return 0; len=0; gpiMemSet(buffer,0x00,size); gpiMemSet(workingString,0x00,sizeof(workingString)); // Wait for inbound sale request do { gpiDisplayMessageByID(gpi_true,currentLanguage,WELCOME); c = aceGetRequest(buffer,&len); if (INIT == c) { sprintf(workingString,"%sTERMINAL","./AGNOS/"); createFile(workingString,buffer+1,len-1); gpiDisplayMessage(gpi_true,"TERMINAL Updated" ); } else if (CONFIG == c) { sprintf(workingString,"%sPROCESSING","./AGNOS/"); createFile(workingString,buffer+1,len-1); gpiDisplayMessage(gpi_true,"PROCESSING Updated" ); } else if ( CL_ENTRY_POINT == c) { sprintf(workingString,"%sENTRY_POINT","./AGNOS/"); createFile(workingString,buffer+1,len-1); gpiDisplayMessage(gpi_true,"ENTRY_POINT Updated" ); } else if ((CAPK == c) && (len >= 21)) { sprintf(workingString,"%sCAKeys","./AGNOS/"); createFile(workingString,buffer+1,len-1-20); gpiDisplayMessage(gpi_true,"CAPK Updated" ); } aceSendResponse((unsigned char*)"\x30\x30",2); } while (c != PAYMENT); gpiDisplayMessageByID(gpi_true,currentLanguage+1,THANKS); aceOut("Training Session - END\n"); return 0; } |
Tutorial #4: manage a payment request
...