PreAuthCancellation – Cancel a Pre-Authorization

Use this method to cancel a reserved amount from a previous pre-authorization.

Step 1: Load the SDK

Code Example

PHP
require_once './IPC/Loader.php';

Step 2: Set Up Configuration

Create a Config object and set your API configuration parameters.

Note that IpcURL is different for sandbox and production environments.

You can use the automatic Configuration package or set manually keyIndex, sid, wallet and RSA keys (for request signatures by setting key content using setPrivateKey and setAPIPublicKey or by setting file path using setPrivateKeyPath and setAPIPublicKeyPath).

Configuration package:

Code Example

PHP
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.com/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setVersion('1.4');
$configurationPackage = 'your-generated-package-token';
$cnf->loadConfigurationPackage($configurationPackage);

RSA Key pair:

Code Example

PHP
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.com/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setVersion('1.4');
$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->setWallet('61938166610');

For more information, please refer to the IPCPreAuthCancellation method documentation.

Step 3: Create PreAuthorizationCancellation Object and Set Required Params

Code Example

PHP
$preAuthorization = new \Mypos\IPC\PreAuthorizationCancellation($cnf);
$preAuthorization->setOrderID('1498');
$preAuthorization->setAmount(24.50); // Total or partial amount of your Pre-authorization
$preAuthorization->setCurrency('EUR');
$preAuthorization->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);

Step 4: Process Request

Code Example

PHP
$result = $preAuthorization->process();

if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
    echo 'success';
    // success
} else {
    // Show error.
}

Need Help?

Check the official documentation for PreAuthCancellation for more advanced usage.