Class: ActiveMerchant::Billing::Integrations::PayuIn::Notification
- Inherits:
-
Notification
- Object
- Notification
- ActiveMerchant::Billing::Integrations::PayuIn::Notification
- Defined in:
- lib/active_merchant/billing/integrations/payu_in/notification.rb
Direct Known Subclasses
ActiveMerchant::Billing::Integrations::PayuInPaisa::Notification
Instance Attribute Summary
Attributes inherited from Notification
Instance Method Summary collapse
-
#account ⇒ Object
Merchant Id provided by the PayU.in.
- #acknowledge(authcode = nil) ⇒ Object
-
#amount_ok?(order_amount, order_discount = BigDecimal.new( '0.0' )) ⇒ Boolean
Order amount should be equal to gross - discount.
- #checksum ⇒ Object
- #checksum_ok? ⇒ Boolean
- #complete? ⇒ Boolean
-
#currency ⇒ Object
What currency have we been dealing with.
-
#customer_address ⇒ Object
Full address of the customer.
-
#customer_email ⇒ Object
Email of the customer.
-
#customer_first_name ⇒ Object
Firstname of the customer.
-
#customer_last_name ⇒ Object
Lastname of the customer.
-
#customer_phone ⇒ Object
Phone of the customer.
-
#discount ⇒ Object
This is discount given to user - based on promotion set by merchants.
-
#gross ⇒ Object
original amount send by merchant.
-
#initialize(post, options = {}) ⇒ Notification
constructor
A new instance of Notification.
-
#invoice ⇒ Object
This is the invoice which you passed to PayU.in.
- #invoice_ok?(order_id) ⇒ Boolean
- #item_id ⇒ Object
- #message ⇒ Object
-
#offer_description ⇒ Object
Description offer for what PayU given the offer to user - based on promotion set by merchants.
-
#product_info ⇒ Object
Information about the product as send by merchant.
- #status ⇒ Object
-
#transaction_id ⇒ Object
ID of this transaction (PayU.in number).
-
#transaction_status ⇒ Object
Status of transaction return from the PayU.
-
#type ⇒ Object
Mode of Payment.
- #user_defined ⇒ Object
Methods inherited from Notification
#amount, #empty!, #gross_cents, #test?, #valid_sender?
Constructor Details
#initialize(post, options = {}) ⇒ Notification
Returns a new instance of Notification.
7 8 9 10 11 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 7 def initialize(post, = {}) super(post, ) @merchant_id = [:credential1] @secret_key = [:credential2] end |
Instance Method Details
#account ⇒ Object
Merchant Id provided by the PayU.in
72 73 74 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 72 def account params['key'] end |
#acknowledge(authcode = nil) ⇒ Object
135 136 137 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 135 def acknowledge(authcode = nil) checksum_ok? end |
#amount_ok?(order_amount, order_discount = BigDecimal.new( '0.0' )) ⇒ Boolean
Order amount should be equal to gross - discount
30 31 32 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 30 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 ⇒ Object
127 128 129 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 127 def checksum params['hash'] end |
#checksum_ok? ⇒ Boolean
139 140 141 142 143 144 145 146 147 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 139 def checksum_ok? checksum_fields = [transaction_status, *user_defined.reverse, customer_email, customer_first_name, product_info, 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? ⇒ Boolean
13 14 15 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 13 def complete? status == "Completed" end |
#currency ⇒ Object
What currency have we been dealing with
58 59 60 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 58 def currency 'INR' end |
#customer_address ⇒ Object
Full address of the customer
117 118 119 120 121 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 117 def customer_address { :address1 => params['address1'], :address2 => params['address2'], :city => params['city'], :state => params['state'], :country => params['country'], :zipcode => params['zipcode'] } end |
#customer_email ⇒ Object
Email of the customer
97 98 99 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 97 def customer_email params['email'] end |
#customer_first_name ⇒ Object
Firstname of the customer
107 108 109 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 107 def customer_first_name params['firstname'] end |
#customer_last_name ⇒ Object
Lastname of the customer
112 113 114 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 112 def customer_last_name params['lastname'] end |
#customer_phone ⇒ Object
Phone of the customer
102 103 104 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 102 def customer_phone params['phone'] end |
#discount ⇒ Object
This is discount given to user - based on promotion set by merchants.
82 83 84 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 82 def discount params['discount'] end |
#gross ⇒ Object
original amount send by merchant
77 78 79 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 77 def gross params['amount'] end |
#invoice ⇒ Object
This is the invoice which you passed to PayU.in
67 68 69 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 67 def invoice params['txnid'] end |
#invoice_ok?(order_id) ⇒ Boolean
25 26 27 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 25 def invoice_ok?( order_id ) order_id.to_s == invoice.to_s end |
#item_id ⇒ Object
62 63 64 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 62 def item_id params['txnid'] end |
#message ⇒ Object
131 132 133 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 131 def @message || params['error'] end |
#offer_description ⇒ Object
Description offer for what PayU given the offer to user - based on promotion set by merchants.
87 88 89 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 87 def offer_description params['offer'] end |
#product_info ⇒ Object
Information about the product as send by merchant
92 93 94 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 92 def product_info params['productinfo'] end |
#status ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 17 def status case transaction_status.downcase when 'success' then 'Completed' when 'failure' then 'Failed' when 'pending' then 'Pending' end end |
#transaction_id ⇒ Object
ID of this transaction (PayU.in number)
43 44 45 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 43 def transaction_id params['mihpayid'] end |
#transaction_status ⇒ Object
Status of transaction return from the PayU. List of possible values:
SUCCESS
PENDING
FAILURE
38 39 40 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 38 def transaction_status params['status'] end |
#type ⇒ Object
Mode of Payment
‘CC’ for credit-card ‘NB’ for net-banking ‘CD’ for cheque or DD ‘CO’ for Cash Pickup
53 54 55 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 53 def type params['mode'] end |
#user_defined ⇒ Object
123 124 125 |
# File 'lib/active_merchant/billing/integrations/payu_in/notification.rb', line 123 def user_defined @user_defined ||= 10.times.map { |i| params["udf#{i + 1}"] } end |