Sha256: ac060f4674b92df4abc97e60eeb9473cd0ffa7312868155a36ffc7f31f271072
Contents?: true
Size: 972 Bytes
Versions: 2
Compression:
Stored size: 972 Bytes
Contents
module JdPay module Util class << self def to_xml(params, options = {}) options[:root] = options[:root] || 'jdpay' denilize(params).to_xml(options).gsub(/>[[:space:]]+/, ">") end def to_uri(params) params.sort.map do |k, v| "#{k}=#{v}" end.compact.join('&') end def denilize(h) h.each_with_object({}) { | (k, v), g | g[k] = (Hash === v) ? denilize(v) : v ? v : '' } end def build_pay_form(url, form_attributes) inputs = '' "<html> <body onload=document.getElementById('payForm').submit(); style='display: none;'> <form action=#{url} method='post' id='payForm'> #{form_attributes.each do |k, v| inputs << "<input type='text' name=#{k} value=#{v}>" end and inputs} </form> </body> </html>".gsub(/>[[:space:]]+/, ">") end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
jdpay-0.1.2 | lib/jd_pay/util.rb |
jdpay-0.1.1 | lib/jd_pay/util.rb |