Class: ActiveMerchant::Billing::ForteGateway

Inherits:
Gateway
  • Object
show all
Includes:
Empty
Defined in:
lib/active_merchant/billing/gateways/forte.rb

Constant Summary

Constants inherited from Gateway

Gateway::CREDIT_DEPRECATION_MESSAGE, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE

Instance Attribute Summary

Attributes inherited from Gateway

#options

Instance Method Summary collapse

Methods inherited from Gateway

#add_field_to_post_if_present, #add_fields_to_post_if_present, #card_brand, card_brand, #generate_unique_id, inherited, #supported_countries, supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?

Methods included from CreditCardFormatting

#expdate, #format

Methods included from PostsData

included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request

Constructor Details

#initialize(options = {}) ⇒ ForteGateway

Returns a new instance of ForteGateway.



18
19
20
21
# File 'lib/active_merchant/billing/gateways/forte.rb', line 18

def initialize(options={})
  requires!(options, :api_key, :secret, :location_id, :account_id)
  super
end

Instance Method Details

#authorize(money, payment_method, options = {}) ⇒ Object



35
36
37
38
39
40
41
42
43
44
45
# File 'lib/active_merchant/billing/gateways/forte.rb', line 35

def authorize(money, payment_method, options={})
  post = {}
  add_amount(post, money, options)
  add_invoice(post, options)
  add_payment_method(post, payment_method)
  add_billing_address(post, payment_method, options)
  add_shipping_address(post, options)
  post[:action] = 'authorize'

  commit(:post, post)
end

#capture(money, authorization, options = {}) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/forte.rb', line 47

def capture(money, authorization, options={})
  post = {}
  post[:transaction_id] = transaction_id_from(authorization)
  post[:authorization_code] = authorization_code_from(authorization) || ''
  post[:action] = 'capture'

  commit(:put, post)
end

#credit(money, payment_method, options = {}) ⇒ Object



56
57
58
59
60
61
62
63
64
65
# File 'lib/active_merchant/billing/gateways/forte.rb', line 56

def credit(money, payment_method, options={})
  post = {}
  add_amount(post, money, options)
  add_invoice(post, options)
  add_payment_method(post, payment_method)
  add_billing_address(post, payment_method, options)
  post[:action] = 'disburse'

  commit(:post, post)
end

#purchase(money, payment_method, options = {}) ⇒ Object



23
24
25
26
27
28
29
30
31
32
33
# File 'lib/active_merchant/billing/gateways/forte.rb', line 23

def purchase(money, payment_method, options={})
  post = {}
  add_amount(post, money, options)
  add_invoice(post, options)
  add_payment_method(post, payment_method)
  add_billing_address(post, payment_method, options)
  add_shipping_address(post, options)
  post[:action] = 'sale'

  commit(:post, post)
end

#refund(money, authorization, options = {}) ⇒ Object



67
68
69
70
71
72
73
74
75
# File 'lib/active_merchant/billing/gateways/forte.rb', line 67

def refund(money, authorization, options={})
  post = {}
  add_amount(post, money, options)
  post[:original_transaction_id] = transaction_id_from(authorization)
  post[:authorization_code] = authorization_code_from(authorization)
  post[:action] = 'reverse'

  commit(:post, post)
end

#scrub(transcript) ⇒ Object



97
98
99
100
101
102
# File 'lib/active_merchant/billing/gateways/forte.rb', line 97

def scrub(transcript)
  transcript.
    gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
    gsub(%r((account_number)\W+\d+), '\1[FILTERED]').
    gsub(%r((card_verification_value)\W+\d+), '\1[FILTERED]')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


93
94
95
# File 'lib/active_merchant/billing/gateways/forte.rb', line 93

def supports_scrubbing?
  true
end

#verify(credit_card, options = {}) ⇒ Object



86
87
88
89
90
91
# File 'lib/active_merchant/billing/gateways/forte.rb', line 86

def verify(credit_card, options={})
  MultiResponse.run(:use_first_response) do |r|
    r.process { authorize(100, credit_card, options) }
    r.process(:ignore_result) { void(r.authorization, options) }
  end
end

#void(authorization, options = {}) ⇒ Object



77
78
79
80
81
82
83
84
# File 'lib/active_merchant/billing/gateways/forte.rb', line 77

def void(authorization, options={})
  post = {}
  post[:transaction_id] = transaction_id_from(authorization)
  post[:authorization_code] = authorization_code_from(authorization)
  post[:action] = 'void'

  commit(:put, post)
end