Module: OffsitePayments::Integrations::Newebpay::HasTradeInfo
- Included in:
- Notification, Return
- Defined in:
- lib/offsite_payments/integrations/newebpay/concern/has_trade_info.rb
Overview
The shared module for return and notification object
Instance Method Summary collapse
-
#checksum ⇒ String
The TradeSha calculated in client-side.
-
#trade_info ⇒ Hash
Trade Information from NewebPay.
-
#valid? ⇒ TrueClass|FalseClass
Does TradeInfo is valid.
Instance Method Details
#checksum ⇒ String
The TradeSha calculated in client-side
27 28 29 30 31 32 33 |
# File 'lib/offsite_payments/integrations/newebpay/concern/has_trade_info.rb', line 27 def checksum @checksum ||= Digest::SHA256 .hexdigest("HashKey=#{::Newebpay::Config.hash_key}&" \ "#{params['TradeInfo']}&HashIV=#{::Newebpay::Config.hash_iv}") .upcase end |
#trade_info ⇒ Hash
Trade Information from NewebPay
15 16 17 18 19 20 |
# File 'lib/offsite_payments/integrations/newebpay/concern/has_trade_info.rb', line 15 def trade_info @trade_info ||= JSON.parse(::Newebpay::Cipher.decrypt(params['TradeInfo'])) rescue JSON::ParserError, TypeError {} end |
#valid? ⇒ TrueClass|FalseClass
Does TradeInfo is valid
40 41 42 |
# File 'lib/offsite_payments/integrations/newebpay/concern/has_trade_info.rb', line 40 def valid? checksum == params['TradeSha'] end |