class PayBoutique::PaymentDetails::Params

Constants

BODY_TYPE
IDS
VERSION

Private Class Methods

params() click to toggle source
# File lib/pay_boutique/payment_details.rb, line 57
def params
  required_params
end
required_params() click to toggle source
# File lib/pay_boutique/payment_details.rb, line 47
def required_params
  configs = Config::CONFIGS + IDS

  if PayBoutique.configuration.qiwi_postback_url || PayBoutique.configuration.credit_card_postback_url
    configs.delete(:postback_url)
  end

  configs
end

Public Instance Methods

to_xml() click to toggle source
# File lib/pay_boutique/payment_details.rb, line 11
def to_xml
  @xml = Nokogiri::XML::Builder.new do |root|
    root.Message(version: VERSION) do |xml|
      xml.Header do |header|
        header.Identity do |identity|
          identity.UserID user_id
          identity.Signature Signature.create(time)
        end
        header.Time time
      end

      xml.Body(type: BODY_TYPE) do |body|
        body.Order do |order|
          order.OrderID order_id if try(:order_id)
          order.ReferenceID reference_id if try(:reference_id)
        end
      end
    end
  end
  @xml
end

Private Instance Methods

missed_only_one_id() click to toggle source
# File lib/pay_boutique/payment_details.rb, line 42
def missed_only_one_id
  @missed_params.size == 1 && IDS.include?(@missed_params.first)
end
verify_params() click to toggle source
# File lib/pay_boutique/payment_details.rb, line 35
def verify_params
  @missed_params = self.class.required_params - (existing_params & self.class.required_params)
  return if @missed_params.empty? || missed_only_one_id

  raise ArgumentError, "wrong arguments, missed: #{@missed_params.map(&:inspect).join(', ')}"
end