Module: ActiveMerchant::Billing::Integrations::FirstData
- Defined in:
- lib/active_merchant/billing/integrations/first_data/notification.rb,
lib/active_merchant/billing/integrations/first_data.rb,
lib/active_merchant/billing/integrations/first_data/helper.rb
Overview
First Data payment pages emulates the Authorize.Net SIM API. See ActiveMerchant::Billing::Integrations::FirstData::Notification for more details.
Example:
parser = FirstData::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 => 'first_data_payment_response' end
if order.total != parser.gross.to_f logger.error "First Data said they paid for #parserparser.gross and it should have been #orderorder.total!" passed = false end
Theoretically, First Data 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 FIRST_DATA_TRANSACTION_KEY, FIRST_DATA_RESPONSE_KEY passed = false logger.error "ALERT POSSIBLE FRAUD ATTEMPT" 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/first_data.rb', line 28 def self.notification(post) Notification.new(post) end |
.return(query_string) ⇒ Object
32 33 34 |
# File 'lib/active_merchant/billing/integrations/first_data.rb', line 32 def self.return(query_string) Return.new(query_string) end |
.service_url ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/active_merchant/billing/integrations/first_data.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 |