Make a direct withdrawal transaction (Request money) from a specific myPOS account

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

$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 RequestMoney object with created config

$rm = new \Mypos\IPC\RequestMoney($cnf);


Set RequestMoney params

$rm->setAmount(10); 
$rm->setCurrency('EUR'); 
$rm->setOrderID(uniqid()); 
$rm->setMandateReferece('126ca831-93d2-4dfc-ab1f-0cce1d0abe9e'); 
$rm->setCustomerWalletNumber('61938166612'); 
$rm->setReason('Here comes the reason'); 
$rm->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);


Process request

$result = $rm->process(); 

if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) { 
    //Success. Save IPC_Trnref for transaction 
    echo $result->getData()['IPC_Trnref']; 
} else { 
    //Show error. 
}