Payment Type validity

@param string $paymentMode
Payment Mode to validate
@return boolean Validity is ok or not
344782
static public function isPaymentMode($paymentMode) {
    return ((string) $paymentMode == Connect2PayClient::PAYMENT_MODE_SINGLE ||
        (string) $paymentMode == Connect2PayClient::PAYMENT_MODE_ONSHIPPING ||
        (string) $paymentMode == Connect2PayClient::PAYMENT_MODE_RECURRENT ||
        (string) $paymentMode == Connect2PayClient::PAYMENT_MODE_INSTALMENTS);
  }
735961
public function processPayment(StripeMethod $paymentMethod, $amount)
    {
        /**
         * check and set payment data.
         */
        $chargeParams = $this->prepareData(
            $paymentMethod,
            $amount
        );

        /**
         * make payment.
         */
        $transaction = $this
            ->transactionFactory
            ->create($chargeParams);

        /**
         * Payment paid done.
         *
         * Paid process has ended ( No matters result )
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderDone(
                $this->paymentBridge,
                $paymentMethod
            );

        /**
         * when a transaction is successful, it is marked as 'closed'.
         */
        if ($transaction['paid'] != 1) {

            /**
             * Payment paid failed.
             *
             * Paid process has ended failed
             */
            $this
                ->paymentEventDispatcher
                ->notifyPaymentOrderFail(
                    $this->paymentBridge,
                    $paymentMethod
                );

            throw new PaymentException();
        }

        $paymentMethod
            ->setTransactionId($transaction['id'])
            ->setTransactionStatus('paid')
            ->setTransactionResponse($transaction);

        /**
         * Payment paid successfully.
         *
         * Paid process has ended successfully
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderSuccess(
                $this->paymentBridge,
                $paymentMethod
            );

        return $this;
    }
792812
def payment_mode(self, payment_mode):
        
        allowed_values = ["authorize", "capture"]
        if payment_mode is not None and payment_mode not in allowed_values:
            raise ValueError(
                "Invalid value for `payment_mode` ({0}), must be one of {1}"
                .format(payment_mode, allowed_values)
            )

        self._payment_mode = payment_mode
391501
public static function isValid($price)
    {
        //====================================================================//
        // Check Contents Available
        if (!is_array($price) && !($price instanceof ArrayObject)) {
            return false;
        }
        /** @var array|ArrayObject $price */
        if (!isset($price["base"])) {
            return false;
        }
        if (!isset($price["ht"]) || !isset($price["ttc"]) || !isset($price["vat"])) {
            return false;
        }
        if (!self::isValidAmount($price)) {
            return false;
        }
        if (!self::isValidCurrency($price)) {
            return false;
        }

        return true;
    }
112495
public function getHppPaymentMethodFee($paymentMethod)
    {
        $paymentMethod = str_replace('adyen_hpp_', '', $paymentMethod);

        $paymentFees = $this->getHppPaymentMethodFees();

        if ($paymentFees && is_array($paymentFees) && !empty($paymentFees)) {
            foreach ($paymentFees as $paymentFee) {
                if (isset($paymentFee['code']) && $paymentFee['code'] == $paymentMethod) {
                    if (isset($paymentFee['amount'])) {
                        return $paymentFee['amount'];
                    }
                }
            }
        }

        return null;
    }
990987
public function validatePayment($orderId)
    {
        /**
         * Loads order to validate.
         */
        $this
            ->paymentBridge
            ->findOrder($orderId);

        /**
         * Order Not found Exception must be thrown just here.
         */
        if (!$this->paymentBridge->getOrder()) {
            throw new PaymentOrderNotFoundException();
        }

        /**
         * Payment paid successfully.
         *
         * Paid process has ended successfully
         */
        $this
            ->paymentEventDispatcher
            ->notifyPaymentOrderSuccess(
                $this->paymentBridge,
                $this
                    ->methodFactory
                    ->create()
            );

        return $this;
    }
544932
public function valid()
    {

        if ($this->container['orderId'] === null) {
            return false;
        }
        if ($this->container['typeId'] === null) {
            return false;
        }
        if ($this->container['regionId'] === null) {
            return false;
        }
        if ($this->container['locationId'] === null) {
            return false;
        }
        if ($this->container['range'] === null) {
            return false;
        }
        $allowedValues = $this->getRangeAllowableValues();
        if (!in_array($this->container['range'], $allowedValues)) {
            return false;
        }
        if ($this->container['isBuyOrder'] === null) {
            return false;
        }
        if ($this->container['price'] === null) {
            return false;
        }
        if ($this->container['volumeTotal'] === null) {
            return false;
        }
        if ($this->container['volumeRemain'] === null) {
            return false;
        }
        if ($this->container['issued'] === null) {
            return false;
        }
        if ($this->container['state'] === null) {
            return false;
        }
        $allowedValues = $this->getStateAllowableValues();
        if (!in_array($this->container['state'], $allowedValues)) {
            return false;
        }
        if ($this->container['minVolume'] === null) {
            return false;
        }
        if ($this->container['walletDivision'] === null) {
            return false;
        }
        if ($this->container['walletDivision'] > 7) {
            return false;
        }
        if ($this->container['walletDivision'] < 1) {
            return false;
        }
        if ($this->container['duration'] === null) {
            return false;
        }
        if ($this->container['escrow'] === null) {
            return false;
        }
        return true;
    }
409296
def valid?
      return false if @id.nil?
      return false if @date.nil?
      return false if @amount.nil?
      return false if @memo.nil?
      return false if @cleared.nil?
      cleared_validator = EnumAttributeValidator.new('String', ['cleared', 'uncleared', 'reconciled'])
      return false unless cleared_validator.valid?(@cleared)
      return false if @approved.nil?
      return false if @flag_color.nil?
      flag_color_validator = EnumAttributeValidator.new('String', ['red', 'orange', 'yellow', 'green', 'blue', 'purple'])
      return false unless flag_color_validator.valid?(@flag_color)
      return false if @account_id.nil?
      return false if @payee_id.nil?
      return false if @category_id.nil?
      return false if @transfer_account_id.nil?
      return false if @transfer_transaction_id.nil?
      return false if @matched_transaction_id.nil?
      return false if @import_id.nil?
      return false if @deleted.nil?
      true
    end
747436
private function checkPaymentMethod($payment)
    {
        $paymentMethod = $payment->getMethod();

        if ($paymentMethod != Payment::METHOD_CODE) {
            throw new LocalizedException(__(
                'Payment method assigned to order is: %1',
                $paymentMethod
            ));
        }
    }
594033
private function validateMemberPaymentType() {
    /** @var \Drupal\node\Entity\Node $campaign Campaign node object. */
    $campaign = $this->getCampaign();
    /** @var \Drupal\openy_campaign\Entity\Member $member Temporary Member object. Will be saved by submit. */
    $member = $this->getMember();

    $campaignPaymentTypes = $campaign->get('field_campaign_payment_types')->getString();
    $memberPaymentType = $member->getPaymentType();

    if (in_array($memberPaymentType, explode(', ', $campaignPaymentTypes))) {
      return ['status' => TRUE, 'error' => ''];
    }

    return ['status' => FALSE, 'error' => t('Payment type does not match types: @types.', ['@types' => $campaignPaymentTypes])->render()];
  }
548252
public function isValidShopProduct($defaultCurrency)
    {
        $isValid = false;

        if (method_exists($this, 'getPrices') &&
            $this->getStatus()->getId() == Status::ACTIVE &&
            $this->getPrices() &&
            count($this->getPrices()) > 0 &&
            $this->hasPriceInDefaultCurrency($this->getPrices(), $defaultCurrency) &&
            $this->getSupplier()
        ) {
            $isValid = true;
        }

        return $isValid;
    }
281845
public function setPaymentMode($mode)
    {

        try {
            if ($mode instanceof PagSeguroPaymentMode) {
                $this->paymentMode = $mode;
            } else {
                $this->paymentMode = new PagSeguroPaymentMode($mode);
            }
        } catch (Exception $e) {
            die($e->getMessage());
        }
    }
905603
public function validateCard(PaylandsMethod $paymentMethod)
    {
        $response = $this->client->retrieveCustomerCards($paymentMethod->getCustomerExternalId());

        foreach ($response['cards'] as $card) {
            if ($paymentMethod->getCardUuid() == $card['uuid']) {
                $paymentMethod
                    ->setPaymentStatus(PaylandsMethod::STATUS_OK)
                    ->setPaymentResult($response);

                return;
            }
        }

        throw new CardNotFoundException(sprintf('Card %s not found for customer %s',
            $paymentMethod->getCardUuid(),
            $paymentMethod->getCustomerExternalId()
        ));
    }
1223398
public function validate()
    {
        if ($this->_amount === null) {
            $this->setValidationError('Payment amount not specified');
            return false;
        }

        $value = $this->_amount->getValue();
        if (empty($value) || $value <= 0.0) {
            $this->setValidationError('Invalid payment amount value: '.$value);
            return false;
        }

        if ($this->_receipt !== null && $this->_receipt->notEmpty()) {
            $email = $this->_receipt->getEmail();
            $phone = $this->_receipt->getPhone();
            if (empty($email) && empty($phone)) {
                $this->setValidationError('Both email and phone values are empty in receipt');
                return false;
            }
        }

        return true;
    }
821476
protected function checkRequirements($mode)
    {
        if (true !== in_array($mode, self::$validModes, true)) {
            throw new Exception(
                sprintf('Mode "%s" not supported. Supported: "%s"', $mode, var_export(self::$validModes, true))
            );
        }

        switch ($mode) {
            case self::MODE_OPEN_SSL:
            case self::MODE_PHP_DEFAULT:
            case self::MODE_PHP_MERSENNE_TWISTER:
            default:
                // Intentionally omitted cause not required - listed here for code quality and readability
                break;
        }

        return true;
    }
167087
def validate_recurrent_transaction_params!(options)
      required_params = [:amount, :payment_method, :invoicenumber, :transaction_id]

      validate_required_params!(options, required_params)

      validate_amount!(options)

      valid_payment_methods = [
        PaymentMethod::VISA, PaymentMethod::MASTER_CARD, PaymentMethod::MAESTRO,
        PaymentMethod::SEPA_DIRECT_DEBIT, PaymentMethod::PAYPAL
      ]
      validate_payment_method!(options, valid_payment_methods)
    end
481358
protected function validateOrderCheckout()
    {
        if ($this->same_payment_address) {
            $this->unsetSubmitted('address.payment');
        }

        $this->setSubmitted('update', array());
        $this->setSubmitted('store_id', $this->store_id);
        $this->setSubmitted('user_id', $this->order_user_id);
        $this->setSubmitted('creator', $this->admin_user_id);

        if ($this->admin) {
            $this->setSubmitted('status', $this->order->getStatusInitial());
        }

        return $this->validateComponent('order');
    }