Class: ActiveMerchant::Billing::Integrations::PayuIn::Notification

Inherits:
Notification
  • Object
show all
Defined in:
lib/active_merchant/payu_in/notification.rb

Instance Method Summary collapse

Instance Method Details

#accountObject

Merchant Id provided by the PayU.in



73
74
75
# File 'lib/active_merchant/payu_in/notification.rb', line 73

def 
  params['key']
end

#amount_ok?(order_amount, order_discount = BigDecimal.new( '0.0' )) ⇒ Boolean

Order amount should be equal to gross - discount

Returns:

  • (Boolean)


35
36
37
# File 'lib/active_merchant/payu_in/notification.rb', line 35

def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )
  BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount ) == order_discount
end

#checksumObject



131
132
133
# File 'lib/active_merchant/payu_in/notification.rb', line 131

def checksum
  params['hash']
end

#checksum_ok?Boolean

Returns:

  • (Boolean)


139
140
141
142
143
144
145
146
147
# File 'lib/active_merchant/payu_in/notification.rb', line 139

def checksum_ok?
  fields = user_defined.dup.push( customer_email, customer_first_name, product_info, gross, invoice, :reverse => true )
  fields.unshift( transaction_status )
  unless PayuIn.checksum( *fields ) == checksum
    @message = 'Return checksum not matching the data provided'
    return false
  end
  return true
end

#complete?Boolean

Was the transaction complete?

Returns:

  • (Boolean)


8
9
10
# File 'lib/active_merchant/payu_in/notification.rb', line 8

def complete?
  status == "success"
end

#currencyObject

What currency have we been dealing with



63
64
65
# File 'lib/active_merchant/payu_in/notification.rb', line 63

def currency
  'INR'
end

#customer_addressObject

Full address of the customer



118
119
120
121
122
# File 'lib/active_merchant/payu_in/notification.rb', line 118

def customer_address
  { :address1 => params['address1'], :address2 => params['address2'],
    :city => params['city'], :state => params['state'],
    :country => params['country'], :zipcode => params['zipcode'] }
end

#customer_emailObject

Email of the customer



98
99
100
# File 'lib/active_merchant/payu_in/notification.rb', line 98

def customer_email
  params['email']
end

#customer_first_nameObject

Firstname of the customer



108
109
110
# File 'lib/active_merchant/payu_in/notification.rb', line 108

def customer_first_name
  params['firstname']
end

#customer_last_nameObject

Lastname of the customer



113
114
115
# File 'lib/active_merchant/payu_in/notification.rb', line 113

def customer_last_name
  params['lastname']
end

#customer_phoneObject

Phone of the customer



103
104
105
# File 'lib/active_merchant/payu_in/notification.rb', line 103

def customer_phone
  params['phone']
end

#discountObject

This is discount given to user - based on promotion set by merchants.



83
84
85
# File 'lib/active_merchant/payu_in/notification.rb', line 83

def discount
  params['discount']
end

#grossObject

original amount send by merchant



78
79
80
# File 'lib/active_merchant/payu_in/notification.rb', line 78

def gross
  params['amount']
end

#invoiceObject

This is the invoice which you passed to PayU.in



68
69
70
# File 'lib/active_merchant/payu_in/notification.rb', line 68

def invoice
  params['txnid']
end

#invoice_ok?(order_id) ⇒ Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/active_merchant/payu_in/notification.rb', line 30

def invoice_ok?( order_id )
  order_id.to_s == invoice.to_s
end

#messageObject



135
136
137
# File 'lib/active_merchant/payu_in/notification.rb', line 135

def message
  @message || params['error']
end

#offer_descriptionObject

Description offer for what PayU given the offer to user - based on promotion set by merchants.



88
89
90
# File 'lib/active_merchant/payu_in/notification.rb', line 88

def offer_description
  params['offer']
end

#product_infoObject

Information about the product as send by merchant



93
94
95
# File 'lib/active_merchant/payu_in/notification.rb', line 93

def product_info
  params['productinfo']
end

#statusObject

Status of the transaction. List of possible values:

invalid

transaction id is not present

tampered

transaction data has been tampered

success

transaction successful

pending

transaction is pending for some approval

failure

transaction failure



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/active_merchant/payu_in/notification.rb', line 18

def status
  @status ||= if checksum_ok?
    if transaction_id.blank?
      'invalid'
    else
      transaction_status.downcase
    end
  else
    'tampered'
  end.freeze
end

#transaction_idObject

ID of this transaction (PayU.in number)



48
49
50
# File 'lib/active_merchant/payu_in/notification.rb', line 48

def transaction_id
  params['mihpayid']
end

#transaction_statusObject

Status of transaction return from the PayU. List of possible values:

SUCCESS
PENDING
FAILURE


43
44
45
# File 'lib/active_merchant/payu_in/notification.rb', line 43

def transaction_status
  params['status']
end

#typeObject

Mode of Payment

‘CC’ for credit-card ‘NB’ for net-banking ‘CD’ for cheque or DD ‘CO’ for Cash Pickup



58
59
60
# File 'lib/active_merchant/payu_in/notification.rb', line 58

def type
  params['mode']
end

#user_definedObject



124
125
126
127
128
129
# File 'lib/active_merchant/payu_in/notification.rb', line 124

def user_defined
  return @user_defined if @user_defined
  @user_defined = []
  10.times{ |i| @user_defined.push( params[ "udf#{i+1}" ] ) }
  @user_defined
end