Purchase Notify
This endpoint is used by myPOS Checkout to notify the merchant about the status of a payment. It is the recommended and most reliable method for verifying a successful payment.
NOTE: Upon HTTP request, your endpoint must respond with HTTP status
200 OKand the body content:OK. Any other response will be treated as a communication error and may trigger retries.
Do not use IPCPurchaseOK to authorize a payment because it is not a server-to-server connection and is not always guaranteed to receive a response.
Always use IPCPurchaseNotify.
Step 1: Include SDK Loader
This will autoload necessary library files and classes.
require_once './IPC/Loader.php';
Step 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 (recommended):
$cnf = new \Mypos\IPC\Config();
$cnf->setIpcURL('https://mypos.com/vmp/checkout-test/');
$cnf->setLang('en');
$cnf->setVersion('1.4');
$configurationPackage = 'your-configuration-token';
$cnf->loadConfigurationPackage($configurationPackage);
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->setKeyIndex(1);
$cnf->setSid('000000000000010');
$cnf->setWallet('61938166610');
For more information, please refer to the IPCPurchaseNotify method documentation.
Step 3: Parse and Validate the Incoming Request
Create a Response object with the incoming POST data. This will validate the data and the request signature.
try {
$responce = \Mypos\IPC\Response::getInstance($cnf, $_POST, \Mypos\IPC\Defines::COMMUNICATION_FORMAT_POST);
} catch(\Mypos\IPC\IPC_Exception $e) {
// Display a general error or redirect to merchant store home page
}
Step 4: Get Posted Data as an Array
$data is a one-dimensional array containing elements with keys:
IPCmethod, SID, Amount, Currency, OrderID, IPC_Trnref, RequestSTAN, RequestDateTime.
$data = $responce->getData(CASE_LOWER);
Step 5: Merchant Logic
- Search in your database for the order with this
OrderID - Verify that
AmountandCurrencymatch the original transaction - Change order status to "Paid"
- Echo
"OK"(any other response will be treated as failure)
if (/* check order ID, match amount & currency, mark as paid */) {
echo 'OK';
} else {
echo 'FAIL'; // Any other response indicates failure
}
More Info
For a deeper dive, see the PurchaseNotify method documentation.