Create a Config object and set API configuration parameters

Note that ipcApiUrl is different for sandbox and production environment

You can set RSA keys for request signatures by setting key content using loadPrivateKeyFromString and loadPublicKeyFromString or by setting file path using loadPrivateKeyFromFile and loadPublicKeyFromFile

For more information please refer to myPOS Checkout API Documentation

import java.net.MalformedURLException; 
import java.net.URL; 

import com.mypos.myposcheckout.ipc.Config; 
import com.mypos.myposcheckout.ipc.IPCException; 

// ... 

Config cnf = new Config(); 

URL ipcApiUrl = null; 
try { 
    ipcApiUrl = new URL("https://mypos.com/vmp/checkout-test/"); 
} catch (MalformedURLException ex) { 
    // Handle the malformed URL exception 
} 

cnf.setIpcUrl(ipcApiUrl); 
cnf.setLang("en"); 
cnf.loadPrivateKeyFromFile("path_to_directory/storePrivateKey.pem"); // Replace `path_to_directory` with the actual file path 
cnf.loadPublicKeyFromFile("path_to_directory/apiPublicKey.pem"); // Replace `path_to_directory` with the actual file path 
cnf.setKeyIndex(1); 
cnf.setSid("000000000000010"); 
cnf.setVersion("1.4"); 
cnf.setWalletNumber("61938166610");


Create a TransactionStatus object and set the required parameters

import com.mypos.myposcheckout.ipc.enumerable.CommunicationFormat; 
import com.mypos.myposcheckout.ipc.request.TransactionStatus; 

// ... 

TransactionStatus ipcStatus = new TransactionStatus(cnf); 
ipcStatus.setOrderId("123456"); 
ipcStatus.setOutputFormat(CommunicationFormat.XML);


Process the request

import com.mypos.myposcheckout.ipc.IPCException; 
import com.mypos.myposcheckout.ipc.response.ComplexResponse; 

// ... 

ComplexResponse ipcResponse = ipcStatus.process(); 
ipcResponse.processApiResponse();


Check response status and use the received data
You may get response data as a Map<String, String>/ResponseNode<String, String> using getBasicData()/getComplexData() method or
in original communication format using getRawData()

import com.mypos.myposcheckout.ipc.IPCException; 

// ... 

switch (ipcResponse.getStatusCode()) { 
    case SUCCESS: 
        // Display the returned data in the site interface 
        // ipcResponse.getComplexData().getChild("OrderStatus"); 
        break; 

    case INVALID_PARAMS: 
        // Order not found or set parameters are invalid 
        break; 
}


Note:
It is a good practice to use try-catch statements to catch "IPCException" exceptions

import com.mypos.myposcheckout.ipc.IPCException; 
import com.mypos.myposcheckout.ipc.enumerable.CommunicationFormat; 
import com.mypos.myposcheckout.ipc.request.TransactionStatus; 
import com.mypos.myposcheckout.ipc.response.ComplexResponse; 

// ... 

try { 
    TransactionStatus ipcStatus = new TransactionStatus(cnf); 
    ipcStatus.setOrderId("123456"); 
    ipcStatus.setOutputFormat(CommunicationFormat.XML); 
    ComplexResponse ipcResponse = ipcStatus.process(); 
    ipcResponse.processApiResponse(); 


    switch (ipcResponse.getStatusCode()) { 
        case SUCCESS: 
            // Display the returned data in the site interface 
            // ipcResponse.getComplexData().getChild("OrderStatus"); 
            break; 

        case INVALID_PARAMS: 
            // Order not found or set parameters are invalid 
            break; 
    } 
} catch (IPCException ex) { 
    // Handle the exception 
}