class OffsitePayments::Integrations::Pay2go::Notification
Constants
- PARAMS_FIELDS
- TRADE_INFO_FIELDS
Public Instance Methods
acknowledge()
click to toggle source
TODO 使用查詢功能實作 acknowledge Pay2go
沒有遠端驗證功能, 而以 checksum_ok? 代替
# File lib/offsite_payments/integrations/pay2go/notification.rb, line 52 def acknowledge checksum_ok? end
checksum_ok?()
click to toggle source
# File lib/offsite_payments/integrations/pay2go/notification.rb, line 60 def checksum_ok? key = OffsitePayments::Integrations::Pay2go.hash_key iv = OffsitePayments::Integrations::Pay2go.hash_iv Digest::SHA256.hexdigest("HashKey=#{key}&#{@params['TradeInfo']}&HashIV=#{iv}").upcase == trade_sha end
complete?()
click to toggle source
# File lib/offsite_payments/integrations/pay2go/notification.rb, line 56 def complete? %w(SUCCESS CUSTOM).include? status end
success?()
click to toggle source
# File lib/offsite_payments/integrations/pay2go/notification.rb, line 45 def success? status == 'SUCCESS' end
trade_info()
click to toggle source
Overrides above define_method
# File lib/offsite_payments/integrations/pay2go/notification.rb, line 19 def trade_info key = OffsitePayments::Integrations::Pay2go.hash_key iv = OffsitePayments::Integrations::Pay2go.hash_iv aes = OpenSSL::Cipher.new('AES-256-CBC') aes.decrypt aes.padding = 0 aes.key = key aes.iv = iv raw_data = aes.update([@params['TradeInfo']].pack('H*')) + aes.final URI.decode_www_form(raw_data).to_h end