class PayuIndia::Notification
Public Class Methods
new(post, options = {})
click to toggle source
# File lib/payuindia.rb, line 56 def initialize(post, options = {}) @key = options[:key] @salt = options[:salt] @params = options[:params] end
Public Instance Methods
account()
click to toggle source
Merchant Id provided by the PayU.in
# File lib/payuindia.rb, line 129 def account params['key'] end
acknowledge(authcode = nil)
click to toggle source
# File lib/payuindia.rb, line 192 def acknowledge(authcode = nil) checksum_ok? end
amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) )
click to toggle source
Order amount should be equal to gross - discount
# File lib/payuindia.rb, line 91 def amount_ok?( order_amount, order_discount = BigDecimal.new( '0.0' ) ) BigDecimal.new( gross ) == order_amount && BigDecimal.new( discount.to_s ) == order_discount end
checksum()
click to toggle source
# File lib/payuindia.rb, line 184 def checksum params['hash'] end
checksum_ok?()
click to toggle source
# File lib/payuindia.rb, line 196 def checksum_ok? checksum_fields = [transaction_status, *user_defined.reverse, customer_email, customer_first_name, product_info, gross, invoice] unless Digest::SHA512.hexdigest([@salt, *checksum_fields, @key].join("|")) == checksum @message = 'Return checksum not matching the data provided' return false end true end
complete?()
click to toggle source
# File lib/payuindia.rb, line 62 def complete? status == "Completed" end
currency()
click to toggle source
What currency have we been dealing with
# File lib/payuindia.rb, line 119 def currency 'INR' end
customer_address()
click to toggle source
Full address of the customer
# File lib/payuindia.rb, line 174 def customer_address { :address1 => params['address1'], :address2 => params['address2'], :city => params['city'], :state => params['state'], :country => params['country'], :zipcode => params['zipcode'] } end
customer_email()
click to toggle source
Email of the customer
# File lib/payuindia.rb, line 154 def customer_email params['email'] end
customer_first_name()
click to toggle source
Firstname of the customer
# File lib/payuindia.rb, line 164 def customer_first_name params['firstname'] end
customer_last_name()
click to toggle source
Lastname of the customer
# File lib/payuindia.rb, line 169 def customer_last_name params['lastname'] end
customer_phone()
click to toggle source
Phone of the customer
# File lib/payuindia.rb, line 159 def customer_phone params['phone'] end
discount()
click to toggle source
This is discount given to user - based on promotion set by merchants.
# File lib/payuindia.rb, line 139 def discount params['discount'] end
gross()
click to toggle source
original amount send by merchant
# File lib/payuindia.rb, line 134 def gross params['amount'] end
invoice()
click to toggle source
This is the invoice which you passed to PayU.in
# File lib/payuindia.rb, line 124 def invoice params['txnid'] end
invoice_ok?( order_id )
click to toggle source
# File lib/payuindia.rb, line 86 def invoice_ok?( order_id ) order_id.to_s == invoice.to_s end
message()
click to toggle source
# File lib/payuindia.rb, line 188 def message @message || "#{params['error']} - #{params['error_Message']}" end
offer_description()
click to toggle source
Description offer for what PayU given the offer to user - based on promotion set by merchants.
# File lib/payuindia.rb, line 144 def offer_description params['offer'] end
params()
click to toggle source
# File lib/payuindia.rb, line 66 def params @params end
product_info()
click to toggle source
Information about the product as send by merchant
# File lib/payuindia.rb, line 149 def product_info params['productinfo'] end
status()
click to toggle source
# File lib/payuindia.rb, line 70 def status @status ||= if checksum_ok? if transaction_id.blank? 'Invalid' else case transaction_status.downcase when 'success' then 'Completed' when 'failure' then 'Failed' when 'pending' then 'Pending' end end else 'Tampered' end end
transaction_id()
click to toggle source
ID of this transaction (PayU.in number)
# File lib/payuindia.rb, line 104 def transaction_id params['mihpayid'] end
transaction_status()
click to toggle source
Status of transaction return from the PayU. List of possible values:
SUCCESS
PENDING
FAILURE
# File lib/payuindia.rb, line 99 def transaction_status params['status'] end
type()
click to toggle source
Mode of Payment
'CC' for credit-card 'NB' for net-banking 'CD' for cheque or DD 'CO' for Cash Pickup
# File lib/payuindia.rb, line 114 def type params['mode'] end
user_defined()
click to toggle source
# File lib/payuindia.rb, line 180 def user_defined @user_defined ||= 10.times.map { |i| params["udf#{i + 1}"] } end