Module: ActiveMerchant::Billing::Integrations::PayuIn

Defined in:
lib/active_merchant_payu_in.rb,
lib/active_merchant/payu_in/helper.rb,
lib/active_merchant/payu_in/return.rb,
lib/active_merchant/payu_in/version.rb,
lib/active_merchant/payu_in/web_service.rb,
lib/active_merchant/payu_in/notification.rb

Defined Under Namespace

Modules: VERSION Classes: Helper, Notification, Return, WebService

Class Method Summary collapse

Class Method Details

.checksum(*payload_items) ⇒ Object



75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/active_merchant_payu_in.rb', line 75

def self.checksum( *payload_items )
  options = payload_items.pop if Hash === payload_items.last
  options ||= {}
  payload = if options[:reverse] then
    payload_items.dup.push( self.merchant_id || "" ).unshift( self.secret_key || "" ).collect{ |x| trim(x) }.join("|")
  else
    payload_items.dup.unshift( self.merchant_id || "" ).push( self.secret_key || "" ).collect{ |x| trim(x) }.join("|")
  end
  if options[:debug]
    puts "-"*80
    puts payload
    puts "-"*80
  end
  Digest::SHA512.hexdigest( payload )
end

.new(options = {}) ⇒ Object



36
37
38
39
40
# File 'lib/active_merchant_payu_in.rb', line 36

def self.new( options = {} )
  self.merchant_id = options[:merchant_id]
  self.secret_key = options[:secret_key]
  self
end

.query(command, *args) ⇒ Object

Query the PayU server using there web services



67
68
69
# File 'lib/active_merchant_payu_in.rb', line 67

def self.query( command, *args )
  WebService.send( command, *args )
end

.return(query_string, options = {}) ⇒ Object



71
72
73
# File 'lib/active_merchant_payu_in.rb', line 71

def self.return(query_string, options = {})
  Return.new(query_string, options)
end

.service_urlObject



42
43
44
45
46
47
48
49
50
51
52
# File 'lib/active_merchant_payu_in.rb', line 42

def self.service_url
  mode = ActiveMerchant::Billing::Base.integration_mode
  case mode
  when :production
    self.production_url
  when :test
    self.test_url
  else
    raise StandardError, "Integration mode set to an invalid value: #{mode}"
  end
end

.trim(obj) ⇒ Object

PayU uses php trim when building the string to compute the checksum trim removes whitespaces from start and end of the string and floats cannot have trailing zeros



94
95
96
97
98
99
100
101
# File 'lib/active_merchant_payu_in.rb', line 94

def self.trim(obj)
  # if (BigDecimal === obj)
  #   obj.to_s('F')
  # else
  #   obj.to_s
  # end.strip.gsub(/(\\d+)\\.0$/){ $1 }.gsub(/(\\d+)(\\.[1-9]+)0+$/){ $1+$2 }
  obj.to_s
end

.versionObject



5
6
7
# File 'lib/active_merchant/payu_in/version.rb', line 5

def self.version
  VERSION
end

.web_service_urlObject



54
55
56
57
58
59
60
61
62
63
64
# File 'lib/active_merchant_payu_in.rb', line 54

def self.web_service_url
  mode = ActiveMerchant::Billing::Base.integration_mode
  case mode
  when :production
    self.production_web_service_url
  when :test
    self.test_web_service_url
  else
    raise StandardError, "Integration mode set to an invalid value: #{mode}"
  end
end