Class: OffsitePayments::Integrations::Migs::Notification
- Inherits:
-
Notification
- Object
- Notification
- OffsitePayments::Integrations::Migs::Notification
- Defined in:
- lib/offsite_payments/integrations/migs.rb
Instance Method Summary collapse
- #acknowledge ⇒ Object
- #avs_response_code ⇒ Object
- #card_code ⇒ Object
- #cvv_result_code ⇒ Object
- #expected_secure_hash ⇒ Object
- #fraud_review? ⇒ Boolean
- #gross ⇒ Object
-
#initialize(params, options = {}) ⇒ Notification
constructor
A new instance of Notification.
-
#message ⇒ Object
only when error.
- #order_id ⇒ Object
- #parse ⇒ Object
- #success? ⇒ Boolean
- #transaction_id ⇒ Object
- #uid ⇒ Object
Constructor Details
#initialize(params, options = {}) ⇒ Notification
Returns a new instance of Notification.
61 62 63 64 65 |
# File 'lib/offsite_payments/integrations/migs.rb', line 61 def initialize(params, = {}) @params = params @response = parse @options = end |
Instance Method Details
#acknowledge ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 |
# 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 ⇒ Object
73 74 75 76 77 |
# 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 ⇒ Object
113 114 115 116 117 118 119 |
# 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 ⇒ Object
79 80 81 82 83 |
# 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 ⇒ Object
105 106 107 |
# File 'lib/offsite_payments/integrations/migs.rb', line 105 def expected_secure_hash SecureHash.calculate(@options[:secure_hash], @response) end |
#fraud_review? ⇒ Boolean
89 90 91 |
# File 'lib/offsite_payments/integrations/migs.rb', line 89 def fraud_review? ISSUER_RESPONSE_CODES[@response[:AcqResponseCode]] == 'Suspected Fraud' end |
#gross ⇒ Object
109 110 111 |
# File 'lib/offsite_payments/integrations/migs.rb', line 109 def gross @response[:Amount].to_d / 100.0 end |
#message ⇒ Object
only when error
133 134 135 |
# File 'lib/offsite_payments/integrations/migs.rb', line 133 def # only when error @response['Message'] end |
#order_id ⇒ Object
121 122 123 |
# File 'lib/offsite_payments/integrations/migs.rb', line 121 def order_id @response[:OrderInfo] end |
#parse ⇒ Object
67 68 69 70 71 |
# 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? ⇒ Boolean
85 86 87 |
# File 'lib/offsite_payments/integrations/migs.rb', line 85 def success? @response[:TxnResponseCode] == '0' end |
#transaction_id ⇒ Object
129 130 131 |
# File 'lib/offsite_payments/integrations/migs.rb', line 129 def transaction_id @response[:TransactionNo] end |
#uid ⇒ Object
125 126 127 |
# File 'lib/offsite_payments/integrations/migs.rb', line 125 def uid @response[:MerchTxnRef] end |