public static function addNewOKPWallet() { $email = Core::validate($_POST['EMAIL']); $wallet_id = Core::validate($_POST['WALLET_ID']); $api_password = Core::validate($_POST['API_PASSWORD']); $currency = Core::validate($_POST['CURRENCY']); $share = Core::validate($_POST['SHARE']); // percent if ($email == null || $wallet_id == null || $api_password == null || $currency == null || $share == null || !Core::isDouble($share)) { print 'Incorrect input data'; exit; } $result = WalletsOkp::findBy(array('email' => $email, 'wallet_id' => $wallet_id, 'currency' => $currency)); if (!empty($result)) { print 'This wallet already exists'; exit; } $okpay = new OKPay(); $balance = $okpay->currency_balance($wallet_id, $api_password, $currency); if ($balance === null) { print $okpay->Error(); exit; } $wallet = new WalletsOkp(); $wallet->setEmail($email); $wallet->setWalletId($wallet_id); $wallet->setApiPassword($api_password); $wallet->setCurrency($currency); $wallet->setValue($balance); $wallet->setShare($share / 100.0); $wallet->insert(); header('Location: /admin/okp'); }