Check if user can pay for transaction
@param $amount
@param $userId
@return bool
543378
public function canPay($amount, $userId)
    {
        $balance = config('laravel_balance.user')::find($userId)->balance();

        return ($balance < $amount) ? false : true;
    }
180918
protected function userPayment()
	{
		$this->authority = Input::get('Authority');
		$status = Input::get('Status');

		if ($status == 'OK') {
			return true;
		}

		$this->transactionFailed();
		$this->newLog(-22, ZarinpalException::$errors[-22]);
		throw new ZarinpalException(-22);
	}
1102198
public function verify($customerId, $bankAccountId, array $amounts, $verificationMethod = null)
    {
        return $this->_post("customers/{$customerId}/sources/{$bankAccountId}/verify", [
            'amounts' => $amounts, 'verification_method' => $verificationMethod,
        ]);
    }
1358367
public static function tooMany($userId)
    {
        $sessionKey = 'messages.' . $userId;
        if (Yii::$app->session->has($sessionKey)) {
            $sentAlready = explode('|', Yii::$app->session->get($sessionKey));
            $validated = [];
            foreach ($sentAlready as $t) {
                if (preg_match('/^[0-9]+$/', $t)) {
                    if ($t > time() - self::SPAM_WAIT * 60) {
                        $validated[] = $t;
                    }
                }
            }
            Yii::$app->session->set($sessionKey, implode('|', $validated));
            if (count($validated) >= self::SPAM_MESSAGES) {
                return true;
            }
        }
        return false;
    }
426809
public static function doPay($billId)
	{
		$isUpdate = self::whereBillId($billId)
			->whereStatus(self::C_STATUS_WAITING)
			->update(
				array('status' => self::C_STATUS_PAID)
			);
		if ($isUpdate) {
			return true;
		}

		return false;
	}
1118535
protected function userPayment()
    {
        $status = Input::get('status');
        $transId = Input::get('transId');
        $this->cardNumber = Input::get('cardNumber');
        $message = Input::get('message');
        if (is_numeric($status) && $status > 0) {
            $this->trackingCode = $transId;
            return true;
        }
        $this->transactionFailed();
        $this->newLog(-5, $message);
        throw new PayirReceiveException(-5);
    }
671173
public static function checkAmount($amount)
    {
        if ($amount < 0 || $amount === null) {
            throw new HpsInvalidRequestException(
                HpsExceptionCodes::INVALID_AMOUNT,
                'Must be greater than or equal to 0.',
                'amount'
            );
        }
        $amount = preg_replace('/[^0-9\.]/', '', $amount);
        return sprintf("%0.2f", round($amount, 3));
    }
314085
public static function findDoublePay($term, $city, $amount, $to, $status = null)
	{
		$payment = self::$paymentStatic
			->newInstance()
			->whereTerm($term)
			->whereTo($to)
			->whereAmount($amount)
			->whereCity($city)
			->whereType(Type::PAY);

		if (!is_array($status)) {
			$status = (array)$status;
		}
		if ($status) {
			$payment->whereIn('status', $status);
		}
		$payment->orderBy('id', 'desc');

		$payment = $payment->first();

		return $payment;

	}
87248
public function filterByAmount($amount)
    {
        $amount = intval($amount);
        $filteredArr = array();
        foreach ($this->_paymentMethodsArrayFiltered as $paymentMethod) {
            $continue = true;
            foreach ($paymentMethod["Issuers"] as $issuer) {
                foreach ($issuer["Countries"] as $country) {
                    if ($amount >= intval($country["MinimumAmount"]) &&
                            $amount <= intval($country["MaximumAmount"])) {
                        array_push($filteredArr, $paymentMethod);
                        $continue = false;
                    }
                    if (!$continue)
                        break;
                }
                if (!$continue)
                    break;
            }
        }
        $this->_paymentMethodsArrayFiltered = $filteredArr;
        return $this;
    }
1336124
public function isConfirmableBy($userId)
    {
        return
            $this->isConfirmable() &&
            $this->shouldConfirmBy($userId) &&
            $this->canConfirm($userId);
    }
1057968
public function checkToken($userId = null, $method = null)
    {
        /** @var Input $input */
        $input = $this->input;
        $token = $this->getFormToken($userId);

        if ($method) {
            $input = $input->$method;
        }

        if ($input->get($token, null, InputFilter::ALNUM) !== null) {
            return true;
        }

        if ($input->header->get('X-CSRF-Token') === $token) {
            return true;
        }

        return false;
    }
123074
public function increaseTransferBalance($amount)
    {
        $this->transfer_balance = bcadd($this->transfer_balance, $amount);
        if ($this->transfer_balance < 0) {//计算后如果余额小于0，那么结果不合法。
            return false;
        }
        $transaction = static::getDb()->beginTransaction();//开始事务
        try {
            if ($this->save()) {
                $transaction->commit();
                return true;
            } else {
                $transaction->rollBack();
                return false;
            }
        } catch (\Exception $e) {
            $transaction->rollBack();
            Yii::error($e->getMessage(), __METHOD__);
        } catch (\yii\db\Exception $e) {
            $transaction->rollBack();
            Yii::error($e->getMessage(), __METHOD__);
        }
        return false;
    }
630050
protected function userPayment()
	{
		$this->refId = Input::get('RefId');
		$this->trackingCode = Input::get('SaleReferenceId');
		$this->cardNumber = Input::get('CardHolderPan');
		$payRequestResCode = Input::get('ResCode');

		if ($payRequestResCode == '0') {
			return true;
		}

		$this->transactionFailed();
		$this->newLog($payRequestResCode, @MellatException::$errors[$payRequestResCode]);
		throw new MellatException($payRequestResCode);
	}
637708
public function lock_submission($userid) {
        global $USER, $DB;
        // Need grade permission.
        require_capability('mod/assign:grade', $this->context);

        // Give each submission plugin a chance to process the locking.
        $plugins = $this->get_submission_plugins();
        $submission = $this->get_user_submission($userid, false);

        $flags = $this->get_user_flags($userid, true);
        $flags->locked = 1;
        $this->update_user_flags($flags);

        foreach ($plugins as $plugin) {
            if ($plugin->is_enabled() && $plugin->is_visible()) {
                $plugin->lock($submission, $flags);
            }
        }

        $user = $DB->get_record('user', array('id' => $userid), '*', MUST_EXIST);
        \mod_assign\event\submission_locked::create_from_user($this, $user)->trigger();
        return true;
    }
1023525
public function listPayments($userId, $monetaryAccountId)
    {
        $payments = $this->client->get($this->getResourceEndpoint($userId, $monetaryAccountId));
        foreach ($payments['Response'] as $key => $payment) {
            $payments['Response'][$key]['Payment']['amount']['value'] = $this->floatToCents($payment['Payment']['amount']['value']);
        }

        return $payments;
    }
153393
protected function userPayment()
    {
        $refId = Input::get('au');

        if ($this->refId() != $refId) {
            $this->transactionFailed();
            $this->newLog(-30, JahanPayException::$errors[-30]);
            throw new JahanPayException(-30);
        }

        return true;
    }
1343281
public static function can_create_data_deletion_request_for_other(int $userid = null): bool {
        global $USER;
        $userid = $userid ?: $USER->id;
        return has_capability('tool/dataprivacy:requestdeleteforotheruser', context_system::instance(), $userid);
    }