Ensures there is only one payment method, and checks that
there is only one card or one token in use. Both cannot be
used.

@param array $actionCounts

@return bool
962656
public function onlyOnePaymentMethod($actionCounts)
    {
        $count = 0;
        if (isset($actionCounts['card'])) { $count++; }
        if (isset($actionCounts['token'])) { $count++; }
        if (isset($actionCounts['trackData'])) { $count++; }
        return 1 === $count;
    }
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);
    }
474512
protected function checkPaymentTransactionStatus(PaymentTransaction $paymentTransaction)
    {
        if (!$paymentTransaction->isFinished())
        {
            throw new ValidationException('Only finished payment transaction can be used for create-card-ref-id');
        }

        if (!$paymentTransaction->getPayment()->isPaid())
        {
            throw new ValidationException("Can not use new payment for create-card-ref-id. Execute 'sale' or 'preauth' query first");
        }
    }
873182
protected function verifyPayment()
	{
		try {
			$soap = new SoapClient($this->serverUrl);

			$result = $soap->CheckRequestStatusResult(
				$this->transactionId(),
				$this->config->get('gateway.sadad.merchant'),
				$this->config->get('gateway.sadad.terminalId'),
				$this->config->get('gateway.sadad.transactionKey'),
				$this->refId(),
				$this->amount
			);

		} catch (\SoapFault $e) {
			$this->transactionFailed();
			$this->newLog('SoapFault', $e->getMessage());
			throw $e;
		}

		if (empty($result) || !isset($result->AppStatusCode))
			throw new SadadException('در دریافت اطلاعات از بانک خطایی رخ داده است.');

		$statusResult = strval($result->AppStatusCode);
		$appStatus = strtolower($result->AppStatusDescription);

		$message = $this->getMessage($statusResult, $appStatus);

		$this->newLog($statusResult, $message['fa']);

		if ($statusResult != 0 || $appStatus !== 'commit') {
			$this->transactionFailed();
			throw new SadadException($message['fa'], $statusResult);
		}
		$this->trackingCode = $result->TraceNo;
		$this->cardNumber = $result->CustomerCardNumber;
		$this->transactionSucceed();
	}
1327042
public function beginTransaction(array $options = [])
    {
        if (!$this->isConnected()) {
            $this->connect();
        }
        
        if (!$this->inTransaction() || !empty($options['new'])) {
            $this->workSavepoint(
                'beginTransaction',
                'SAVEPOINT ' . $this->savePointName()
            );
            $this->transactions[] = true;
        } else {
            $this->transactions[] = false;
        }
    }
302683
public function onlyOneTransactionId($actionCounts)
    {
        return (isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 1
                && (!isset($actionCounts['clientTransactionId'])
                    || isset($actionCounts['clientTransactionId']) && $actionCounts['clientTransactionId'] == 0))
            || (isset($actionCounts['clientTransactionId']) && $actionCounts['clientTransactionId'] == 1
                && (!isset($actionCounts['transactionId'])
                    || isset($actionCounts['transactionId']) && $actionCounts['transactionId'] == 0));
    }
1288435
public function isActionAvailable($action)
    {
        $order = $this->getOrder();

        $availableActions = $this->getAvailableAction($order->getTransactionMode());

        $isAvailable = in_array($action, $availableActions);

        if ($isAvailable) {
            $isAvailable = false;

            switch ($action) {
                case 'capture':
                case 'reauthorize':
                case 'void':
                    if ($order->getRemainingOrderSum() > 0 && $order->getVoidedAmount() < $order->getRemainingOrderSum()) {
                        $isAvailable = true;
                    }
                    break;
            }
        }

        return $isAvailable;
    }
715409
public static function listAllTransactionsAsync(array $parameters = [])
    {
        return self::listAllTransactionsAsyncWithHttpInfo($page, $size, $sort)
            ->then(
                function ($response) {
                    return $response[0];
                }
            );
    }
250313
public function paymentSuccessful() {
    if ($this->requestMethod->getTransactionSuccessfulCode() != NULL) {
      return $this->requestMethod->getTransactionSuccessfulCode() == $this->notifyParams['gcResultPayment'];
    }

    return FALSE;
  }
1278742
protected function hasToken(IPaymentMethod $paymentMethod)
    {
        $tokenValue = null;

        if ($paymentMethod instanceof ITokenizable && !empty($paymentMethod->token)) {
            $tokenValue = $paymentMethod->token;
            return [true, $tokenValue];
        }

        return [false, $tokenValue];
    }
981049
public function paymentMethod(array $values)
    {
        $existing = array_filter($values, function ($method_id) {
            return (bool) $this->payment->get($method_id);
        });

        if (count($values) != count($existing)) {
            return $this->translation->text('@name is unavailable', array(
                '@name' => $this->translation->text('Payment')));
        }

        return true;
    }
12486
public function isSuccessful()
    {
        // get response code
        $code = $this->getHttpResponseCode();

        if ($code === 200) {  // OK
            return true;
        }

        if ($code === 201) {   // Created
            if ($this->getTransactionType() === 'payment') {
                return $this->isApproved();
            }
            return true;
        }

        if ($code === 202 && $this->isPending()) {   // Accepted
            return true;
        }

        return false;
    }
285489
public function rollback() {

        if($this->transactionCounter > 0) {
            $this->transactionCounter = 0;
            return parent::rollback();
        }//if

        $this->transactionCounter = 0;
        return false;

    }
169783
public function getMerchantAccountStatus($requestParameters = array())
    {
        $parameters           = array();
        $parameters['Action'] = 'GetMerchantAccountStatus';
        $requestParameters    = array_change_key_case($requestParameters, CASE_LOWER);

        $fieldMappings = array(
            'merchant_id'         => 'SellerId',
            'mws_auth_token'      => 'MWSAuthToken'
        );

        $responseObject = $this->setParametersAndPost($parameters, $fieldMappings, $requestParameters);
        return ($responseObject);
    }
285962
public function checkEntityPayments($payments = array())
    {
        $requestReferenceDetails = new Structure\RequestEntityPayments();
        if ($payments) {
            foreach ($payments as $key => $value) {
                $requestPayment = new Structure\RequestReferenceDetails($value);
                $requestReferenceDetails->addPayment($requestPayment);
            }
        }

        $this->response = parent::checkEntityPayments($this->entity, $requestReferenceDetails);

        /**
         * Checks the state of the platform integration.
         */
        if (Exception\IntegrationState::check($this->response->state)) {
            throw new Exception\IntegrationState($this->response->state);
        }

        if ($this->response->state->state == 0) {
            throw new Exception\IntegrationResponse($this->response->state->message, $this->response->state->code);
        }

        return $this->response;
    }
762253
public function getBatchCards($offset = 0, $count = 50)
    {
        $result = $this->httpPost(static::WECHAT_GET_BATCH_CARD_URL . 'access_token=' . $this->getAccessToken(), [
            'offset' => $offset,
            'count' => $count
        ]);

        return isset($result['card_id_list']) ? $result['card_id_list'] : false;
    }
95027
protected function getBatchActionConfirmationResponse($actionId, array $selectedIds)
    {
        $response = null;

        if (empty($selectedIds)) {
            // No IDs, so redirect to the index page.
            $response = $this->getIndexRedirectionResponse();
        } else {
            // There are IDs, so display the confirmation page.
            $response = $this->getHtmlResponse();
            $collectionName = $this->getCollectionName();
            $response->setTemplateId(sprintf('%s/%s',
                $collectionName,
                $actionId
            ));
            $response->setData($collectionName, $selectedIds);
        }

        return $response;
    }