Class: ActiveMerchant::Billing::CreditcallGateway

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

Constant Summary collapse

CVV_CODE =
{
  'matched' => 'M',
  'notmatched' => 'N',
  'notchecked' => 'P',
  'partialmatch' => 'N'
}
AVS_CODE =
{
  'matched;matched' => 'D',
  'matched;notchecked' => 'B',
  'matched;notmatched' => 'A',
  'matched;partialmatch' => 'A',
  'notchecked;matched' => 'P',
  'notchecked;notchecked' => 'I',
  'notchecked;notmatched' => 'I',
  'notchecked;partialmatch' => 'I',
  'notmatched;matched' => 'W',
  'notmatched;notchecked' => 'C',
  'notmatched;notmatched' => 'C',
  'notmatched;partialmatch' => 'C',
  'partialmatched;matched' => 'W',
  'partialmatched;notchecked' => 'C',
  'partialmatched;notmatched' => 'C',
  'partialmatched;partialmatch' => 'C'
}

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

Returns a new instance of CreditcallGateway.



44
45
46
47
# File 'lib/active_merchant/billing/gateways/creditcall.rb', line 44

def initialize(options = {})
  requires!(options, :terminal_id, :transaction_key)
  super
end

Instance Method Details

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



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

def authorize(money, payment_method, options = {})
  request = build_xml_request do |xml|
    add_transaction_details(xml, money, nil, 'Auth', options)
    add_terminal_details(xml, options)
    add_card_details(xml, payment_method, options)
  end

  commit(request)
end

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



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

def capture(money, authorization, options = {})
  request = build_xml_request do |xml|
    add_transaction_details(xml, money, authorization, 'Conf', options)
    add_terminal_details(xml, options)
  end

  commit(request)
end

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



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/active_merchant/billing/gateways/creditcall.rb', line 49

def purchase(money, payment_method, options = {})
  multi_response = MultiResponse.run do |r|
    r.process { authorize(money, payment_method, options) }
    r.process { capture(money, r.authorization, options) }
  end

  merged_params = multi_response.responses.map(&:params).reduce({}, :merge)

  Response.new(
    multi_response.primary_response.success?,
    multi_response.primary_response.message,
    merged_params,
    authorization: multi_response.responses.first.authorization,
    avs_result: AVSResult.new(code: avs_result_code_from(merged_params)),
    cvv_result: CVVResult.new(cvv_result_code_from(merged_params)),
    error_code: error_result_code_from(merged_params),
    test: test?
  )
end

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



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

def refund(money, authorization, options = {})
  request = build_xml_request do |xml|
    add_transaction_details(xml, money, authorization, 'Refund', options)
    add_terminal_details(xml, options)
  end

  commit(request)
end

#scrub(transcript) ⇒ Object



117
118
119
120
121
122
# File 'lib/active_merchant/billing/gateways/creditcall.rb', line 117

def scrub(transcript)
  transcript.
    gsub(%r((<TransactionKey>).+?(</TransactionKey>))i, '\1[FILTERED]\2').
    gsub(%r((<PAN>).+?(</PAN>))i, '\1[FILTERED]\2').
    gsub(%r((<CSC>).+?(</CSC>))i, '\1[FILTERED]\2')
end

#supports_scrubbing?Boolean

Returns:

  • (Boolean)


113
114
115
# File 'lib/active_merchant/billing/gateways/creditcall.rb', line 113

def supports_scrubbing?
  true
end

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



106
107
108
109
110
111
# File 'lib/active_merchant/billing/gateways/creditcall.rb', line 106

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



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

def void(authorization, options = {})
  request = build_xml_request do |xml|
    add_transaction_details(xml, nil, authorization, 'Void', options)
    add_terminal_details(xml, options)
  end

  commit(request)
end