Authorization – Initiate a Payment with a Card Token
Important:
To use Authorization, you must have a valid card token.
You can generate one by visiting the Recurring Payments section.
Please NOTE
For IPCAuthorization usage, a card token is required. To generate one, please visit Recurring payments.
Step 1: Load the SDK
This will autoload necessary library files and classes.
Code Example
require_once './IPC/Loader.php';Step 2: Configure API Access
The 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).
For more information, please refer to the IPCAuthorization method documentation.
Configuration package:
Code Example
$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
$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');EncryptPublicKey is the same as APIPublicKey and is required to encrypt sensitive card details.
Step 3: Create the Authorization Object
Use your config and set all required parameters:
Code Example
$authorization = new \Mypos\IPC\Authorization($cnf);
$authorization->setOrderID(uniqid()); // Some unique ID
$authorization->setItemName('Some Book'); // Item contained in your authorization
$authorization->setAmount(24.50); // Total amount of your authorization
$authorization->setCurrency('EUR');
$authorization->setNote('Some note'); // Not required
$authorization->setCard($card);
$authorization->setOutputFormat(Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);Step 4: Send the Request
Process the authorization request:
Code Example
$result = $authorization->process();
if ($result->getStatus() == \Mypos\IPC\Defines::STATUS_SUCCESS) {
echo 'success';
// Success
} else {
// Show error.
}