Class: AuthNetReceiver::RawTransaction
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- AuthNetReceiver::RawTransaction
- Defined in:
- app/models/auth_net_receiver/raw_transaction.rb
Class Method Summary collapse
-
.process_all! ⇒ Object
Process all raw transactions.
Instance Method Summary collapse
-
#json_data ⇒ Object
Return the JSON data on this record as a hash.
-
#process! ⇒ Object
Process this transaction.
Class Method Details
.process_all! ⇒ Object
Process all raw transactions
-
Returns a hash of counts in the form of:
{:authentic => 0, :forgeries => 0, :errors => 0}
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'app/models/auth_net_receiver/raw_transaction.rb', line 13 def self.process_all! result = {:authentic => 0, :forgeries => 0, :errors => 0} unprocessed.each do |raw_transaction| if raw_transaction.process! result[:authentic] += 1 elsif raw_transaction.errors.any? result[:errors] += 1 else result[:forgeries] += 1 end end return result end |
Instance Method Details
#json_data ⇒ Object
Return the JSON data on this record as a hash
29 30 31 32 33 34 35 36 |
# File 'app/models/auth_net_receiver/raw_transaction.rb', line 29 def json_data begin return JSON.parse(self.data) rescue JSON::ParserError, TypeError => e logger.warn "Error while parsing raw transaction data: #{e.}" return {} end end |
#process! ⇒ Object
Process this transaction
40 41 42 43 44 45 46 |
# File 'app/models/auth_net_receiver/raw_transaction.rb', line 40 def process! if is_processed raise StandardError, 'The requested transaction has already been processed' else do_processing() end end |