Class: ActiveMerchant::Billing::DataCashGateway

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

Constant Summary collapse

AUTH_TYPE =
'auth'
CANCEL_TYPE =
'cancel'
FULFILL_TYPE =
'fulfill'
PRE_TYPE =
'pre'
REFUND_TYPE =
'refund'
TRANSACTION_REFUND_TYPE =
'txn_refund'
POLICY_ACCEPT =
'accept'
POLICY_REJECT =
'reject'

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

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

Returns a new instance of DataCashGateway.



27
28
29
30
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 27

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

Instance Method Details

#authorize(money, authorization_or_credit_card, options = {}) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 44

def authorize(money, authorization_or_credit_card, options = {})
  requires!(options, :order_id)

  if authorization_or_credit_card.is_a?(String)
    request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
  else
    request = build_purchase_or_authorization_request_with_credit_card_request(PRE_TYPE, money, authorization_or_credit_card, options)
  end

  commit(request)
end

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



56
57
58
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 56

def capture(money, authorization, options = {})
  commit(build_void_or_capture_request(FULFILL_TYPE, money, authorization, options))
end

#credit(money, reference_or_credit_card, options = {}) ⇒ Object



66
67
68
69
70
71
72
73
74
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 66

def credit(money, reference_or_credit_card, options = {})
  if reference_or_credit_card.is_a?(String)
    ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
    refund(money, reference_or_credit_card)
  else
    request = build_credit_request(money, reference_or_credit_card, options)
    commit(request)
  end
end

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



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 32

def purchase(money, authorization_or_credit_card, options = {})
  requires!(options, :order_id)

  if authorization_or_credit_card.is_a?(String)
    request = build_purchase_or_authorization_request_with_continuous_authority_reference_request(AUTH_TYPE, money, authorization_or_credit_card, options)
  else
    request = build_purchase_or_authorization_request_with_credit_card_request(AUTH_TYPE, money, authorization_or_credit_card, options)
  end

  commit(request)
end

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



76
77
78
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 76

def refund(money, reference, options = {})
  commit(build_transaction_refund_request(money, reference))
end

#scrub(transcript) ⇒ Object



84
85
86
87
88
89
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 84

def scrub(transcript)
  transcript.
    gsub(/(<pan>)\d+(<\/pan>)/i, '\1[FILTERED]\2').
    gsub(/(<cv2>)\d+(<\/cv2>)/i, '\1[FILTERED]\2').
    gsub(/(<password>).+(<\/password>)/i, '\1[FILTERED]\2')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


80
81
82
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 80

def supports_scrubbing?
  true
end

#void(authorization, options = {}) ⇒ Object



60
61
62
63
64
# File 'lib/active_merchant/billing/gateways/data_cash.rb', line 60

def void(authorization, options = {})
  request = build_void_or_capture_request(CANCEL_TYPE, nil, authorization, options)

  commit(request)
end