Payment Status
Check the current status of a previously executed payment using the myPOS Checkout API.
1. Include the SDK Loader
This will autoload necessary library files and classes.
require_once './IPC/Loader.php';
2. Create Config Object and Set API Configuration Params
Note:
IpcURLis 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:
$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:
$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, see the IPCGetPaymentStatus method documentation.
3. Create GetPaymentStatus Object and Set Required Params
$ipcStatus = new Mypos\IPC\GetPaymentStatus($cnf);
$ipcStatus->setOrderID('1440');
$ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
4. Process Request
$result = $ipcStatus->process();
5. Check Response Status and Use Received Data
You may get response data as an array using getData() or in the original communication format using getDataRaw().
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
// Display returned data in the site interface.
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
// Order not found or set params are invalid.
// Show error.
break;
}
Best Practice: Wrap in Try-Catch
Using a try-catch block helps handle exceptions gracefully:
try{
$ipcStatus = new \Mypos\IPC\GetPaymentStatus($cnf);
$ipcStatus->setOrderID('1440');
$ipcStatus->setOutputFormat(\Mypos\IPC\Defines::COMMUNICATION_FORMAT_JSON);
$result = $ipcStatus->process();
switch($result->getStatus()){
case \Mypos\IPC\Defines::STATUS_SUCCESS:
print_r(\Mypos\IPC\Helper::getArrayVal($result->getData(CASE_LOWER), 'orderstatus'));
break;
case \Mypos\IPC\Defines::STATUS_INVALID_PARAMS:
echo 'Not found!';
break;
}
}catch(\Mypos\IPC_Exception $ex){
// Display exception message
echo $ex->getMessage();
}
More Information
For a full breakdown of response fields and validation tips, see the GetPaymentStatus API documentation.