module OpenPayU
Constants
- VERSION
Public Class Methods
hosted_order_form(order)
click to toggle source
Generate a form body for hosted order
@param [Hash] order Hash @return [String] A full form containign an order
# File lib/openpayu.rb, line 51 def self.hosted_order_form(order) @order = Models::Order.new(order) render_hash = @order.to_flatten_hash html_form = "<form method='post' " + "action='#{Configuration.get_base_url}order'>\n" render_hash.each do |key, value| html_form << "<input type='hidden' name='#{key}' value='#{value}' />\n" end html_form << "<input type='hidden' name='OpenPayu-Signature' value='#{sign_form(render_hash)}' /> <button type='submit' formtarget='_blank' />\n</form>" end
sign_form(form_fields, key = nil, algorithm = nil, pos_id = nil)
click to toggle source
Generate a signature for signing form sent directly to PayU
@param [Hash] form_fields Hash with all form fields with values @param [String] signature_key defaults to Configuration.signature_key
@param [String] algorithm defaults to OpenPayU::Configuration.algorithm
@param [String] merchant_pos_id defaults to Configuration.merchant_pos_id
@return [String] Signature that should be inserted to field
with name "OpenPayu-Signature"
# File lib/openpayu.rb, line 37 def self.sign_form(form_fields, key = nil, algorithm = nil, pos_id = nil) sorted_values = form_fields.sort.map { |array| array[1] }.join Document.new.generate_signature_structure( sorted_values, algorithm || Configuration.algorithm, pos_id || Configuration.merchant_pos_id, key || Configuration.signature_key ) end