Class: ActiveMerchant::Billing::VancoGateway

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

Constant Summary collapse

SECONDS_PER_DAY =
3600 * 24
BUFFER_TIME_IN_SECS =
60 * 3

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 = {}) ⇒ VancoGateway

Returns a new instance of VancoGateway.



21
22
23
24
# File 'lib/active_merchant/billing/gateways/vanco.rb', line 21

def initialize(options = {})
  requires!(options, :user_id, :password, :client_id)
  super
end

Instance Method Details

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



26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/active_merchant/billing/gateways/vanco.rb', line 26

def purchase(money, payment_method, options = {})
  moment_less_than_24_hours_ago = Time.now - SECONDS_PER_DAY - BUFFER_TIME_IN_SECS

  if options[:session_id] && options[:session_id][:created_at] >= moment_less_than_24_hours_ago
    commit(purchase_request(money, payment_method, options[:session_id][:id], options), :response_transactionref)
  else
    MultiResponse.run do |r|
      r.process {  }
      r.process { commit(purchase_request(money, payment_method, r.params['response_sessionid'], options), :response_transactionref) }
    end
  end
end

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



39
40
41
42
43
44
# File 'lib/active_merchant/billing/gateways/vanco.rb', line 39

def refund(money, authorization, options = {})
  MultiResponse.run do |r|
    r.process {  }
    r.process { commit(refund_request(money, authorization, r.params['response_sessionid']), :response_creditrequestreceived) }
  end
end

#scrub(transcript) ⇒ Object



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

def scrub(transcript)
  transcript.
    gsub(%r((<Password>).+(</Password>))i, '\1[FILTERED]\2').
    gsub(%r((<CardCVV2>).+(</CardCVV2>))i, '\1[FILTERED]\2').
    gsub(%r((<AccountNumber>).+(</AccountNumber>))i, '\1[FILTERED]\2')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


46
47
48
# File 'lib/active_merchant/billing/gateways/vanco.rb', line 46

def supports_scrubbing?
  true
end