Sha256: aedcd1a29b071d980cf04c9b25224fa6c4ef74e7ffe1d65e694941a4f26b68d4

Contents?: true

Size: 1.54 KB

Versions: 45

Compression:

Stored size: 1.54 KB

Contents

module ActiveMerchant #:nodoc:
  module Billing #:nodoc:
    module Integrations #:nodoc:
      module Liqpay
        class Helper < ActiveMerchant::Billing::Integrations::Helper
          def initialize(order, account, options = {})
            @secret = options.delete(:secret)
            super

            add_field 'version', '1.2'
          end

          def form_fields
            xml = "<request>
              <version>1.2</version>
              <result_url>#{@fields["result_url"]}</result_url>
              <server_url>#{@fields["server_url"]}</server_url>
              <merchant_id>#{@fields["merchant_id"]}</merchant_id>
              <order_id>#{@fields["order_id"]}</order_id>
              <amount>#{@fields["amount"]}</amount>
              <currency>#{@fields["currency"]}</currency>
              <description>#{@fields["description"]}</description>
              <default_phone>#{@fields["default_phone"]}</default_phone>
              <pay_way>card</pay_way>
              </request>".strip
            sign = Base64.encode64(Digest::SHA1.digest("#{@secret}#{xml}#{@secret}")).strip
            {"operation_xml" => Base64.encode64(xml), "signature" => sign}
          end

          mapping :account, 'merchant_id'
          mapping :amount, 'amount'
          mapping :currency, 'currency'
          mapping :order, 'order_id'
          mapping :description, 'description'
          mapping :phone, 'default_phone'

          mapping :notify_url, 'server_url'
          mapping :return_url, 'result_url'
        end
      end
    end
  end
end

Version data entries

45 entries across 45 versions & 3 rubygems

Version Path
tanga_activemerchant-1.38.0.5 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.38.0.4 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.38.0.3 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.38.0.2 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.38.0.1 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.38.0 lib/active_merchant/billing/integrations/liqpay/helper.rb
tanga_activemerchant-1.37.0 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.43.3 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.43.1 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.43.0 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.9 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.8 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.7 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.6 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.5 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.4 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.3 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.2 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.1 lib/active_merchant/billing/integrations/liqpay/helper.rb
activemerchant-1.42.0 lib/active_merchant/billing/integrations/liqpay/helper.rb