Sha256: 66e4f5ed41b6780a4e112fa07be66869626527aa6ec7abc70a5f148ce8353901

Contents?: true

Size: 895 Bytes

Versions: 2

Compression:

Stored size: 895 Bytes

Contents

module WebToPayHelper
  def webtopay_confirm_button(text, params_or_payment, button_options = {}, form_options = {})
    fields = { :lang => 'LIT', :currency => 'LTL', :projectid => WebToPay.config.project_id, :test => 0 }

    if params_or_payment.is_a?(Hash)
      fields = fields.merge(params_or_payment)
      payment = WebToPay::Payment.new(fields, sign_password: WebToPay.config.sign_password)
    else
      payment = params_or_payment
      fields.each_pair do |field, value|
        payment.public_send("#{field}=", value) if payment.public_send(field).nil?
      end
    end

    content_tag(:form, {action: 'https://www.mokejimai.lt/pay/', method: :post}.merge(form_options)) do
      html = ''
      html << hidden_field_tag(:data, payment.data)
      html << hidden_field_tag(:sign, payment.sign)
      html << submit_tag(text, button_options)
      html.html_safe
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
webtopay-1.6.1 lib/webtopay_helper.rb
webtopay-1.6.0 lib/webtopay_helper.rb