class OffsitePayments::Integrations::Migs::Notification
Public Class Methods
new(params, options = {})
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 61 def initialize(params, options = {}) @params = params @response = parse @options = options end
Public Instance Methods
acknowledge()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 93 def acknowledge # Failures don't include a secure hash, so return directly return true unless success? # Check SecureHash only on success (not returned otherwise) unless @response[:SecureHash] == expected_secure_hash raise SecurityError, "Secure Hash mismatch, response may be tampered with" end true end
avs_response_code()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 73 def avs_response_code avs_response_code = @response[:AVSResultCode] avs_response_code = 'S' if avs_response_code == "Unsupported" avs_response_code end
card_code()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 113 def card_code return unless @response.key?(:Card) # Card doesn't appear on failure migs_code = @response[:Card] CARD_TYPES.detect { |ct| ct.migs_code == migs_code }.am_code end
cvv_result_code()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 79 def cvv_result_code cvv_result_code = @response[:CSCResultCode] cvv_result_code = 'P' if cvv_result_code == "Unsupported" cvv_result_code end
expected_secure_hash()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 105 def expected_secure_hash SecureHash.calculate(@options[:secure_hash], @response) end
fraud_review?()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 89 def fraud_review? ISSUER_RESPONSE_CODES[@response[:AcqResponseCode]] == 'Suspected Fraud' end
gross()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 109 def gross @response[:Amount].to_d / 100.0 end
message()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 133 def message # only when error @response['Message'] end
order_id()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 121 def order_id @response[:OrderInfo] end
parse()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 67 def parse @params.map.with_object({}) { |(key, value), hash| hash[key.gsub('vpc_', '').to_sym] = value } end
success?()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 85 def success? @response[:TxnResponseCode] == '0' end
transaction_id()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 129 def transaction_id @response[:TransactionNo] end
uid()
click to toggle source
# File lib/offsite_payments/integrations/migs.rb, line 125 def uid @response[:MerchTxnRef] end