PreAuthorization
Pre-authorization allows you to place a hold on a customer’s funds using their payment card before finalizing a transaction.
Important Notes
-
PCI SAQ-D Requirements:
If you use this method without a tokenized card, you must comply with PCI SAQ-D requirements. Since all cardholder data is processed on your side, you are also responsible for communication with the issuing bank's ACS. We recommend using an MPI plugin for 3D Secure communication. -
Tokenized Cards:
If you want to use the method with a tokenized card, myPOS will need to test and evaluate the usage (whether in your website or in-app) and enable the functionality in the Production Environment.
1. Include the SDK Loader
This will autoload necessary library files and classes.
require_once './IPC/Loader.php';
2. API Configuration
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).
EncryptPublicKey is required to encrypt sensitive data (Card number, Expiry date, CVC).
Note: EncryptPublicKey is the same as the APIPublicKey.
For more information, see the IPCIAPreAuthorization method documentation.
Option 1: Using a Configuration Package (Recommended)
$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);
Option 2: Manual Configuration
$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->setEncryptPublicKeyPath(dirname(__FILE__) . '/keys/encrypt_key.pem');
$cnf->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setWallet('61938166610');
3. Create IAPreAuthorization Object and Set Required Params
$preAuthorization = new \Mypos\IPC\IAPreAuthorization($cnf);
$preAuthorization->setOrderID(uniqid()); // Some unique ID
$preAuthorization->setItemName('Some Book'); // Item contained in your Pre-authorization
$preAuthorization->setAmount(24.50); // Total amount of your Pre-authorization
$preAuthorization->setCurrency('EUR');
$preAuthorization->setNote('Some note'); // Not required
$preAuthorization->setCard($card); // Card object with sensitive data
$preAuthorization->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
4. Process Request
$result = $preAuthorization->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
echo 'success';
// Success
} else {
// Show error.
}
Reference
For more information, refer to the PreAuthorization method in the official documentation.