Class: ActiveMerchant::Billing::Integrations::PayuIn::Return

Inherits:
Return
  • Object
show all
Defined in:
lib/active_merchant/billing/integrations/payu_in/return.rb

Instance Attribute Summary

Attributes inherited from Return

#notification, #params

Instance Method Summary collapse

Methods inherited from Return

#cancelled?, #parse

Constructor Details

#initialize(query_string, options = {}) ⇒ Return

Returns a new instance of Return.



7
8
9
10
# File 'lib/active_merchant/billing/integrations/payu_in/return.rb', line 7

def initialize(query_string, options = {})
  super
  @notification = Notification.new(query_string, options)
end

Instance Method Details

#messageObject



45
46
47
# File 'lib/active_merchant/billing/integrations/payu_in/return.rb', line 45

def message
  @notification.message
end

#status(order_id, order_amount) ⇒ Object

Returns the status of the transaction as a string The status can be one of the following

invalid - transaction id not present tampered - checksum does not mismatch mismatch - order id mismatch success - transaction success pending - transaction pending failure - transaction failure

payu does not put the discount field in the checksum it can be easily forged by the attacker without detection



31
32
33
34
35
36
37
# File 'lib/active_merchant/billing/integrations/payu_in/return.rb', line 31

def status( order_id, order_amount )
  if @notification.invoice_ok?( order_id ) && @notification.amount_ok?( BigDecimal.new(order_amount) )
    @notification.status
  else
    'mismatch'
  end
end

#success?Boolean

check success of the transaction check order_id and

Returns:

  • (Boolean)


41
42
43
# File 'lib/active_merchant/billing/integrations/payu_in/return.rb', line 41

def success?
  status( @params['txnid'], @params['amount'] ) == 'success'
end

#transaction_idObject

PayU Transaction Id



14
15
16
# File 'lib/active_merchant/billing/integrations/payu_in/return.rb', line 14

def transaction_id
  @notification.transaction_id
end