Sha256: b0aeb4f8a147b2cd10c5a42800c68a2b094a39bd8d4768a41374a39f072bd0c5

Contents?: true

Size: 1.42 KB

Versions: 5

Compression:

Stored size: 1.42 KB

Contents

module Opay
  module Helpers

    module PayuHelper

      def payu_form_for(record, options = {}, &block)
        record.prepare_payment

        options[:builder] ||= Opay::FormBuilder
        options[:url]  = Opay::Providers::Payu.url(:new_payment)
        options[:html] = { id: "payu_payment_form_#{record.id}", class: 'payu_payment_form' }

        form_for(record, options, &block)
      end

      def payu_payment_info(options = {})
        options[:first_name]   ||= object.first_name
        options[:last_name]    ||= object.last_name
        options[:email]        ||= object.email

        options[:pos_id]       ||= Opay.config.pos_id
        options[:pos_auth_key] ||= Opay.config.pos_auth_key
        options[:session_id]   ||= object.payment_session_id

        options[:amount]       ||= object.amount
        options[:desc]         ||= object.payment_description
        options[:client_ip]    ||= @template.request.remote_ip
        options[:js]             = 0

        options[:pay_type]       = 't' if Opay.config.test_mode
        options[:ts]             = Time.now.to_i.to_s
        options[:sig]            = Providers::Payu.create_form_sig(options)

        fields = options.map { |key, val| @template.hidden_field_tag(key, val) }.join("\n")
        js = "<script type=\"text/javascript\">document.forms['payu_payment_form_#{object.id}'].js.value = 1;</script>"

        "#{fields}\n#{js}".html_safe
      end

    end

  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
opay-1.1.6 lib/opay/helpers/payu_helper.rb
opay-1.1.5 lib/opay/helpers/payu_helper.rb
opay-1.1.4 lib/opay/helpers/payu_helper.rb
opay-1.1.3 lib/opay/helpers/payu_helper.rb
opay-1.1.2 lib/opay/helpers/payu_helper.rb