Checks whether PayPal payment is available.

@param object $user
@param double $basketPrice
@param string $shippingId

@return bool
487444
protected function isPayPalPaymentValid($user, $basketPrice, $shippingId)
    {
        $valid = true;

        $payPalPayment = oxNew(\OxidEsales\Eshop\Application\Model\Payment::class);
        $payPalPayment->load('oxidpaypal');
        if (!$payPalPayment->isValidPayment(null, null, $user, $basketPrice, $shippingId)) {
            $valid = $this->isEmptyPaymentValid($user, $basketPrice, $shippingId);
        }

        return $valid;
    }
458916
protected function saveECDefaultShippingId($config, $shippingId, $payPalConfig)
    {
        $payPalModuleId = 'module:' . $payPalConfig->getModuleId();
        $config->saveShopConfVar('string', 'sOEPayPalMECDefaultShippingId', $shippingId, null, $payPalModuleId);
    }
132593
public function getPdt($transactionID)
    {
        $this->transactionID = $transactionID;
        
        // Now we need to ask PayPal to tell us if it sent this notification
        $pdtResponse = $this->_postData($this->pdtURL, array('cmd' => '_notify-synch', 'tx' => $transactionID, 'at' => $this->pdtToken));
        if ($pdtResponse === FALSE) { // Bail out if we have an error.
            return FALSE;
        }

        // Phew! We have a valid PDT transaction, log it.
        $this->_logTransaction('PDT', 'SUCCESS', 'Parsing complete', $pdtResponse);
        return $pdtResponse;
    }
1359297
protected function _checkIPN( $baseManager, $basket, $additional )
	{
		$attrManager = MShop_Factory::createManager( $this->_getContext(), 'order/base/service/attribute' );

		if( $this->_getConfigValue( array( 'paypalexpress.AccountEmail' ) ) !== $additional['receiver_email'] )
		{
			$msg = sprintf( 'PayPal Express: Wrong receiver email "%1$s"', $additional['receiver_email'] );
			throw new MShop_Service_Exception( $msg );
		}

		$price = $basket->getPrice();
		$amount = $price->getValue() + $price->getCosts();
		if( $amount != $additional['payment_amount'] )
		{
			$msg = sprintf( 'PayPal Express: Wrong payment amount "%1$s" for order ID "%2$s"', $additional['payment_amount'], $additional['invoice'] );
			throw new MShop_Service_Exception( $msg );
		}

		$search = $attrManager->createSearch();
		$expr = array(
			$search->compare( '==', 'order.base.service.attribute.code', $additional['txn_id'] ),
			$search->compare( '==', 'order.base.service.attribute.value', $additional['payment_status'] ),
		);

		$search->setConditions( $search->combine( '&&', $expr ) );
		$results = $attrManager->searchItems( $search );

		if ( ( $attr = reset( $results ) ) !== false )
		{
			$msg = sprintf( 'PayPal Express: Duplicate transaction with ID "%1$s" and status "%2$s" ', $additional['txn_id'], $additional['txn_status'] );
			throw new MShop_Service_Exception( $msg );
		}
	}
984180
public function isBidder(User $user)
    {
        return (bool) $this->bids()->whereHas('bidder', function ($query) use ($user) {
            return $query->where('user_id', $user->userId);
        })->count();
    }
280216
public function isValidBasketElement(BasketElementInterface $basketElement)
    {
        $product = $basketElement->getProduct();

        if (!$product instanceof ProductInterface) {
            return false;
        }

        return true;
    }
433693
public function isPaymentDataRequired(OrderTransfer $orderTransfer)
    {
        $paymentTransfer = $this->getPayment($orderTransfer);

        // Return early if we don't need the iban or bic data
        $paymentMethod = $paymentTransfer->getPaymentMethod();
        $whiteList = [
            PayoneApiConstants::PAYMENT_METHOD_E_WALLET,
            PayoneApiConstants::PAYMENT_METHOD_CREDITCARD_PSEUDO,
            PayoneApiConstants::PAYMENT_METHOD_ONLINE_BANK_TRANSFER,
        ];

        if (in_array($paymentMethod, $whiteList)) {
            return false;
        }

        return true;
    }
415699
private function processAbandonedCartsForCustomers($storeId, $websiteId, $result)
    {
        $secondCustomerEnabled = $this->isLostBasketCustomerEnabled(self::CUSTOMER_LOST_BASKET_TWO, $storeId);
        $thirdCustomerEnabled = $this->isLostBasketCustomerEnabled(self::CUSTOMER_LOST_BASKET_THREE, $storeId);

        //first customer
        if ($this->isLostBasketCustomerEnabled(self::CUSTOMER_LOST_BASKET_ONE, $storeId) ||
            $secondCustomerEnabled ||
            $thirdCustomerEnabled
        ) {
            $result[$storeId]['firstCustomer'] = $this->processCustomerFirstAbandonedCart($storeId);
        }

        //second customer
        if ($secondCustomerEnabled) {
            $result[$storeId]['secondCustomer'] = $this->processExistingAbandonedCart(
                $this->getLostBasketCustomerCampaignId(self::CUSTOMER_LOST_BASKET_TWO, $storeId),
                $storeId,
                $websiteId,
                self::CUSTOMER_LOST_BASKET_TWO
            );
        }

        //third customer
        if ($thirdCustomerEnabled) {
            $result[$storeId]['thirdCustomer'] = $this->processExistingAbandonedCart(
                $this->getLostBasketCustomerCampaignId(self::CUSTOMER_LOST_BASKET_THREE, $storeId),
                $storeId,
                $websiteId,
                self::CUSTOMER_LOST_BASKET_THREE
            );
        }

        return $result;
    }
1211128
public function IsAvailable()
    {
        $bIsValid = true;
        $bIsValid = ($bIsValid && $this->IsActive());
        $bIsValid = ($bIsValid && $this->isValidForCurrentPortal());
        $bIsValid = ($bIsValid && $this->IsValidForCurrentUser());
        $bIsValid = ($bIsValid && $this->IsValidForBasket());

        return $bIsValid;
    }
944491
public function checkPayment($transaction_id)
    {
        // Check arguments
        if (null === $transaction_id || !is_string($transaction_id) || strlen(trim($transaction_id)) == 0) {
            throw new \InvalidArgumentException('Transaction ID should be a string.');
        }

        // Params
        $params = array(
            'partnerid' => $this->partnerId,
            'transaction_id' => $transaction_id,
        );

        // Do request
        $response = $this->request('check-status/', $params);

        // Gather data
        if ($response->order === null) {
            throw new MollieException('Unexpected response');
        }
        $transactionId = (string) $response->order->transaction_id;
        $amount = (int) $response->order->amount;
        $paid = ((string) $response->order->paid == 'true');
        $status = (string) $response->order->status;

        // Return TransactionStatus
        return new TransactionStatus($amount, $paid, $transactionId, $status);
    }
476236
public function update(UserPolicy $user, PriceList $price_list)
    {
        if ($user->canDo('pricelist.price_list.edit') && $user->isAdmin()) {
            return true;
        }

        return $price_list->user_id == user_id() && $price_list->user_type == user_type();
    }
352501
private function isValidPaymentId($paymentId)
    {
        // We force reading from master to prevent issues with slow replications or open transactions (see ESDEV-3804).
        $masterDb = DatabaseProvider::getMaster();

        $paymentModel = oxNew(EshopPayment::class);
        $tableName = $paymentModel->getViewName();

        $sql = "
            select
                1 
            from 
                {$tableName}
            where 
                {$tableName}.oxid = {$masterDb->quote($paymentId)}
                and {$paymentModel->getSqlActiveSnippet()}
        ";

        return (bool) $masterDb->getOne($sql);
    }
1271991
function _TransactionSearch($startDate = '', $oID = '', $criteria = '') {
    global $db, $messageStack, $doPayPal;
    $doPayPal = $this->paypal_init();
    // look up history on this order from PayPal table
    $sql = "select * from " . TABLE_PAYPAL . " where order_id = :orderID  AND parent_txn_id = '' ";
    $sql = $db->bindVars($sql, ':orderID', $oID, 'integer');
    $zc_ppHist = $db->Execute($sql);
    if ($zc_ppHist->RecordCount() == 0) return false;
    $txnID = $zc_ppHist->fields['txn_id'];
    $startDate = $zc_ppHist->fields['payment_date'];
    $timeval = time();
    if ($startDate == '') $startDate = date('Y-m-d', $timeval) . 'T' . date('h:i:s', $timeval) . 'Z';
    /**
     * Read data from PayPal
     */
    $response = $doPayPal->TransactionSearch($startDate, $txnID, $email, $criteria);

    $error = $this->_errorHandler($response, 'TransactionSearch');
    if ($error === false) {
      return false;
    } else {
      return $response;
    }
  }
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;
	}
1110221
protected function isValidTwoFactorTotp(AuthenticatableTwoFactorContract $user, int $token): bool
    {
        $totpProvider = app(Google2FA::class);
        $secret = array_get($user->getTwoFactor(), 'totp.secret');

        return mb_strlen($token) === 6 && $totpProvider->verifyKey($secret, $token);
    }
722412
public function isActionAvailable($action, $payment = null)
    {
        if ($payment) {
            $this->setPayment($payment);
        }

        $payment = $this->getPayment();

        $isAvailable = in_array($action, $this->getAvailableActions($payment->getAction(), $payment->getStatus()));

        if ($isAvailable) {
            $isAvailable = false;

            switch ($action) {
                case 'refund':
                    $isAvailable = ($payment->getAmount() > $payment->getRefundedAmount());
                    break;
            }
        }

        return $isAvailable;
    }
456942
public function cancelCoupon($basketId, string $couponCode, $userId)  // !! DEPRECATED moved to basket
    {
        $params = [
          "basketId" => $basketId,
          "couponCode" => $couponCode,
          "userId" => $userId
        ];

        $response = $this->handler->handle('POST', $params, 'discard');

        //TODO: refactor to make method
        return $response;
        //        return $this->make($response, false);
    }