Class: ActiveMerchant::Billing::ClearhausGateway
- Inherits:
-
Gateway
- Object
- Gateway
- ActiveMerchant::Billing::ClearhausGateway
show all
- Defined in:
- lib/active_merchant/billing/gateways/clearhaus.rb
Constant Summary
collapse
- ACTION_CODE_MESSAGES =
{
20000 => 'Approved',
40000 => 'General input error',
40110 => 'Invalid card number',
40120 => 'Invalid CSC',
40130 => 'Invalid expire date',
40135 => 'Card expired',
40140 => 'Invalid currency',
40200 => 'Clearhaus rule violation',
40300 => '3-D Secure problem',
40310 => '3-D Secure authentication failure',
40400 => 'Backend problem',
40410 => 'Declined by issuer or card scheme',
40411 => 'Card restricted',
40412 => 'Card lost or stolen',
40413 => 'Insufficient funds',
40414 => 'Suspected fraud',
40415 => 'Amount limit exceeded',
50000 => 'Clearhaus error'
}
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
-
#authorize(amount, payment, options = {}) ⇒ Object
-
#capture(amount, authorization, options = {}) ⇒ Object
-
#initialize(options = {}) ⇒ ClearhausGateway
constructor
A new instance of ClearhausGateway.
-
#purchase(amount, payment, options = {}) ⇒ Object
-
#refund(amount, authorization, options = {}) ⇒ Object
-
#scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
-
#supports_scrubbing? ⇒ Boolean
-
#verify(credit_card, options = {}) ⇒ Object
-
#void(authorization, options = {}) ⇒ Object
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?
#expdate, #format
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
Returns a new instance of ClearhausGateway.
39
40
41
42
43
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 39
def initialize(options={})
requires!(options, :api_key)
options[:private_key] = options[:private_key].strip if options[:private_key]
super
end
|
Instance Method Details
#authorize(amount, payment, options = {}) ⇒ Object
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 52
def authorize(amount, payment, options={})
post = {}
add_invoice(post, amount, options)
action = if payment.respond_to?(:number)
add_payment(post, payment)
'/authorizations'
elsif payment.kind_of?(String)
"/cards/#{payment}/authorizations"
else
raise ArgumentError.new("Unknown payment type #{payment.inspect}")
end
post[:recurring] = options[:recurring] if options[:recurring]
post[:card][:pares] = options[:pares] if options[:pares]
commit(action, post)
end
|
#capture(amount, authorization, options = {}) ⇒ Object
71
72
73
74
75
76
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 71
def capture(amount, authorization, options={})
post = {}
add_invoice(post, amount, options)
commit("/authorizations/#{authorization}/captures", post)
end
|
#purchase(amount, payment, options = {}) ⇒ Object
45
46
47
48
49
50
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 45
def purchase(amount, payment, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(amount, payment, options) }
r.process { capture(amount, r.authorization, options) }
end
end
|
#refund(amount, authorization, options = {}) ⇒ Object
78
79
80
81
82
83
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 78
def refund(amount, authorization, options={})
post = {}
add_amount(post, amount, options)
commit("/authorizations/#{authorization}/refunds", post)
end
|
#scrub(transcript) ⇒ Object
107
108
109
110
111
112
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 107
def scrub(transcript)
transcript.
gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]').
gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]').
gsub(%r((&?card(?:\[|%5B)pan(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]')
end
|
#store(credit_card, options = {}) ⇒ Object
96
97
98
99
100
101
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 96
def store(credit_card, options={})
post = {}
add_payment(post, credit_card)
commit('/cards', post)
end
|
#supports_scrubbing? ⇒ Boolean
103
104
105
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 103
def supports_scrubbing?
true
end
|
#verify(credit_card, options = {}) ⇒ Object
89
90
91
92
93
94
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 89
def verify(credit_card, options={})
MultiResponse.run(:use_first_response) do |r|
r.process { authorize(0, credit_card, options) }
r.process(:ignore_result) { void(r.authorization, options) }
end
end
|
#void(authorization, options = {}) ⇒ Object
85
86
87
|
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 85
def void(authorization, options = {})
commit("/authorizations/#{authorization}/voids", options)
end
|