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



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

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)
  post[:action] = 'authorize'

  commit(:post, post)
end

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



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

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



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

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
# 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)
  post[:action] = 'sale'

  commit(:post, post)
end

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



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

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



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

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)


95
96
97
# File 'lib/active_merchant/billing/gateways/forte.rb', line 95

def supports_scrubbing?
  true
end

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



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

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



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

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