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



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'lib/active_merchant/billing/gateways/forte.rb', line 37

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

  commit(:post, post)
end

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



51
52
53
54
55
56
57
58
# File 'lib/active_merchant/billing/gateways/forte.rb', line 51

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



60
61
62
63
64
65
66
67
68
69
# File 'lib/active_merchant/billing/gateways/forte.rb', line 60

def credit(money, payment_method, options = {})
  post = {}
  add_amount(post, money, options)
  add_invoice(post, options)
  add_payment_method(post, payment_method, options)
  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
34
35
# File 'lib/active_merchant/billing/gateways/forte.rb', line 23

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

  commit(:post, post)
end

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



71
72
73
74
75
76
77
78
79
# File 'lib/active_merchant/billing/gateways/forte.rb', line 71

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



101
102
103
104
105
106
# File 'lib/active_merchant/billing/gateways/forte.rb', line 101

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)


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

def supports_scrubbing?
  true
end

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



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

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



81
82
83
84
85
86
87
88
# File 'lib/active_merchant/billing/gateways/forte.rb', line 81

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