public static function PM_transaction_o_complete() { $id = Core::validate($_GET['id']); $hash = Core::validate($_GET['hash']); $at = new AtPm(); if (!$at->findById($id)) { header('Location: ' . URL_WRONG_DATA_INPUT); exit; } if ($hash != self::hash_for_money_output_link($at->getId(), $at->getUID())) { header('Location: ' . URL_WRONG_DATA_INPUT); exit; } $amount = $at->getAmount(); $wallets = self::PM_MinAndMaxWallets($at->getUnits()); if ($wallets['max'] == null || $wallets['max']['current_balance'] < $amount) { header('Location: ' . URL_SERVER_ERROR); exit; } $wallet = new WalletsPm(); $wallet->findById($wallets['max']['id']); $perfectMoney = new PerfectMoney(); $perfectMoney->setAccountID($wallet->getAccountId()); $perfectMoney->setPassPhrase($wallet->getPassPhrase()); $resp = $perfectMoney->transfer($wallet->getAccount(), $at->getPayeeAccount(), $amount, 'Transfer from bitmonex', false); if ($resp == null) { header('Location: ' . URL_SERVER_ERROR); exit; } $currency = new Currency(); $currency->findBy(array('Name' => $at->getUnits())); $limits = self::transactionLimits($currency->getId(), 'PM', 1); $feeVolume = $amount * $limits['fee']; $feeVolume = Core::round_up($feeVolume, 2); $purses = Purse::findBy(array('UID' => $at->getUID(), 'CurId' => $currency->getId())); $purse = new Purse(); $purse->findById($purses[0]['id']); $purse->addValue(-($amount + $feeVolume)); $purse->save(); $systemFeeVolume = $amount * $limits['system_fee']; $systemFeeVolume = Core::round_up($systemFeeVolume, 2); $profit = ($feeVolume - $systemFeeVolume) * $wallet->getShare(); $wallet->setProfit($wallet->getProfit() + $profit); $wallet->save(); $at->setStatus(1); $at->setPayerAccount($wallet->getAccount()); $at->setBatchNum($resp['PAYMENT_BATCH_NUM']); $at->setTimestamp(Core::timestamp_gmp()); $at->save(); header('Location: ' . URL_SUCCESS_PAYMENT); }
if ((floatval($_POST['amount']) <= $limit || $limit == 0) && (floatval($_POST['amount']) + $withdrawnToday <= $daily_limit || $daily_limit == 0)) { sql_query(' INSERT INTO translines SET id=0, parent_id=0, user_id="' . $user['id'] . '", plan_id=0, type="w", amount="-' . abs(floatval($_POST['amount'])) . '", stamp="' . Project::getInstance()->getNow() . '", status="0", batch="" '); $payment_id = sql_insert_id(); $reciept_id = $gateway->transfer($account, $user['account'], floatval($_POST['amount']), urlencode('Withdrawal for user ' . $user['login'] . ' on ' . date('M d, Y H:i', Project::getInstance()->getNow()) . ' from ' . get_setting('project_name'))); } else { $reciept_id = 0; } if ($reciept_id) { sql_query(' UPDATE translines SET status="1", batch="' . $reciept_id . '" WHERE id="' . $payment_id . '"'); if (Project::getInstance()->getCurUser()->withdrawal_notify) { include_once LIB_ROOT . '/emails.class.php'; //%user_fullname%, %user_login%, %amount%, %batch%, %access_time%, %account%, %project_name%, %project_email% $params = array('%user_fullname%' => htmlspecialchars($user['fullname']), '%user_login%' => $user['login'], '%account%' => $user['account'], '%amount%' => floatval($_POST['amount']), '%batch%' => $reciept_id, '%project_name%' => get_setting('project_name'), '%project_email%' => get_setting('project_email'), '%access_time%' => date('M d, Y H:i', Project::getInstance()->getNow()));