class PayBoutique::PaymentGateway::Params

Constants

BODY_TYPE
VERSION

Private Class Methods

params() click to toggle source
# File lib/pay_boutique/payment_gateway.rb, line 66
def params
  %i[
    user_id buyer_currency merchant_currency amount_merchant_currency
    merchant_id order_id expiration_time description merchant_reference
    label product_name site_address payment_method first_name middle_name
    last_name address city country account_id success_url failure_url
    credit_card_postback_url qiwi_postback_url
  ]
end
required_params() click to toggle source
# File lib/pay_boutique/payment_gateway.rb, line 56
def required_params
  configs = Config::CONFIGS + %i[payment_method order_id amount_merchant_currency]

  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_gateway.rb, line 9
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, live: PayBoutique.configuration.live) do |body|
        body.Order(paymentMethod: payment_method_camelize, buyerCurrency: buyer_currency) do |order|
          order.MerchantID merchant_id
          order.OrderID order_id
          order.AmountMerchantCurrency amount_merchant_currency
          order.MerchantCurrency merchant_currency
          order.ExpirationTime expiration_time if try(:expiration_time)
          order.Label label if try(:label)
          order.SiteAddress site_address
          order.Description description if try(:description)
          order.SuccessURL success_url if try(:success_url)
          order.FailureURL failure_url if try(:failure_url)
          order.PostbackUrl postback_url
          order.Buyer do |buyer|
            buyer.FirstName first_name if try(:first_name)
            buyer.MiddleName middle_name if try(:middle_name)
            buyer.LastName last_name if try(:last_name)
            buyer.Address address if try(:address)
            buyer.City city if try(:city)
            buyer.Country country if try(:country)
            buyer.AccountID account_id if try(:account_id)
          end
        end
      end
    end
  end
  @xml
end

Private Instance Methods

payment_method_camelize() click to toggle source
# File lib/pay_boutique/payment_gateway.rb, line 51
def payment_method_camelize
  payment_method.to_s.camelize
end