Check the payment for required fields and validity.
        @param payment: The payment dict
        @return: True if valid, error string if invalid paramaters where
        encountered.
167548
def check_payment(self, payment):
        
        validation = ""

        if not isinstance(payment['amount'], int):
            validation += "AMOUNT_NOT_INTEGER "

        if not isinstance(payment['mandate_date'], datetime.date):
            validation += "MANDATE_DATE_INVALID_OR_NOT_DATETIME_INSTANCE"
        payment['mandate_date'] = str(payment['mandate_date'])

        if not isinstance(payment['collection_date'], datetime.date):
            validation += "COLLECTION_DATE_INVALID_OR_NOT_DATETIME_INSTANCE"
        payment['collection_date'] = str(payment['collection_date'])

        if validation == "":
            return True
        else:
            raise Exception('Payment did not validate: ' + validation)
22684
def validate_setup_transaction_params!(options)
      required_params = [:amount, :payment_method, :invoicenumber]
      required_params << :return_url if options[:payment_method] != PaymentMethod::SEPA_DIRECT_DEBIT

      case options[:payment_method]
      when PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING
        required_params << :payment_issuer
      when PaymentMethod::SEPA_DIRECT_DEBIT
        required_params << [:account_iban, :account_name]
      end

      validate_required_params!(options, required_params)

      validate_amount!(options)

      valid_payment_methods = [
        PaymentMethod::IDEAL, PaymentMethod::IDEAL_PROCESSING, PaymentMethod::VISA, PaymentMethod::MASTER_CARD, PaymentMethod::MAESTRO,
        PaymentMethod::SEPA_DIRECT_DEBIT, PaymentMethod::PAYPAL, PaymentMethod::BANCONTACT_MISTER_CASH
      ]
      validate_payment_method!(options, valid_payment_methods)

      validate_payment_issuer!(options)
    end
1118631
def refund_payment(self):
        
        Money = MoneyMaker(self.currency)
        filter_kwargs = {
            'transaction_id__startswith': 'ch_',
            'payment_method': StripePayment.namespace,
        }
        for payment in self.orderpayment_set.filter(**filter_kwargs):
            refund = stripe.Refund.create(charge=payment.transaction_id)
            if refund['status'] == 'succeeded':
                amount = Money(refund['amount']) / Money.subunits
                OrderPayment.objects.create(order=self, amount=-amount, transaction_id=refund['id'],
                                            payment_method=StripePayment.namespace)

        del self.amount_paid  # to invalidate the cache
        if self.amount_paid:
            # proceed with other payment service providers
            super(OrderWorkflowMixin, self).refund_payment()
1334134
def check_valid(self, get_params):
        
        if self.commands._if:
            return self.commands._if.check_valid(get_params)
1095058
protected function _isPaymentResponseSessionInvalid()
    {
        /** @var OxpsPaymorrowModule $oModule */
        $oModule = oxRegistry::get('OxpsPaymorrowModule');

        // Get Paymorrow response from session
        $aPaymorrowResponse = $oModule->getPaymorrowResponseData();

        // The response must exist and be valid
        return (
            !isset($aPaymorrowResponse['order_status'], $aPaymorrowResponse['response_status']) or
            !in_array($aPaymorrowResponse['order_status'], array('VALIDATED', 'ACCEPTED')) or
            ($aPaymorrowResponse['response_status'] !== 'OK')
        );
    }
200601
def validate(self):
        
        required_fields = list(filter(lambda x: self._fields[x], self._fields.keys()))
        for field in (self._top_fields + required_fields):
            if not hasattr(self, field) or hasattr(self, field) and getattr(self, field) == None:
                raise MissingFieldError(field)
1184556
def validate_payment_form(self):
        """"""
        warn_untested()
        form = self.payment_form_cls(self.request.POST)
        if form.is_valid():
            success = form.process(self.request, self.item)
            if success:
                return HttpResponseRedirect(self.success_url)
            else:
                self.context['errors'] = self.errors['processing']

        self.context[self.form_context_name] = form
        self.context.setdefault("errors", self.errors['form'])
        return TemplateResponse(self.request, self.payment_template, self.context)
977439
def validate_field(self, value):
        '''
        
        '''
        if self.choices:
            value = self.normalize_field(value)
            if value in self.choices:
                return None
            return _('Must be one of: %(choices)s') % {'choices': '; '.join(self.choices)}
        if self.default is not None:
            if value is None or value == '':
                value = self.default
        if self.required and (value is None or value == ''):
            return _('Required field')
666927
def _check_values(self, value):
        
        key = self.to_field_name or 'pk'
        # deduplicate given values to avoid creating many querysets or
        # requiring the database backend deduplicate efficiently.
        try:
            value = frozenset(value)
        except TypeError:
            # list of lists isn't hashable, for example
            raise ValidationError(
                self.error_messages['list'],
                code='list',
            )
        for pk in value:
            try:
                self.queryset.filter(**{key: pk})
            except (ValueError, TypeError):
                raise ValidationError(
                    self.error_messages['invalid_pk_value'],
                    code='invalid_pk_value',
                    params={'pk': pk},
                )
        qs = EventOccurrence.objects.filter(**{'%s__in' % key: value})
        pks = set(force_text(getattr(o, key)) for o in qs)
        for val in value:
            if force_text(val) not in pks:
                raise ValidationError(
                    self.error_messages['invalid_choice'],
                    code='invalid_choice',
                    params={'value': val},
                )
        return qs
7316
def valid?
      return false if @payment_id.nil?
      return false if @type.nil?
      type_validator = EnumAttributeValidator.new('String', ["FULL", "PARTIAL"])
      return false unless type_validator.valid?(@type)
      return false if @reason.nil?
      return true
    end
778383
def check_required_params(self):
        
        for param in self.REQUIRED_FIELDS:
            if param not in self.params:
                raise ValidationError("Missing parameter: {}".format(param))
848757
def validate_fields(self, **kwargs):
        
        for field in self.fields:
            value = kwargs[field]
            required_type = self.fields[field]
            if type(value) != required_type:
                raise TypeError('{}.{} needs to be a {}, recieved: {}({})'.format(
                    self.name,
                    field,
                    required_type.__name__,
                    type(value).__name__,
                    value.__repr__()))
1330043
def check(self):
        
        for k in iter(self.__dict__.keys()):
            if k not in self.__allowed:
                raise TypeError("Parameter not allowed {}".format(k))

        for k in self.__requiered:
            if k not in self.__dict__:
                raise TypeError("Requiered parameter not found {}".format(k))

        if not isinstance(self.units, (int, float)):
            msg = "Unit must be either int or float, '{}'' found".format(
                type(self.units))
            raise TypeError(msg)

        if self.side not in self.__side:
            msg = "Side must be in {1}, '{0}' found".format(
                self.side, self.__side)
            raise TypeError(msg)

        if self.type not in self.__type:
            msg = "Type must be in {1}, '{0}' found".format(
                self.type, self.__type)
            raise TypeError(msg)

        if not self.type == "market" and (
           not hasattr(self, "expiry") or not hasattr(self, "price")):
            msg = "As type is {}, expiry and price must be provided".format(
                self.type)
            raise TypeError(msg)
        if hasattr(self, "expiry") and not isinstance(self.expiry, datetime):
            msg = "Expiry must be {1}, '{0}' found".format(
                type(self.expiry), datetime)
            raise TypeError(msg)

        if hasattr(self, "price"):
            try:
                Decimal(self.price)
            except InvalidOperation:
                msg = "Expiry must be int or float, '{0}' found".format(
                    type(self.price))
                raise TypeError(msg)

        return True
1096368
protected function HasValidPaymentMethod()
    {
        $bHasValidPaymentMethod = false;
        $oPayment = $this->GetActivePaymentMethod();
        if (!is_null($oPayment) && $oPayment->IsAvailable()) {
            $bHasValidPaymentMethod = true;
        }

        return $bHasValidPaymentMethod;
    }
825041
private function validatePaymentMethodSpecific ()
	{
		$this->validate( 'paymentMethod' );
		switch ( $this->getPaymentMethod() ) {
			case 'ideal':
				$this->validate( 'issuer' );
				if ( $this->getCurrency() != 'EUR' )
					throw new InvalidRequestException( "Cardgate : iDeal only accepts EUR" );
				break;
			case 'mistercash':
				if ( $this->getCurrency() != 'EUR' )
					throw new InvalidRequestException( "Cardgate : Bancontact/Mistercash only accepts EUR" );
				break;
		}
	}
90116
def valid?
      return false if @id.nil?
      return false if @name.nil?
      return false if @type.nil?
      type_validator = EnumAttributeValidator.new('String', ['checking', 'savings', 'cash', 'creditCard', 'lineOfCredit', 'otherAsset', 'otherLiability', 'payPal', 'merchantAccount', 'investmentAccount', 'mortgage'])
      return false unless type_validator.valid?(@type)
      return false if @on_budget.nil?
      return false if @closed.nil?
      return false if @note.nil?
      return false if @balance.nil?
      return false if @cleared_balance.nil?
      return false if @uncleared_balance.nil?
      return false if @transfer_payee_id.nil?
      return false if @deleted.nil?
      true
    end
547343
def validate(self, request, value):
        
        if self.required and value == DEFAULT_FIELD_VALUE:
            return ValidationResult(is_success=False,
                                    reason='This field is required')
        if not self.nullable and value is None:
            return ValidationResult(is_success=False,
                                    reason='null is not a valid value')
        return ValidationResult(is_success=True)