Class: ActiveMerchant::Billing::ClearhausGateway
- 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::DEBIT_CARDS, Gateway::RECURRING_DEPRECATION_MESSAGE, Gateway::STANDARD_ERROR_CODE
Instance Attribute Summary
Attributes inherited from Gateway
Instance Method Summary collapse
-
#authorize(amount, payment, options = {}) ⇒ Object
Authorize a transaction.
-
#capture(amount, authorization, options = {}) ⇒ Object
Capture a pre-authorized transaction.
-
#initialize(options = {}) ⇒ ClearhausGateway
constructor
Create gateway.
-
#purchase(amount, payment, options = {}) ⇒ Object
Make a purchase (authorize and capture).
-
#refund(amount, authorization, options = {}) ⇒ Object
Refund a captured transaction (fully or partial).
- #scrub(transcript) ⇒ Object
-
#store(credit_card, options = {}) ⇒ Object
Tokenize credit card with Clearhaus.
- #supports_scrubbing? ⇒ Boolean
- #verify(credit_card, options = {}) ⇒ Object
- #void(authorization, options = {}) ⇒ Object
Methods inherited from Gateway
#card_brand, card_brand, #generate_unique_id, inherited, supported_countries, #supported_countries, supported_countries=, supports?, #supports_network_tokenization?, #test?
Methods included from CreditCardFormatting
Methods included from PostsData
included, #raw_ssl_request, #ssl_get, #ssl_post, #ssl_request
Constructor Details
#initialize(options = {}) ⇒ ClearhausGateway
Create gateway
options:
:api_key - merchant's Clearhaus API Key
:signing_key - merchant's private key for optionally signing request
45 46 47 48 49 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 45 def initialize(={}) requires!(, :api_key) [:signing_key].strip! if [:signing_key] super end |
Instance Method Details
#authorize(amount, payment, options = {}) ⇒ Object
Authorize a transaction.
amount - The monetary amount of the transaction in cents. payment - The CreditCard or the Clearhaus card token. options - A standard ActiveMerchant options hash with optional pares
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 68 def (amount, payment, ={}) post = {} add_invoice(post, amount, ) 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] = [:recurring] if [:recurring] post[:threed_secure] = {pares: [:pares]} if [:pares] commit(action, post) end |
#capture(amount, authorization, options = {}) ⇒ Object
Capture a pre-authorized transaction.
amount - The monetary amount of the transaction in cents. authorization - The Clearhaus authorization id string. options - A standard ActiveMerchant options hash
92 93 94 95 96 97 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 92 def capture(amount, , ={}) post = {} add_invoice(post, amount, ) commit("/authorizations/#{}/captures", post) end |
#purchase(amount, payment, options = {}) ⇒ Object
Make a purchase (authorize and capture)
amount - The monetary amount of the transaction in cents. payment - The CreditCard or the Clearhaus card token. options - A standard ActiveMerchant options hash
56 57 58 59 60 61 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 56 def purchase(amount, payment, ={}) MultiResponse.run(:use_first_response) do |r| r.process { (amount, payment, ) } r.process { capture(amount, r., ) } end end |
#refund(amount, authorization, options = {}) ⇒ Object
Refund a captured transaction (fully or partial).
amount - The monetary amount of the transaction in cents. authorization - The Clearhaus authorization id string. options - A standard ActiveMerchant options hash
104 105 106 107 108 109 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 104 def refund(amount, , ={}) post = {} add_amount(post, amount, ) commit("/authorizations/#{}/refunds", post) end |
#scrub(transcript) ⇒ Object
137 138 139 140 141 142 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 137 def scrub(transcript) transcript. gsub(%r((Authorization: Basic )[\w=]+), '\1[FILTERED]'). gsub(%r((&?card(?:\[|%5B)csc(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]'). gsub(%r((&?card(?:\[|%5B)number(?:\]|%5D)=)[^&]*)i, '\1[FILTERED]') end |
#store(credit_card, options = {}) ⇒ Object
Tokenize credit card with Clearhaus.
credit_card - The CreditCard. options - A standard ActiveMerchant options hash
126 127 128 129 130 131 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 126 def store(credit_card, ={}) post = {} add_payment(post, credit_card) commit("/cards", post) end |
#supports_scrubbing? ⇒ Boolean
133 134 135 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 133 def supports_scrubbing? true end |
#verify(credit_card, options = {}) ⇒ Object
115 116 117 118 119 120 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 115 def verify(credit_card, ={}) MultiResponse.run(:use_first_response) do |r| r.process { (100, credit_card, ) } r.process(:ignore_result) { void(r., ) } end end |
#void(authorization, options = {}) ⇒ Object
111 112 113 |
# File 'lib/active_merchant/billing/gateways/clearhaus.rb', line 111 def void(, = {}) commit("/authorizations/#{}/voids", ) end |