Get transaction status for previously executed payment

require_once './IPC/Loader.php';


Create Config object and set API configuration params

Note that IpcURL is different for sandbox and production environment

You can set RSA keys for request signatures by setting key content using setPrivateKey and setAPIPublicKey or by setting file path using setPrivateKeyPath and setAPIPublicKeyPath

$cnf = new \Mypos\IPC\Config(); 
$cnf->setIpcURL('https://mypos.eu/vmp/checkout-test/'); 
$cnf->setLang('en'); 
$cnf->setPrivateKeyPath(dirname(__FILE__) . '/keys/store_private_key.pem'); 
$cnf->setAPIPublicKeyPath(dirname(__FILE__) . '/keys/api_public_key.pem'); 
$cnf->setKeyIndex(1); 
$cnf->setSid('000000000000010'); 
$cnf->setVersion('1.0'); 
$cnf->setWallet('61938166610');


Create GetPaymentStatus object and set required params

$ipcStatus = new Mypos\IPC\GetPaymentStatus($cnf); 
$ipcStatus->setOrderID('1440'); 
$ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);


Process request

$result = $ipcStatus->process();


Check response status and use received data
You may get response data as an array using getData() method or
in original communication format using getDataRaw()

switch($result->getStatus()){ 
    case \Mypos\IPC\Defines::STATUS_SUCCESS: 
        //Display returned data in the site interfase. 
        //Loop and display in table or just print_r response 
        print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus')); 
        break; 
    case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS: 
        //Order not found or set params are invalid. 
        //Show error. 
        break; 
}


Note:
It is good practice to use try-catch statement to catch "IPC_Exception" exceptions

try{ 
    $ipcStatus = new \Mypos\IPC\GetPaymentStatus($cnf); 
    $ipcStatus->setOrderID('1440'); 
    $ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON); 
    $result = $ipcStatus->process(); 

    switch($result->getStatus()){ 
        case \Mypos\IPC\Defines::STATUS_SUCCESS: 
            print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus')); 
            break; 
        case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS: 
            echo 'Not found!'; 
            break; 
    } 
}catch(\Mypos\IPC_Exception $ex){ 
    //Display exception message 
    echo $ex->getMessage(); 
}