class OffsitePayments::Integrations::PayuIn::Notification
Public Class Methods
new(post, options = {})
click to toggle source
Calls superclass method
OffsitePayments::Notification::new
# File lib/offsite_payments/integrations/payu_in.rb, line 97 def initialize(post, options = {}) super(post, options) @merchant_id = options[:credential1] @secret_key = options[:credential2] end
Public Instance Methods
account()
click to toggle source
Merchant Id provided by the PayU.in
# File lib/offsite_payments/integrations/payu_in.rb, line 162 def account params['key'] end
acknowledge(authcode = nil)
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 229 def acknowledge(authcode = nil) checksum_ok? end
amount_ok?( order_amount, order_discount = BigDecimal( '0.0' ) )
click to toggle source
Order amount should be equal to gross - discount
# File lib/offsite_payments/integrations/payu_in.rb, line 119 def amount_ok?( order_amount, order_discount = BigDecimal( '0.0' ) ) parsed_discount = discount.nil? ? 0.to_d : discount.to_d BigDecimal( original_gross ) == order_amount && parsed_discount == order_discount end
checksum()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 221 def checksum params['hash'] end
checksum_ok?()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 233 def checksum_ok? checksum_fields = [transaction_status, *user_defined.reverse, customer_email, customer_first_name, product_info, original_gross, invoice] unless Digest::SHA512.hexdigest([@secret_key, *checksum_fields, @merchant_id].join("|")) == checksum @message = 'Return checksum not matching the data provided' return false end true end
complete?()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 103 def complete? status == "Completed" end
currency()
click to toggle source
What currency have we been dealing with
# File lib/offsite_payments/integrations/payu_in.rb, line 148 def currency 'INR' end
customer_address()
click to toggle source
Full address of the customer
# File lib/offsite_payments/integrations/payu_in.rb, line 211 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/offsite_payments/integrations/payu_in.rb, line 191 def customer_email params['email'] end
customer_first_name()
click to toggle source
Firstname of the customer
# File lib/offsite_payments/integrations/payu_in.rb, line 201 def customer_first_name params['firstname'] end
customer_last_name()
click to toggle source
Lastname of the customer
# File lib/offsite_payments/integrations/payu_in.rb, line 206 def customer_last_name params['lastname'] end
customer_phone()
click to toggle source
Phone of the customer
# File lib/offsite_payments/integrations/payu_in.rb, line 196 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/offsite_payments/integrations/payu_in.rb, line 176 def discount params['discount'] end
gross()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 171 def gross parse_and_round_gross_amount(params['amount']) end
invoice()
click to toggle source
This is the invoice which you passed to PayU.in
# File lib/offsite_payments/integrations/payu_in.rb, line 157 def invoice params['txnid'] end
invoice_ok?( order_id )
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 114 def invoice_ok?( order_id ) order_id.to_s == invoice.to_s end
item_id()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 152 def item_id params['txnid'] end
message()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 225 def message @message || params['error'] 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/offsite_payments/integrations/payu_in.rb, line 181 def offer_description params['offer'] end
original_gross()
click to toggle source
original amount send by merchant
# File lib/offsite_payments/integrations/payu_in.rb, line 167 def original_gross params['amount'] end
product_info()
click to toggle source
Information about the product as send by merchant
# File lib/offsite_payments/integrations/payu_in.rb, line 186 def product_info params['productinfo'] end
status()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 107 def status case transaction_status.downcase when 'success' then 'Completed' else 'Failed' end end
transaction_id()
click to toggle source
ID of this transaction (PayU.in number)
# File lib/offsite_payments/integrations/payu_in.rb, line 133 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/offsite_payments/integrations/payu_in.rb, line 128 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/offsite_payments/integrations/payu_in.rb, line 143 def type params['mode'] end
user_defined()
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 217 def user_defined @user_defined ||= 10.times.map { |i| params["udf#{i + 1}"] } end
Private Instance Methods
parse_and_round_gross_amount(amount)
click to toggle source
# File lib/offsite_payments/integrations/payu_in.rb, line 244 def parse_and_round_gross_amount(amount) rounded_amount = (amount.to_f * 100.0).round sprintf("%.2f", rounded_amount / 100.00) end