Upon HTTP request, the party should respond with header HTTP 200 OK with the following body content: “OK”. Every other response will be treated as a communication error, call error, server error or system malfunctions.



Include SDK loader
This will autoload necessary library files and classes

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 a file path using setPrivateKeyPath and setAPIPublicKeyPath.

For more information please refer to myPOS Checkout API Documentation. 

 

$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.3'); 
$cnf->setWallet('61938166610');

 

Create a Response object with the incoming POST data.
This will validate the income data and the request signature.

try{ 
    $responce = \Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST); 
}catch(\Mypos\IPC\IPC_Exception $e){ 
    //Display Some general error or redirect to merchant store home page 
}

 

 

Get posted data as an array
$data is one-dimensional array containing elements with keys: IPCmethodSIDAmountCurrencyOrderIDIPC_TrnrefRequestSTANRequestDateTime.

getData() has optional argument $case to change array keys case. It must be CASE_LOWER or CASE_UPPER.

 

Merchant site must have the following logic:

1. Search in DB for order with this OrderID

2. Verify that Amount and Currency match to amount from the original transaction

3. Change order status to "Paid"

4. Echo "OK"

 

$data = $responce->getData(CASE_LOWER); 
if (' ... check and update order ') { 
//Echo "OK" 
} else { 
//Output anything different from "OK"
}