Make a refund for previously executed payment

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

$refund = new \Mypos\IPC\Refund($cnf);


Set Refund params

$refund->setAmount(10); 
$refund->setCurrency('EUR'); 
$refund->setOrderID(uniqid()); 
$refund->setTrnref('123456'); 
$refund->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_XML);


Send Refund request

if($refund->process()){ 
    //Refund successful! Do something 
}else{ 
    //Do something else 
}