Module: ActiveMerchant::Billing::Integrations::AuthorizeNetSim

Defined in:
lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb,
lib/active_merchant/billing/integrations/authorize_net_sim.rb,
lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb

Overview

# Example: parser = AuthorizeNetSim::Notification.new(request.raw_post) passed = parser.complete?

order = Order.find_by_order_number(parser.invoice_num)

unless order

@message = 'Error--unable to find your transaction! Please contact us directly.'
return render :partial => 'authorize_net_sim_payment_response'

end

if order.total != parser.gross.to_f

logger.error "Authorize.Net sim said they paid for #{parser.gross} and it should have been #{order.total}!"
passed = false

end

# Theoretically, Authorize.net will never pass us the same transaction # ID twice, but we can double check that… by using # parser.transaction_id, and checking against previous orders’ transaction # id’s (which you can save when the order is completed).…

unless parser.acknowledge MD5_HASH_SET_IN_AUTHORIZE_NET, AUTHORIZE_LOGIN

passed = false
logger.error "ALERT POSSIBLE FRAUD ATTEMPT either that or you haven't setup your md5 hash setting right in #{__FILE__} 
  because a transaction came back from Authorize.Net with the wrong hash value--rejecting!"

end

unless parser.cavv_matches? and parser.avs_code_matches?

logger.error 'Warning--non matching CC!' + params.inspect
# Could fail them here, as well (recommended)...

end

if passed

# Set up your session, and render something that will redirect them to
# your site, most likely.

else

# Render failure or redirect them to your site where you will render failure

end

Defined Under Namespace

Classes: Helper, Notification

Class Method Summary collapse

Class Method Details

.notification(post) ⇒ Object



28
29
30
# File 'lib/active_merchant/billing/integrations/authorize_net_sim.rb', line 28

def self.notification(post)
  Notification.new(post)
end

.return(query_string) ⇒ Object



32
33
34
# File 'lib/active_merchant/billing/integrations/authorize_net_sim.rb', line 32

def self.return(query_string)
  Return.new(query_string)
end

.service_urlObject



16
17
18
19
20
21
22
23
24
25
26
# File 'lib/active_merchant/billing/integrations/authorize_net_sim.rb', line 16

def self.service_url
  mode = ActiveMerchant::Billing::Base.integration_mode
  case mode
  when :production
    self.production_url    
  when :test
    self.test_url
  else
    raise StandardError, "Integration mode set to an invalid value: #{mode}"
  end
end