include dirname(__FILE__) . '/../../config/config.inc.php'; require_once dirname(__FILE__) . '/lib/api.php'; require_once dirname(__FILE__) . '/masterpayment.php'; function dieWithError($error) { $l = date('Y-m-d H:i:s') . ' "' . $error . '" data:' . json_encode(array('post' => $_POST, 'get' => $_GET)) . "\n"; file_put_contents(dirname(__FILE__) . '/error.log', $l, FILE_APPEND); die($error); } $module = new MasterPayment(); //Setup MasterPayment API to handle request $api = new MasterPaymentApi(); $api->secretKey = Configuration::get('MP_SECRET_KEY'); //Get request status $status = $api->getRequestStatus(); //Check status if ($status == 'INVALID') { dieWithError('Invalid request'); } //Extract cart ID from transaction ID $id_cart = MasterPayment::decodeTxID($api->txId); $totalAmount = (double) $api->basketValue / 100; $cart = new Cart($id_cart); if (!Validate::isLoadedObject($cart)) { dieWithError('Cart not found'); } $id_order = Order::getOrderByCartId($cart->id); $order = $id_order ? new Order($id_order) : null; $currency = new Currency($cart->id_currency); //Check currency